dotsagent.io
语言:简体中文
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。

.gemini/settings.json
{
  "mcpServers": {
    "github": {
      "httpUrl": "https://api.githubcopilot.com/mcp/"
    },
    "playwright": {
      "command": "npx",
      "args": [
        "@playwright/mcp@latest"
      ]
    }
  }
}
shell
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。

生成 Gemini CLI 配置 →

其他客户端

来源

  1. geminicli.com/docs/tools/mcp-server/
  2. raw.githubusercontent.com/google-gemini/gemini-cli/main/docs/tools/mcp-server.md

为 AI agent 开发者提供的独立参考资料。与此处提及的任何厂商均无关联。

© 2026 DotsAgent · 事实核查日期:2026年10月1日