使用说明
MCP关键字搜索服务器
该项目实现了 模型上下文协议(MCP) 服务器和客户端使用 Node.js.
它允许您在给定的文本文件中搜索特定的关键字,演示MCP工具如何通过标准输入/输出进行通信。
目录
特性
- 内置
@modelcontextprotocol/sdk - 实现自定义MCP工具:
keyword-search - 在文本文件中搜索特定关键字
- 使用以下颜色编码的干净输出
chalk - 完全开源,轻量级
项目结构
mcp服务器/
│
├── index.js#MCP服务器实现
├── client.js#客户端发送关键字搜索请求
├── sample.txt#示例输入文件
├── package.json
Mabalin遇到了i-print学生。
├── 许可证
└── README.md
安装说明
1.克隆存储库
git clone https://github.com/TuShArBhArDwA/mcp-keyword-search-server.git
cd mcp-keyword-search-server
2.安装依赖项
npm install
3.运行客户端
node client.js
您应该看到类似于以下内容的输出:
Starting MCP Keyword Search Server...
Sending keyword-search request...
Search Result:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Found 1 line(s):
This is Tushar
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
运作原理
- MCP服务器(index.js)使用SDK定义工具关键字搜索。
- 客户端(client.js)发送一个带有文件路径和关键字的MCP请求。
- 服务器读取文件,找到匹配的行,并返回结果。
示例文件
sample.txt
Hello world
This is Tushar
Keyword search test
Example Request:
{
"filePath": "sample.txt",
"keyword": "Tushar"
}
Response
Found 1 line(s):
This is Tushar
截图
Salesforce自定义对象屏幕截图
MCP服务器输出屏幕截图
许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
联系
- 认识T-Bot - 发现我的作品
- Tushar Bhardwaj - 投资组合
- 连接1:1 - Topmate
- github: TuShArBhArDwA
- 领英: Tushar Bhardwaj
- 电子邮件: tusharbhardwaj2617@example.com