PR检查员
用于检查和分析拉取请求的模型上下文协议(MCP)服务器。
设置
此项目使用 uv 用于依赖性管理。要设置环境,请执行以下操作:
- 安装
uv(如果尚未安装):
curl -LsSf https://astral.sh/uv/install.sh | sh- 安装依赖项:
uv sync- 配置服务器(可选):
- 编辑 config.yaml 更改主机、端口或传输设置 - 默认设置: host: 127.0.0.1, port: 8000, transport: http
- 运行MCP服务器(在一个终端中):
# Option 1: Using the console script (recommended)
uv run pr-inspector
# Option 2: Using Python module syntax
uv run python -m pr_inspector.server服务器将开始使用以下设置 config.yaml (默认值: http://127.0.0.1:8000/mcp)并等待连接。
测试
要测试MCP服务器并验证其是否正常工作:
- 首先,启动服务器 (在一个终端中):
uv run pr-inspector服务器将于启动 http://127.0.0.1:8000/mcp
- 然后,运行测试客户端 (在另一个终端中):
uv run python -m pr_inspector.test_client测试客户端将:
- 连接到正在运行的MCP服务器
- 列出可用工具
- 打电话给
say_hello具有不同参数的端点
发展
MCP服务器公开用于PR检查的工具。目前可用:
say_hello:问候指定名称的hello world端点
使用MCP服务器
选项1:测试客户端(建议用于开发)
使用附带的测试客户端验证功能:
uv run python -m pr_inspector.test_client选项2:连接MCP客户端
服务器可以连接到任何兼容MCP的客户端。服务器在HTTP上运行 http://127.0.0.1:8000/mcp.
对于基于stdio的MCP客户端,您可以通过更改中的最后一行来修改服务器以使用stdio传输 pr_inspector/server.py 发件人:
mcp.run(transport="http", host="127.0.0.1", port=8000)致:
mcp.run() # Uses stdio transport by default选项3:程序化使用
您还可以在自己的Python代码中使用FastMCP客户端连接到正在运行的HTTP服务器:
import asyncio
from fastmcp import Client
async def main():
# Connect to the HTTP server (make sure it's running first)
client = Client("http://127.0.0.1:8000/mcp")
async with client:
result = await client.call_tool("say_hello", {"name": "YourName"})
print(result.content[0].text)
asyncio.run(main())