关键词搜索服务器

一个基于Model Context Protocol (MCP)的服务器,用于在文本文件中搜索关键词。

  • by RHL-RWT-01
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 RHL-RWT-01/MCP-Inspector

使用说明

关键字搜索MCP服务器

一种在文本文件中搜索关键字的模型上下文协议(MCP)服务器。

快速开始

1.安装依赖项

npm install

2.建设项目

npm run build

3.测试服务器

npm test

测试方法

方法1:自动测试客户端(推荐)

运行自动测试所有服务器功能的测试客户端:

npm run test:client

方法2:MCP检查员(交互式测试)

使用官方MCP检查器进行交互式调试:

  1. 全局安装MCP检查器:
npm install -g @modelcontextprotocol/inspector
  1. 运行检查器:
npx @modelcontextprotocol/inspector node dist/index.js

这将打开一个web界面,您可以在其中:

  • 查看可用工具
  • 使用自定义参数调用工具
  • 查看实时日志和响应

可用命令

  • npm run build -将TypeScript编译为JavaScript
  • npm 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."
    }
  ]
}