使用说明
🧩 MCP服务器–关键字搜索工具
这个项目是一个MCP(模型上下文协议)服务器,它为 在文本文件中搜索关键字.
🚀 特性
- 在指定文件中搜索任何关键字。
- 以JSON格式返回匹配的行。
- 使用Node.js和Express构建。
📁 项目结构
mcp-server/
├── index.js # Main MCP server file
├── package.json # Node dependencies
├── sample.txt # Example file for testing
└── README.md # Project documentation
⚙️ 安装
- 克隆此存储库:
克隆https://github.com/Navateja-gupta/MCP.git cd-mcp服务器
2. Install dependencies:
```bash
npm install
- 启动MCP服务器:
node index.js ``
🔹 端点:
POST /search_in_file
🔹 请求示例(PowerShell):
Invoke-WebRequest -Uri "http://localhost:3000/search_in_file" `
-Method POST `
-ContentType "application/json" `
-Body '{"file_path": "C:/path/to/sample.txt", "keyword": "error"}'
🔹 示例响应:
{"message":"✅ Found 2 matches",
"matches":["An error occurred in the system.",
"Critical error found in logs."
]
}