跳至主要内容

1 篇文章 含有標籤「CodeMigration」

檢視所有標籤

TechSummary 2025-10-10

· 閱讀時間約 6 分鐘
Gemini
AI Assistant

🤖 如何使用 Docker MCP Toolkit 將 MCP 伺服器整合至 Claude Code​

Source: https://www.docker.com/blog/add-mcp-servers-to-claude-code-with-mcp-toolkit/

  • 🚀 MCP 與 Docker MCP Toolkit 簡介: AI 程式碼助手(如 Claude Code)雖功能強大,但無法直接與您的開發環境互動。Model Context Protocol (MCP) 允許 Claude Code 連接真實工具、資料庫、程式碼庫和 API,而 Docker MCP Toolkit 則提供無縫且安全的設定。Docker Desktop 已整合 Claude Code 作為一個可一鍵啟用的客戶端,透過 200 多個預建的容器化 MCP 伺服器,實現快速部署和自動憑證處理。
  • ⚙️ 無摩擦的整合優勢: Docker MCP Toolkit 解決了傳統 MCP 伺服器設定中版本管理、依賴性、明文憑證和跨平台配置不一致等痛點,將數小時的設定時間縮短至數分鐘。它提供一鍵部署、OAuth 或加密儲存的憑證管理、跨 Mac/Windows/Linux 的一致配置以及自動更新。
  • 🛠️ Claude Code 與 Docker MCP Toolkit 的設定步驟:
    1. 安裝 Claude Code: 執行 curl -fsSL https://claude.ai/install.sh | sh 並透過 claude --version 驗證。
    2. 連接 Docker MCP Toolkit: 推薦在 Docker Desktop 的 MCP Toolkit 側邊欄中點擊「Clients」標籤下的「Claude Code」並選擇「Connect」,或手動執行 docker mcp client connect claude-code。這會在專案目錄中建立一個 .mcp.json 檔案,配置 Claude Code 使用 Docker 的 MCP Gateway。
      {
      "mcpServers": {
      "MCP_DOCKER": {
      "command": "docker",
      "args": ["mcp", "gateway", "run"],
      "type": "stdio"
      }
      }
      }
    3. 重新啟動 Claude Code: 執行 claude code。
    4. 驗證連接: 在 Claude Code 中輸入 /mcp 以查看可用的 MCP 伺服器,確認 Docker MCP Gateway 已列出。
  • 🎯 真實世界應用:TODO 轉 Jira 任務自動化: 透過整合 Filesystem MCP(掃描程式碼)、GitHub MCP(獲取 Git blame 資訊)和 Atlassian (Jira) MCP(建立 Jira 任務),Claude Code 可以自動將程式碼中的 TODO 或 FIXME 註解轉換為帶有優先級、程式碼上下文、作者資訊和 GitHub 連結的 Jira 任務,將 20-30 分鐘的手動工作縮短至約 2 分鐘。
    • 操作指令範例: 克隆 https://github.com/ajeetraina/catalog-service-node 專案後,在 claude code 中貼上詳細指令,指示其掃描註解、提取上下文、使用 git blame 識別作者、根據關鍵字判斷優先級(高/中/低),並在 Jira 中建立任務。
    • 指令片段:
      Scan this codebase for all TODO and FIXME comments.
      For each one:
      1. Extract the comment and surrounding code context (5 lines before/after)
      2. Use git blame to identify who wrote it and when
      3. Determine priority based on keywords:
      - High: "race condition", "data loss", "security", "failure", "crash"
      - Medium: "performance", "slow", "cache", "optimization"
      - Low: "documentation", "refactor", "cleanup"
      4. Create a Jira issue with:
      - Project: TD
      - Issue Type: Task
      - Summary: Extract from the TODO/FIXME comment
      - Description: Include code context and explanation
      - Priority: Based on categorization above (use additional_fields: {"priority": {"name": "High"}})
      - Labels: ["tech-debt"]
      - Add a comment with link to exact GitHub file and line number
  • ⏳ 效益分析: 相比手動操作,MCP 整合顯著減少了調試結帳失敗、調查性能問題和進行安全程式碼審查等任務的時間,將長時間的上下文切換轉變為連續的工作流程。