概覽

Cursor CLI 支援 Model Context Protocol(MCP) 伺服器,讓你把外部工具與資料來源連結到 cursor-agentCLI 的 MCP 與編輯器使用相同設定——你配置的任何 MCP 伺服器都能在兩者間無縫運作。

深入了解 MCP

第一次接觸 MCP?閱讀完整指南,了解設定、驗證與可用伺服器

CLI 指令

使用 cursor-agent mcp 指令來管理 MCP 伺服器:

列出已設定的伺服器

檢視所有已設定的 MCP 伺服器及其目前狀態:
cursor-agent mcp list
這會顯示:
  • 伺服器名稱與識別碼
  • 連線狀態(已連線/未連線)
  • 設定來源(專案或全域)
  • 傳輸方式(stdio、HTTP、SSE)

列出可用工具

檢視特定 MCP 伺服器提供的工具:
cursor-agent mcp list-tools <identifier>
這會顯示:
  • 工具名稱與說明
  • 必填與選填參數
  • 參數型別與限制條件

登入 MCP 伺服器

使用在你的 mcp.json 中設定的 MCP 伺服器進行驗證:
cursor-agent mcp login <identifier>

停用 MCP 伺服器

從本機核可清單中移除某個 MCP 伺服器:
cursor-agent mcp disable <identifier>

在 Agent 中使用 MCP

一旦你設定好 MCP 伺服器(請參考主要 MCP 指南 進行設定),cursor-agent 會在需要時自動探索並使用可用的工具來回應你的請求。
# 檢查可用的 MCP 伺服器
cursor-agent mcp list

# 查看特定伺服器提供的工具
cursor-agent mcp list-tools playwright

# 直接用 cursor-agent —— 需要時會自動使用 MCP 工具
cursor-agent --prompt "Navigate to google.com and take a screenshot of the search page"
CLI 會遵循與編輯器相同的設定優先序(專案 → 全域 → 巢狀),並自動從父目錄探索設定。