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-server2.️⃣ 再进行
npm install3.️⃣ 构建项目
npm run build4.️⃣ 运行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:
______________________________________________________________________
