Spirit Agent
下載

MCP

使用者的 mcp.json 加上工作區的 .spirit/mcp.json。相同伺服器名稱時,以工作區為準。

MCP 伺服器從 Spirit 外部加入工具、資源與提示詞。

範圍路徑
使用者{spiritDataDir}/mcp.json
工作區{workspace}/.spirit/mcp.json

當兩個檔案定義相同的伺服器名稱時,工作區的項目優先。

設定 → MCP 中管理伺服器,或使用 CLI 的 spirit mcplistshowinitenabledisableinspecttoolscall-tool 等)。

MCP 工具會合併到 Agent 既有的工具清單中。高風險的工具仍會經過核准

檔案欄位

根物件只有 servers。每個伺服器必須包含 transport,且 type 設為 stdiohttp

欄位說明
servers物件。鍵為伺服器名稱
displayName選用。介面標籤;預設為伺服器名稱。也接受 display_name
enabled選用。預設為 true
capabilities.tools選用。預設為 true
capabilities.resources選用。預設為 true
capabilities.prompts選用。預設為 true
transport.type必填。stdiohttp

stdio

欄位說明
command必填。啟動指令
args選用。指令參數
env選用。環境變數。值可使用 ${env:NAME}
cwd選用。工作目錄
timeoutMs選用。逾時(毫秒)。也接受 timeout_ms
stderr選用。inherit(預設)或 pipe

http

欄位說明
url必填。伺服器 URL
headers選用。請求標頭。值可使用 ${env:NAME}
timeoutMs選用。逾時(毫秒)。也接受 timeout_ms

範例

{
  "servers": {
    "local-docs": {
      "displayName": "Local docs",
      "enabled": true,
      "capabilities": {
        "tools": true,
        "resources": true,
        "prompts": false
      },
      "transport": {
        "type": "stdio",
        "command": "npx",
        "args": ["-y", "example-mcp-server"],
        "env": {
          "API_TOKEN": "${env:EXAMPLE_API_TOKEN}"
        },
        "cwd": "/path/to/workspace",
        "timeoutMs": 15000,
        "stderr": "pipe"
      }
    },
    "remote-tools": {
      "transport": {
        "type": "http",
        "url": "https://mcp.example.com/mcp",
        "headers": {
          "Authorization": "Bearer ${env:EXAMPLE_MCP_TOKEN}"
        },
        "timeoutMs": 20000
      }
    }
  }
}