dotsagent.io
ภาษา:ไทย
Google

เพิ่มเซิร์ฟเวอร์ MCP ใน Gemini CLI

Gemini CLI อ่าน mcpServers จาก settings.json ใน ~/.gemini/ หรือโฟลเดอร์ .gemini/ ของโปรเจกต์

macOS
~/.gemini/settings.json
Windows
~/.gemini/settings.json
Linux
~/.gemini/settings.json
ไฟล์โปรเจกต์
.gemini/settings.json
Key ระดับบนสุด
mcpServers
รูปแบบ
json
OAuth สำหรับเซิร์ฟเวอร์ remote
ใช่

ตัวอย่าง config

ตัวอย่างนี้เพิ่มเซิร์ฟเวอร์ที่ GitHub โฮสต์ไว้และ Playwright เป็นเซิร์ฟเวอร์ local โดยใช้รูปแบบที่ไคลเอนต์นี้รองรับ

.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

หมายเหตุและข้อควรระวัง

  • ชื่อฟิลด์จะกำหนด transport: httpUrl สำหรับ Streamable HTTP, url สำหรับ SSE และ command สำหรับ stdio
  • gemini mcp add จะเพิ่มเซิร์ฟเวอร์ในขอบเขตโปรเจกต์ เว้นแต่จะระบุ -s user
  • includeTools และ excludeTools ใช้กรองว่าโมเดลจะเห็นเครื่องมือใดบ้าง
  • ระบบบันทึก OAuth token ไว้ใน ~/.gemini/mcp-oauth-tokens.json

สร้าง config สำหรับ Gemini CLI →

ไคลเอนต์อื่น

แหล่งที่มา

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