使用说明
my_mcp_server
该项目提供了一个端到端可测试的MCP(模型上下文协议)服务器环境,包括一个基于FastAPI的聊天机器人生成存根、一个MCP服务器和一个用于测试 generate 工具。主要重点是实现聊天机器人生成工作流程的轻松本地测试。
TLDR:此软件包负责llm摄入的端到端pdf预处理。
它为pdfplumber添加了几个功能
MCP服务器反馈机制 代理自适应pdf解析。 迭代进化框架。
项目结构
my_mcp_server/
├── [`chatbot_generation_stub.py`](chatbot_generation_stub.py )
├── [`client_stub.py`](client_stub.py )
├── common/
│ └── [`common/config.py`](common/config.py )
├── config/
│ └── [`config/custom_config.toml`](config/custom_config.toml )
├── [`main.py`](main.py )
├── [`run_all_test.sh`](run_all_test.sh )
├── [`run_inspector.sh`](run_inspector.sh )
├── [`run_mcp_server.sh`](run_mcp_server.sh )
├── [`server.py`](server.py )
├── [`pyproject.toml`](pyproject.toml )
└── ...
快速入门:端到端测试
测试整个管道的推荐方法,包括 generate 工具,就是使用 run_all_test.sh 脚本。此脚本将:
- 从中读取聊天机器人API端口
config/custom_config.toml. - 等待聊天机器人API在配置的端口上可用。
- 启动聊天机器人API存根(
chatbot_generation_stub.py). - 启动MCP服务器(
server.py). - 启动MCP检查器(
run_inspector.sh). - (可选)运行客户端存根(
client_stub.py)为了测试generate工具。 - 测试后清理所有后台进程。
如何跑步
-
安装依赖项
请确保您已安装Python 3.10+和Node.js。
安装Python依赖项:pip install -r requirements.txt或者,如果使用Poetry或PDM,请通过您喜欢的工具进行安装。
-
运行测试脚本
从项目根目录执行:bash run_all_test.sh脚本将:
- 等待聊天机器人API在
http://127.0.0.1:<port>/(来自配置的端口)。 - 启动所有必需的服务。
- 安装后提示您继续。
- (可选)运行客户端存根以测试
generate工具。
- 等待聊天机器人API在
-
测试
generate工具
客户存根(client_stub.py)连接到MCP服务器并调用generate该工具反过来调用聊天机器人API存根并打印结果。
配置
- 聊天机器人API端口和其他设置配置在
config/custom_config.toml. - MCP服务器通过以下方式从该文件读取其配置
common/config.py.
组件
chatbot_generation_stub.py:FastAPI应用程序模拟聊天机器人生成端点。server.py:MCP服务器暴露generate工具。client_stub.py:连接到MCP服务器并测试generate工具。run_all_test.sh:协调完整的端到端测试环境。
备注
- 该脚本假定所有命令(
uv,npx等)在您的PATH中可用。 - 对于自定义配置,请编辑
config/custom_config.toml.
有关每个组件的更多详细信息,请参阅
