Google
向 Gemini CLI 添加 MCP 服务器
Gemini CLI 从 ~/.gemini/ 或项目 .gemini/ 目录中的 settings.json 读取 mcpServers。
- macOS
~/.gemini/settings.json- Windows
~/.gemini/settings.json- Linux
~/.gemini/settings.json- 项目文件
.gemini/settings.json- 顶层键
mcpServers- 格式
- json
- 远程服务器的 OAuth
- 是
配置示例
此示例按该客户端所需的格式,添加 GitHub 托管的服务器和作为本地服务器的 Playwright。
{
"mcpServers": {
"github": {
"httpUrl": "https://api.githubcopilot.com/mcp/"
},
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}
gemini mcp add -s project -t http github https://api.githubcopilot.com/mcp/
gemini mcp add -s project playwright npx @playwright/mcp@latest
注意事项和特殊情况
- 字段名决定传输方式:Streamable HTTP 使用 httpUrl,SSE 使用 url,stdio 使用 command。
- 运行 gemini mcp add 时,配置默认写入项目级范围;传入 -s user 可改为用户级范围。
- includeTools 和 excludeTools 可筛选模型能看到的工具。
- OAuth token 保存在 ~/.gemini/mcp-oauth-tokens.json。
其他客户端
Claude DesktopClaude CodeCursorVS Code (GitHub Copilot)Windsurf / Devin DesktopZedOpenAI Codex CLIChatGPTOpenClawClineContinueJetBrains AI Assistant