关键字搜索MCP服务器
一种在文本文件中搜索关键字的模型上下文协议(MCP)服务器。
快速开始
1.安装依赖项
npm install2.建设项目
npm run build3.测试服务器
npm test测试方法
方法1:自动测试客户端(推荐)
运行自动测试所有服务器功能的测试客户端:
npm run test:client方法2:MCP检查员(交互式测试)
使用官方MCP检查器进行交互式调试:
- 全局安装MCP检查器:
npm install -g @modelcontextprotocol/inspector- 运行检查器:
npx @modelcontextprotocol/inspector node dist/index.js这将打开一个web界面,您可以在其中:
- 查看可用工具
- 使用自定义参数调用工具
- 查看实时日志和响应
可用命令
npm run build-将TypeScript编译为JavaScriptnpm start-运行已编译的服务器npm run dev-在一个命令中构建和运行npm run test:client-运行自动化测试
工具文档
搜索文件
在文本文件中搜索关键字(不区分大小写)。
参数:
keyword(必填):要搜索的关键字filePath(可选):文件路径(默认为./sample.txt)
退货:
- 已找到匹配项数的消息
- 带有行号的匹配行数组
- 如果找不到文件,则显示错误消息
示例响应:
{
"message": "Found 2 match(es) for 'MCP':",
"matches": [
{
"lineNumber": 2,
"text": "The MCP server will search for a given keyword inside this file."
},
{
"lineNumber": 4,
"text": "Learning with Salesforce and MCP together."
}
]
}