Anthropic
เพิ่มเซิร์ฟเวอร์ MCP ใน Claude Code
Claude Code รับเซิร์ฟเวอร์จากคำสั่ง claude mcp add หรือไฟล์ .mcp.json ที่ root ของ repository
- macOS
~/.claude.json- Windows
~/.claude.json- Linux
~/.claude.json- ไฟล์โปรเจกต์
.mcp.json- Key ระดับบนสุด
mcpServers- รูปแบบ
- json
- OAuth สำหรับเซิร์ฟเวอร์ remote
- ใช่
ตัวอย่าง config
ตัวอย่างนี้เพิ่มเซิร์ฟเวอร์ที่ GitHub โฮสต์ไว้และ Playwright เป็นเซิร์ฟเวอร์ local โดยใช้รูปแบบที่ไคลเอนต์นี้รองรับ
{
"mcpServers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/"
},
"playwright": {
"type": "stdio",
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}
claude mcp add --transport http --scope project github https://api.githubcopilot.com/mcp/
claude mcp add --scope project playwright -- npx @playwright/mcp@latest
หมายเหตุและข้อควรระวัง
- การตั้งค่าขอบเขต local ซึ่งเป็นค่าเริ่มต้น และขอบเขต user จะเก็บไว้ใน ~/.claude.json ส่วนขอบเขต project จะอยู่ใน .mcp.json
- ทุกรายการที่มี url ต้องระบุ type ด้วย เช่น http; หากมี url เพียงอย่างเดียวจะเกิดข้อผิดพลาด
- ค่าในไฟล์รองรับการแทนค่า ${VAR} และ ${VAR:-default}
- เรียกใช้ /mcp ในเซสชันเพื่อเข้าสู่ระบบเซิร์ฟเวอร์ OAuth สำหรับแอป OAuth ที่ลงทะเบียนไว้ล่วงหน้า ให้ส่ง --client-id, --client-secret และ --callback-port
สร้าง config สำหรับ Claude Code →
ไคลเอนต์อื่น
Claude DesktopCursorVS Code (GitHub Copilot)Windsurf / Devin DesktopZedOpenAI Codex CLIGemini CLIChatGPTOpenClawClineContinueJetBrains AI Assistant