MCP服务器工具
这是一个使用Flask构建的简单MCP(模型上下文协议)服务器。 它在文本文件中搜索给定的关键字,并返回包含该关键字的所有行。
如何跑步
- 安装烧瓶\
管道安装烧瓶
- 运行服务器\
python服务器.py
C++ 复制代码 3.测试终点(使用Postman或curl):\ 发布http://127.0.0.1:5000/search
层叠样式表
正文(JSON):
{
"keyword": "Satyam",
"file_path": "sample.txt"
}
Output Example:
json
Copy code
{
"keyword": "Satyam",
"matches": [
{
"line_number": 3,
"text": "This assignment belongs to Satyam Kumar."
}
]
}
---
### 🪜 Steps to Create It in VS Code
1. **Open VS Code** → Click **File → Open Folder** → select a location (like Desktop).
2. **Create Folder:**
- Name it `MCP_Server`
3. **Inside it:**
- Right-click → **New File** → `server.py`
- Right-click → **New File** → `sample.txt`
- (optional) Right-click → **New File** → `README.md`
4. **Copy and paste** the above content into each file.
5. **Open Terminal in VS Code** → type:
pip install flask
6. Then run:
python server.py
Copy code
7. You’ll see:
Running on http://127.0.0.1:5000