使用 Python SDK 的文档 MCP 服务器
先决条件
uv
包管理器(可选但强烈推荐)
- claude 桌面版或 cursor(基本上任何 MCP 客户端)
- Serper 账号 - 用于搜索工具(免费,无需信用卡)
安装
将 MCP 添加到您的 Python 项目
uv add "mcp[cli]"
或者对于使用 pip 管理依赖项的项目:
pip install "mcp[cli]"
开发者快速入门
克隆仓库
git clone https://github.com/shivansh12t/docs-mcp-pythonsdk
cd docs-mcp-pythonsdk
安装依赖项(可选)
uv pip sync
根据 template.env 创建 .env 文件
SERPER_API_KEY=<your_api_key>
将 MCP 服务器添加到 VSCode Copilot 聊天中
- 打开
.vscode/mcp.json
文件
- 更新 args 到您项目的绝对路径的 MCP 服务器
- 它应该以
Agent Mode
正常运行
- 如果有任何问题,请访问 在 VSCode Copilot Chat 中使用 MCP 服务器
将 MCP 添加到客户端 - 这里是 Claude 桌面版
- 打开 Claude 桌面版,转到设置
shift + ,
- 选择
编辑配置文件
- 添加以下 JSON 内容,将路径替换为正确的
claude_desktop_configurations.json
路径
{
"mcpServers": {
"documentation": {
"command": "uv",
"args": [
"--directory",
"absolute/path/to/the/project",
"run",
"main.py"
]
}
}
}
- 重新启动 Claude,如果在聊天框附近看到锤子符号,则表示您的 MCP 已经正常运行
使用 MCP 检查工具
npx @modelcontextprotocol/inspector uv run main.py