GitHub Copilot插件在PyCharm中无法使用Context7和 Sentry MCP服务器
复现步骤:
- 在编辑器中打开mcp.json文件(视图菜单 -> 工具窗口 -> GitHub Copilot MCP日志 -> 编辑配置)
- 在 "servers" 节点下添加Context7 MCP服务器
json
"context7": {
"tools": [
"query-docs",
"resolve-library-id"
],
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@upstash/context7-mcp",
"--api-key",
"ctx7sk-some-other-values-6a82ad7ab509"
]
}
3.启动服务器(成功运行,以下是日志)
[2026-05-27 04:47:46.489][info] [context7]Starting server context7
[2026-05-27 04:47:58.105][warning] [context7][server stderr] Context7 Documentation MCP Server v3.0.0 running on stdio
[2026-05-27 04:47:58.115][info] [context7]Connection state: Running
4.让代理使用context7执行任务,例如
Create another FastAPI server with GET /health endpoint, use context7
代理尝试使用 resolve-library-id 工具,输入如下
{
"libraryName": "FastAPI",
"query": "Create a minimal FastAPI server with a GET /health endpoint, including recommended startup and uvicorn run pattern."
}
但输出如下,未成功
Invalid API key. Please check your API key. API keys should start with 'ctx7sk' prefix.
我在另外两个地方测试了相同的配置:
- Copilot CLI(
~/.copilot/mcp-config.json) MCP Inspector使用stdio命令。 在两处都能正常工作!
Sentry也出现了同样的问题,得到
**Authorization Expired**
Sentry rejected the stored access token for this session. Please re-authorize to continue.
在PyCharm中的GitHub Copilot插件也无法使用其他服务器,如 playwright 和 fetch!
解决方案
经过大量尝试和排查,我发现了问题所在。
在PyCharm中,依次进入 设置 → Enable MCP server。就我而言,它已经启用并自动配置为使用带有 Codex 的MCP服务器。
问题在于我之前安装过Codex然后又卸载了它。 解决办法如下:
- 完全删除
~/.codex文件夹 - 重启PyCharm
之后,一切都正常工作。我甚至完全禁用了 Enable MCP server,Copilot仍然能够使用MCP服务器和工具,毫无问题。