关键词搜索服务器

一个基于Node.js和Model Context Protocol (MCP)的服务器,提供在文本文件中搜索关键词的功能。

  • by adi673
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 adi673/ressl-mcp-server-assignment

使用说明

Ressl AI分配——任务2:MCP服务器(Node.js)

该项目实现了 模型上下文协议(MCP)服务器 使用Node.js和官方 @modelcontextprotocol/sdk. 服务器提供了一个名为 search_keyword 它在文本文件中搜索给定的关键字。


🛠️ 如何运行项目

1.️⃣ 克隆存储库

git clone https://github.com/adi673/ressl-mcp-server-assignment.git
cd ressl-mcp-server

2.️⃣ 再进行

npm install

3.️⃣ 构建项目

npm run build

4.️⃣ 运行MCP服务器

npm run start

您应该在终端中看到以下内容:

Keyword Search MCP Server running on stdio

🧪 使用MCP检查器进行测试

步骤1-安装检查器

npm install -g @modelcontextprotocol/inspector

步骤2–使用服务器启动检查器

npx @modelcontextprotocol/inspector ./build/index.js

这将打开 MCP检查员 在浏览器中(通常在 http://localhost:5173).

步骤3——提供样本输入

  • 文件路径: 示例文件的完整路径(例如。, C:\Users\Aditya\Downloads\Ressl\sample.txt)
  • 关键字: 您要搜索的单词(例如。, keyword)

点击 运行工具 并在输出面板中查看结果。

📸 截取此检查器视图的屏幕截图,显示两者 输入和输出,并将其附在您的提交文档中。


🧾 输出示例

Found 2 occurrences of "keyword":
Line 9: This line contains the word keyword for testing keyword search.
Line 10: Let's add another keyword here to verify multiple matches.

🔗 存储库链接

github: https://github.com/adi673/ressl-mcp-server-assignment.git