TechSummary 2025-10-10
· 閱讀時間約 6 分鐘
🤖 如何使用 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 的設定步驟:
- 安裝 Claude Code: 執行
curl -fsSL https://claude.ai/install.sh | sh並透過claude --version驗證。 - 連接 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"
}
}
} - 重新啟動 Claude Code: 執行
claude code。 - 驗證連接: 在 Claude Code 中輸入
/mcp以查看可用的 MCP 伺服器,確認 Docker MCP Gateway 已列出。
- 安裝 Claude Code: 執行
- 🎯 真實世界應用: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 整合顯著減少了調試結帳失敗、調查性能問題和進行安全程式碼審查等任務的時間,將長時間的上下文切換轉變為連續的工作流程。
💡 Audible 藉助 Amazon Q Developer 提升單元測試自動化
- 🎤 測試挑戰與 Amazon Q Developer 的解決方案: 在 Audible 等高速度開發環境中,測試往往因時間壓力而被壓縮,導致品質風險。Amazon Q Developer 透過其代理工作流(agentic workflows)加速測試過程,透過自動化測試生成、邊緣案例識別和修復建議,使團隊能夠在更短的時間內執行全面測試,從而加速發布、優化 QA 資源並增強生產就緒性。它特別針對那些缺乏測試覆蓋率的繼承程式碼庫提供了高效的解決方案。
- 🧠 Amazon Q Developer 的核心能力:
- 智能測試生成: 不同於傳統工具,Amazon Q Developer 透過分析程式碼意圖、業務邏輯和邊緣案例,生成有意義且能全面驗證程式碼行為的測試套件。
- 靈活的測試輔助: 除了專用的測試生成工作流,它還支援透過對話提示生成測試計劃、改進現有測試或在撰寫測試時進行結對程式設計。
- 架構優勢: 結合 AI 能力與人類專業知識,Amazon Q Developer 能夠分析程式碼庫、識別邊緣案例並執行自動化轉換,同時允許開發人員應用其領域知識確保輸出符合業務需求。

- 🔄 Audible 的實踐方法:
- 程式碼提交: Audible 團隊利用 Amazon Q Developer 為 Java 類別(包括靜態方法和已有測試案例的方法)生成額外單元測試,自動識別邊緣案例(如空值輸入、空字串檢查)。
- 目標性請求: 團隊明確要求 Amazon Q Developer 提供針對特定方法的單元測試建議、未測試邊緣案例的建議以及錯誤處理和異常情境的測試建議。
- 開發人員工作流: 遵循「人類在環」的方法,開發人員在 IDE 中打開類別檔案,選定方法並添加提示,提交給 Amazon Q Developer,接收生成的測試,最後進行審查和整合。

- 📝 有效提示範例:
- 基本測試生成:
Generate unit tests for the following Java method. Focus on covering all possible input scenarios and edge cases:
[method code here]
Please include tests for:
- Valid input scenarios
- Null input checks
- Empty string validations
- Exception handling - 邊緣案例專注:
I have this method that processes user input. Can you suggest unit tests that cover edge cases I might have missed? Pay special attention to boundary conditions and error scenarios:
[method code here] - 手動框架遷移 (透過 Q Developer Chat):
Convert this JUnit 4 test to JUnit 5 format. Make sure to update annotations and use modern JUnit 5 features where appropriate:
[JUnit 4 test code here]
- 基本測試生成:
- 📈 量化成果: 藉助 Amazon Q Developer,Audible 團隊實現了:
- 超過 10 個關鍵套件獲得全面單元測試覆蓋。
- 每個測試類別節省約 1 小時時間。
- 成功遷移 5,000 多個測試案例從 JUnit 4 到 JUnit 5。
- 在 JDK 8 到 JDK 17 遷移中節省 50 多小時手動工作。
- 透過 AI 輔助轉換減少人為錯誤。
- 🌟 展現的關鍵能力: 包括全面的異常測試(涵蓋
IllegalArgumentException,NullPointerException等)、自動化邊緣案例檢測(無需提示的空指針異常處理建議)、透過 AI 輔助的手動框架遷移(將 JUnit 4 轉換為 JUnit 5 的ParameterizedTest)和上下文分析(匹配團隊編碼風格)。 - 總結: Amazon Q Developer 將測試生成過程從耗時的雜務轉變為精簡的工作流,使開發人員能專注於高價值活動,同時提高程式碼品質和可靠性。