GitHub Copilot插件在PyCharm中无法使用Context7和 Sentry MCP服务器

后端开发 2026-07-09

复现步骤:

  1. 在编辑器中打开mcp.json文件(视图菜单 -> 工具窗口 -> GitHub Copilot MCP日志 -> 编辑配置)
  2. 在 "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.

我在另外两个地方测试了相同的配置:

  1. Copilot CLI(~/.copilot/mcp-config.json
  2. MCP Inspector 使用stdio命令。 在两处都能正常工作!

Sentry也出现了同样的问题,得到

**Authorization Expired** 
Sentry rejected the stored access token for this session. Please re-authorize to continue.

在PyCharm中的GitHub Copilot插件也无法使用其他服务器,如 playwrightfetch

解决方案

经过大量尝试和排查,我发现了问题所在。

在PyCharm中,依次进入 设置 → Enable MCP server。就我而言,它已经启用并自动配置为使用带有 Codex 的MCP服务器。

问题在于我之前安装过Codex然后又卸载了它。 解决办法如下:

  1. 完全删除 ~/.codex 文件夹
  2. 重启PyCharm

之后,一切都正常工作。我甚至完全禁用了 Enable MCP server,Copilot仍然能够使用MCP服务器和工具,毫无问题。

站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章