Repository: https://github.com/strands-agents/mcp-server Stars: 286 | Forks: 72 | Language: Python License: Apache-2.0 | Last Updated: 2026-06-14 PyPI:
strands-agents-mcp-server| Python: 3.10+ Tags: MCP, Documentation, GenAI, Agentic AI, Agents, Bedrock, LiteLLM, Ollama, OpenAI
1. 專案概覽 (Project Overview)
1.1 這是什麼?
strands-agents/mcp-server 是一個 MCP Server (Model Context Protocol Server; 模型上下文協議伺服器),專門為 AI 程式碼助手 (AI coding assistant; AI 編碼助理) 提供 Strands Agents 框架的完整文件存取能力。
簡單來說:當你使用 Claude Code、Cursor、VS Code Copilot、Amazon Q Developer CLI 等 AI 編碼工具時,這個 MCP Server 讓 AI 能夠即時查閱 Strands Agents 的官方文件,使 AI 在幫你寫 agent 程式碼時能參考最新、最正確的文件內容,而不是依賴可能過時的訓練資料。
1.2 誰開發的?
本專案由 AWS (Amazon Web Services) 的 Strands Agents 團隊開發,是 Strands Agents 生態系統中 12 個開源專案之一。Strands Agents 是 AWS 推出的開源 AI Agent 框架,定位是「用幾行程式碼就能建立 AI Agent」的 model-driven (模型驅動) 方法。
1.3 為什麼重要?
在 AI agent 開發的實務中,最大的瓶頸之一是 context gap (上下文落差)——AI 助手不知道你正在使用的框架最新 API 長什麼樣子。這個 MCP Server 解決了這個問題:
- 即時文件存取:不依賴訓練資料,直接從
strandsagents.com取得最新文件 - 智慧搜尋:基於 TF-IDF (Term Frequency-Inverse Document Frequency; 詞頻-逆文件頻率) 的 Markdown-aware (Markdown 感知) 搜尋引擎
- Token 效率最佳化:透過 section-based browsing (分段瀏覽) 避免一次載入整份文件,節省寶貴的 context window (上下文視窗) 空間
- Vibe Coding 賦能:讓開發者能用自然語言描述需求,AI 助手參考正確文件來生成 Strands Agents 程式碼
1.4 在生態系中的定位
在 Strands Agents 的 12 個 repo 組成的完整平台中,mcp-server 扮演的是 「開發者體驗入口」 的角色——它不直接參與 agent 的執行,而是讓 AI 工具在開發階段就能理解整個框架。
2. 核心架構 (Core Architecture)
2.1 系統總覽
graph TB
subgraph "AI 編碼工具"
CC[Claude Code]
CU[Cursor]
VS[VS Code Copilot]
QD[Amazon Q Developer CLI]
KI[Kiro]
end
subgraph "MCP Server
strands-agents-mcp-server"
FMP[FastMCP Server
server.py]
subgraph "Tools Layer"
ST[search_docs
智慧文件搜尋]
FT[fetch_doc
分段文件讀取]
end
subgraph "Utils Layer"
CA[cache.py
懶載入快取]
IX[indexer.py
TF-IDF 反向索引]
TP[text_processor.py
Markdown 解析]
DF[doc_fetcher.py
HTTP 抓取 + 清理]
end
CO[config.py
llms.txt URL 設定]
end
subgraph "外部資料來源"
LT["strandsagents.com/llms.txt
策展文件清單"]
DOC["strandsagents.com/**
完整文件頁面"]
end
CC & CU & VS & QD & KI -->|MCP Protocol
stdio| FMP
FMP --> ST & FT
ST --> CA
FT --> CA
CA --> IX
CA --> DF
IX --> TP
DF -->|HTTP GET
on-demand| DOC
CO -->|初始化時讀取| LT
CA -->|parse_llms_txt| LT
style FMP fill:#4B8BBE,color:#fff
style ST fill:#306998,color:#fff
style FT fill:#306998,color:#fff
style LT fill:#FFD43B,color:#000
style DOC fill:#FFD43B,color:#000
2.2 資料流程
這個 MCP Server 的核心設計理念是 lazy loading (懶載入)——啟動時只載入文件標題和 URL 列表(從 llms.txt),完整內容只在被查詢時才抓取,確保啟動速度快、記憶體用量低。
sequenceDiagram
participant AI as AI 編碼工具
participant MCP as MCP Server
participant Cache as Cache Layer
participant Index as TF-IDF Index
participant Fetcher as Doc Fetcher
participant Web as strandsagents.com
Note over MCP,Web: === 階段一:初始化 (僅標題) ===
MCP->>Web: GET /llms.txt
Web-->>MCP: Markdown 連結清單
MCP->>Cache: parse_llms_txt → (title, url) pairs
Cache->>Index: add(Doc) — 僅 title,content=""
Note over AI,Web: === 階段二:搜尋 (search_docs) ===
AI->>MCP: search_docs("bedrock model", k=5)
MCP->>Cache: ensure_ready()
MCP->>Index: search("bedrock model", k=5)
Index-->>MCP: ranked results (score, Doc)
loop Top 5 結果 (hydration)
MCP->>Cache: ensure_page(url)
alt 快取未命中
Cache->>Fetcher: fetch_and_clean(url)
Fetcher->>Web: HTTP GET 文件頁面
Web-->>Fetcher: HTML / Markdown
Fetcher-->>Cache: Page(url, title, content)
end
end
MCP->>MCP: make_snippet() 為每筆結果產生摘要
MCP-->>AI: [{url, title, score, snippet}, ...]
Note over AI,Web: === 階段三:讀取 (fetch_doc) ===
AI->>MCP: fetch_doc(uri="https://...", section="")
MCP->>Cache: ensure_page(uri)
MCP->>MCP: parse_sections() → TOC 樹
MCP-->>AI: {url, title, preamble, sections[]}
AI->>MCP: fetch_doc(uri="https://...", section="3")
MCP->>MCP: extract_section("3")
MCP-->>AI: {url, title, section_id, section_title, content}
2.3 模組職責
| 模組 | 檔案 | 職責 |
|---|---|---|
| Server | server.py | FastMCP 應用入口;定義 search_docs 和 fetch_doc 兩個 MCP tool |
| Config | config.py | 全域設定:llms.txt URL、HTTP timeout、User-Agent |
| Cache | utils/cache.py | 全域狀態管理:反向索引實例、URL→Page 快取、URL→Title 對應 |
| Indexer | utils/indexer.py | 輕量 TF-IDF 搜尋引擎,含 Markdown 結構感知加權 |
| Text Processor | utils/text_processor.py | Markdown 解析:section tree、preamble 提取、snippet 生成 |
| Doc Fetcher | utils/doc_fetcher.py | HTTP 抓取 + HTML→純文字轉換 + llms.txt 解析 |
3. 安裝與設定 (Installation & Setup)
3.1 前置需求
- Python 3.10+
- uv (Astral 的 Python 套件管理工具):
1# macOS / Linux 2curl -LsSf https://astral.sh/uv/install.sh | sh 3 4# Windows 5powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" - Node.js (僅測試用,供 MCP Inspector)
3.2 各 MCP Client 設定
Claude Code
最簡方式——一行指令:
1claude mcp add strands uvx strands-agents-mcp-server
這會自動在 Claude Code 的 MCP 設定中註冊 strands 伺服器。
Cursor
編輯 ~/.cursor/mcp.json:
1{
2 "mcpServers": {
3 "strands-agents": {
4 "command": "uvx",
5 "args": ["strands-agents-mcp-server"],
6 "env": {
7 "FASTMCP_LOG_LEVEL": "INFO"
8 },
9 "disabled": false,
10 "autoApprove": ["search_docs", "fetch_doc"]
11 }
12 }
13}
關鍵設定說明:
"command": "uvx"— 使用uvx臨時執行套件,不需預先安裝"autoApprove"— 自動核准search_docs和fetch_doc,因為它們是唯讀操作,不會修改任何東西"FASTMCP_LOG_LEVEL": "INFO"— 設定日誌等級,除錯時可改為"DEBUG"
VS Code
編輯你的 MCP 設定 mcp.json:
1{
2 "servers": {
3 "strands-agents": {
4 "command": "uvx",
5 "args": ["strands-agents-mcp-server"]
6 }
7 }
8}
Amazon Q Developer CLI
編輯 ~/.aws/amazonq/mcp.json:
1{
2 "mcpServers": {
3 "strands-agents": {
4 "command": "uvx",
5 "args": ["strands-agents-mcp-server"],
6 "env": {
7 "FASTMCP_LOG_LEVEL": "INFO"
8 },
9 "disabled": false,
10 "autoApprove": ["search_docs", "fetch_doc"]
11 }
12 }
13}
Kiro
編輯 ~/.kiro/settings/mcp.json:
1{
2 "mcpServers": {
3 "strands-agents": {
4 "command": "uvx",
5 "args": ["strands-agents-mcp-server"],
6 "env": {
7 "FASTMCP_LOG_LEVEL": "INFO"
8 },
9 "disabled": false,
10 "autoApprove": ["search_docs", "fetch_doc"]
11 }
12 }
13}
3.3 快速測試連線
使用 MCP Inspector 驗證伺服器是否正常運作:
1# 用已發佈的 PyPI 套件測試
2npx @modelcontextprotocol/inspector uvx strands-agents-mcp-server
3
4# 用本地開發版本測試
5npx @modelcontextprotocol/inspector python -m strands_mcp_server
MCP Inspector 會開啟一個 Web UI,讓你可以:
- 查看伺服器暴露的 tool 列表
- 手動呼叫
search_docs和fetch_doc - 檢查協議通訊細節
3.4 本地開發環境設定
如果要貢獻程式碼或修改伺服器:
1# 1. Clone repo
2git clone https://github.com/strands-agents/mcp-server.git
3cd mcp-server/strands-mcp
4
5# 2. 建立虛擬環境並安裝(含開發依賴)
6python3 -m venv venv
7source venv/bin/activate
8pip3 install -e ".[dev]"
9
10# 3. 用 Inspector 測試
11npx @modelcontextprotocol/inspector python -m strands_mcp_server
12
13# 4. 執行測試
14pytest tests/ # 單元測試(不需網路)
15pytest tests_integ/ -v # 整合測試(需網路)
16pytest tests/ tests_integ/ -v # 全部測試
4. 使用方式與程式碼範例 (Usage & Code Examples)
4.1 Tool 一覽
這個 MCP Server 只暴露 兩個 tool (工具),設計極其精簡:
| Tool | 功能 | 參數 |
|---|---|---|
search_docs | 智慧文件搜尋,回傳排名結果與摘要 | query (str), k (int, 預設 5) |
fetch_doc | 讀取文件頁面,支援 TOC 模式與 section 模式 | uri (str), section (str) |
4.2 範例一:搜尋文件 (search_docs)
1# 當 AI 助手收到使用者問題:「如何在 Strands Agents 中使用 Bedrock 模型?」
2# AI 會呼叫 search_docs tool:
3
4result = search_docs(query="bedrock model provider", k=5)
5
6# 回傳結果結構(範例):
7# [
8# {
9# "url": "https://strandsagents.com/.../bedrock/",
10# "title": "Amazon Bedrock", # 策展標題(來自 llms.txt)
11# "score": 0.847, # 相關性分數(0-1,越高越相關)
12# "snippet": "Amazon Bedrock provides # 內容預覽(最多 300 字元)
13# access to foundation..."
14# },
15# {
16# "url": "https://strandsagents.com/.../model-providers/",
17# "title": "Model Providers",
18# "score": 0.623,
19# "snippet": "Strands Agents supports multiple model providers..."
20# },
21# ...
22# ]
搜尋引擎的加權機制:
1# indexer.py 中的評分權重(由高到低):
2
3# 1. 標題匹配 — 權重最高
4# - 未載入內容的文件:8 倍加權(補償 content 為空的情況)
5# - 短頁面(<800 字元):5 倍加權
6# - 長頁面:3 倍加權
7title_tf = title_lower.count(token) * _title_boost_for(doc)
8
9# 2. 標題匹配 (Header) — 4 倍加權
10# Markdown 的 # ~ ###### 標題行
11header_tf += header.lower().count(token) * 4
12
13# 3. 程式碼區塊 — 2 倍加權
14# ``` 包圍的程式碼和 ` 包圍的行內程式碼
15code_tf += code.lower().count(token) * 2
16
17# 4. 連結文字 — 2 倍加權
18# [連結文字](url) 中的連結文字部分
19link_tf += link.lower().count(token) * 2
20
21# 5. 一般文字 — 1 倍(基本權重)
22content_tf = content_lower.count(token)
4.3 範例二:分段瀏覽文件 (fetch_doc — TOC 模式)
1# 步驟一:先用 search_docs 找到相關 URL
2# 步驟二:取得文件的目錄結構(不傳 section 參數)
3
4result = fetch_doc(uri="https://strandsagents.com/latest/user-guide/concepts/agents/agent-loop/")
5
6# 回傳結構(TOC 模式):
7# {
8# "url": "https://strandsagents.com/.../agent-loop/",
9# "title": "Agent Loop",
10# "preamble": "The agent loop is the core execution cycle...", # 前言文字
11# "sections": [
12# {
13# "id": "1",
14# "level": 2,
15# "title": "How It Works",
16# "summary": "The agent loop processes user messages through...",
17# "children": [
18# {"id": "1.1", "title": "Message Processing"},
19# {"id": "1.2", "title": "Tool Execution"}
20# ]
21# },
22# {
23# "id": "2",
24# "level": 2,
25# "title": "Configuration",
26# "summary": "You can configure the agent loop behavior...",
27# "children": []
28# }
29# ]
30# }
Token 效率的關鍵設計: 這個 TOC 模式只回傳標題、摘要和章節 ID,不回傳完整內容。AI 助手可以先看結構,再決定讀哪一段,避免浪費 token 讀取不相關的段落。
4.4 範例三:讀取特定段落 (fetch_doc — Section 模式)
1# 步驟三:根據 TOC 的 section ID 讀取特定段落
2
3result = fetch_doc(
4 uri="https://strandsagents.com/latest/user-guide/concepts/agents/agent-loop/",
5 section="1.2" # 讀取 "Tool Execution" 子段落
6)
7
8# 回傳結構(Section 模式):
9# {
10# "url": "https://strandsagents.com/.../agent-loop/",
11# "title": "Agent Loop",
12# "section_id": "1.2",
13# "section_title": "Tool Execution",
14# "content": "### Tool Execution\n\nWhen the model decides to use a tool..."
15# }
4.5 範例四:文件目錄列表 (fetch_doc — 空 URI)
1# 不傳 URI 時,回傳所有可用文件的完整清單
2
3result = fetch_doc() # uri="" (預設)
4
5# 回傳結構:
6# {
7# "urls": [
8# {"url": "https://strandsagents.com/.../quickstart/", "title": "Quickstart"},
9# {"url": "https://strandsagents.com/.../agent-loop/", "title": "Agent Loop"},
10# {"url": "https://strandsagents.com/.../bedrock/", "title": "Amazon Bedrock"},
11# ... (所有策展文件)
12# ]
13# }
4.6 範例五:小型文件的自動行為
1# 對於小於 8KB 的文件,伺服器自動回傳完整內容,跳過分段機制
2
3result = fetch_doc(uri="https://strandsagents.com/latest/some-short-page/")
4
5# 回傳結構(小型文件模式):
6# {
7# "url": "https://strandsagents.com/.../some-short-page/",
8# "title": "Quick Config",
9# "document_small": true, # 標記為小型文件
10# "reason": "size", # 或 "no_sections"(無可解析段落)
11# "content": "# Quick Config\n\nSet the following..." # 完整內容
12# }
這個設計很聰明——對於本來就很短的文件,分段反而增加來回次數的開銷。SMALL_DOC_THRESHOLD = 8192 bytes 是分界線。
5. 進階功能 (Advanced Features)
5.1 llms.txt 標準支援
本伺服器的資料來源不是爬取整個網站,而是讀取 llms.txt 檔案——這是一個新興標準,讓網站主動宣告「這些頁面適合 LLM 閱讀」。
1# config.py 中的預設設定:
2llm_texts_url: list[str] = field(
3 default_factory=lambda: ["https://strandsagents.com/llms.txt"]
4)
llms.txt 的格式是 Markdown 連結清單:
1# Strands Agents Documentation
2
3## User Guide
4- [Quickstart](https://strandsagents.com/latest/quickstart/)
5- [Agent Loop](https://strandsagents.com/latest/user-guide/concepts/agents/agent-loop/)
6...
伺服器啟動時解析這個檔案,取得所有文件的 (title, url) 對應,建立初始索引。
5.2 TF-IDF 搜尋引擎的 Markdown 感知
與一般的 TF-IDF 實作不同,這個搜尋引擎針對技術文件做了特殊最佳化:
1# indexer.py 的五層加權 haystack:
2haystack_parts = [
3 title_text, # 標題(含變體詞)— 最高權重
4 headers.lower(), # ## 和 ### 標題行 — 高權重
5 link_text.lower(), # [文字](url) 中的文字 — 中等權重
6 code_blocks.lower(), # ``` 程式碼區塊 — 中等權重
7 inline_code.lower(), # `行內程式碼` — 中等權重
8 content, # 一般文字 — 基本權重
9]
5.3 標題變體索引 (Title Variant Indexing)
搜尋引擎會自動產生標題的變體詞,提升搜尋的 recall (召回率):
1# text_processor.py — index_title_variants()
2def index_title_variants(display_title: str, url: str) -> str:
3 # 原始標題
4 base = display_title # "Agent2Agent"
5
6 # 數字轉文字變體
7 variant = re.sub(r"(?i)(\w)2(\w)",
8 r"\1 to \2", base) # "Agent to Agent"
9
10 # URL slug 變體
11 slug = title_from_url(url) # "Agent2agent" (from URL path)
12
13 # 合併為搜尋用字串(去重)
14 return "Agent2Agent Agent to Agent Agent2agent"
這意味著搜尋 “agent to agent”、“a2a”、“agent2agent” 都能找到同一份文件。
5.4 智慧 Snippet 產生
摘要產生邏輯會跳過程式碼區塊、標題行、項目清單,找出第一段有意義的散文段落:
1# text_processor.py — make_snippet()
2def make_snippet(page, display_title, max_chars=300):
3 # 1. 移除 ``` 程式碼區塊
4 text = _CODE_FENCE.sub("", text)
5
6 # 2. 跳過標題行(# 開頭)
7 # 3. 跳過與 display_title 重複的第一行
8 # 4. 跳過項目清單(- * 1. 開頭)
9
10 # 5. 收集第一段有意義的散文
11 # 至少 120 字元或以句號結尾才算完整
12 if len(" ".join(buf)) >= 120 or line.endswith("."):
13 paras.append(" ".join(buf))
14 break
15
16 # 6. 截斷至 300 字元,加省略號
17 return _truncate(snippet, max_chars)
5.5 URL 安全驗證
fetch_doc 有嚴格的 URL 驗證,只允許存取 strandsagents.com 的 HTTPS 頁面:
1# server.py
2def _is_valid_doc_url(uri: str) -> bool:
3 parsed = urlparse(uri)
4 return parsed.scheme == "https" and parsed.hostname == "strandsagents.com"
這防止了 SSRF (Server-Side Request Forgery; 伺服器端請求偽造) 攻擊——惡意使用者無法透過 fetch_doc 讀取內部網路或其他網站的內容。
5.6 零外部依賴的 HTML 清理
文件抓取模組完全使用 Python 標準庫 (urllib, html, re) 處理 HTML→純文字轉換,不依賴 BeautifulSoup 或其他第三方套件:
1# doc_fetcher.py
2def _html_to_text(raw_html: str) -> str:
3 stripped = _HTML_BLOCK.sub("", raw_html) # 移除 <script>/<style>
4 stripped = _TAG.sub(" ", stripped) # 移除所有 HTML tag
5 stripped = html.unescape(stripped) # 反轉 HTML entities
6 lines = [ln.strip() for ln in stripped.splitlines()]
7 return "\n".join(ln for ln in lines if ln)
6. Agent 可呼叫性分析 (Agent Callability)
6.1 呼叫介面
| 介面 | 支援 | 說明 |
|---|---|---|
| MCP (stdio) | 完整支援 | 主要設計介面;透過 uvx strands-agents-mcp-server 啟動 |
| CLI | 間接支援 | python -m strands_mcp_server 啟動,但只支援 stdio 協議 |
| REST API | 不支援 | 無 HTTP 端點;若需要可用 FastMCP 的 SSE transport |
| Python SDK | 不支援 | 無公開的 Python API;僅作為 MCP Server 使用 |
6.2 MCP Tool Schema
1{
2 "tools": [
3 {
4 "name": "search_docs",
5 "description": "Search curated documentation and return ranked results with snippets.",
6 "inputSchema": {
7 "type": "object",
8 "properties": {
9 "query": {"type": "string", "description": "Search query string"},
10 "k": {"type": "integer", "default": 5, "description": "Max results to return"}
11 },
12 "required": ["query"]
13 }
14 },
15 {
16 "name": "fetch_doc",
17 "description": "Read documentation pages with smart sectioning for token efficiency.",
18 "inputSchema": {
19 "type": "object",
20 "properties": {
21 "uri": {"type": "string", "default": "", "description": "Document URL"},
22 "section": {"type": "string", "default": "", "description": "Section ID from TOC"}
23 }
24 }
25 }
26 ]
27}
6.3 最佳呼叫模式
推薦的三步驟工作流:
- 搜尋 →
search_docs("your question")— 取得 ranked URL 清單 - 瀏覽 →
fetch_doc(uri="...")— 取得該文件的 TOC + preamble - 精讀 →
fetch_doc(uri="...", section="2.1")— 讀取特定段落
這個模式比起直接讀完整頁面,通常可節省 50-70% 的 token 用量。
7. 與生態系的關係 (Ecosystem Relationships)
7.1 Strands Agents 生態系總覽
Strands Agents 由 12 個 repo 組成一個完整的 agent 開發平台:
| Repo | 功能 | 與 mcp-server 的關係 |
|---|---|---|
| sdk-python | Python SDK 核心 | mcp-server 提供其文件的即時查閱 |
| sdk-typescript | TypeScript SDK 核心 | 文件同樣透過 mcp-server 存取 |
| tools | 內建工具集 (file, shell, http 等) | mcp-server 索引其工具文件 |
| mcp-server | 本專案 — MCP 文件伺服器 | 生態系的開發者體驗入口 |
| agent-builder | 視覺化 Agent 建構工具 | 可結合 mcp-server 做 AI 輔助開發 |
| samples | 範例程式碼集合 | mcp-server 索引範例文件 |
| docs | 官方文件原始碼 | mcp-server 的實際資料來源 |
| a2a-python | Agent-to-Agent 協議 (Python) | 文件透過 mcp-server 存取 |
| a2a-typescript | Agent-to-Agent 協議 (TS) | 文件透過 mcp-server 存取 |
| swe-agent | 軟體工程 Agent | 可掛載 mcp-server 做 self-referential coding |
| eval | Agent 評估框架 | 文件透過 mcp-server 存取 |
| agentcore | Bedrock AgentCore 整合 | 部署文件透過 mcp-server 存取 |
7.2 關鍵整合路徑
1開發者的 AI 助手
2 │
3 ├── MCP Server (本專案)
4 │ └── 查閱文件 → 生成正確的 Strands Agents 程式碼
5 │
6 ├── sdk-python / sdk-typescript
7 │ └── 開發者實際寫 agent 用的 SDK
8 │
9 ├── tools
10 │ └── Agent 使用的內建工具(MCP Server 知道這些工具的文件在哪)
11 │
12 └── samples
13 └── 範例程式碼(MCP Server 索引這些範例)
7.3 與其他 MCP Server 的差異
本專案與其他常見的 MCP Server 有根本性的不同:
- Context7 MCP Server:泛用型,覆蓋眾多框架的文件 → 廣度優先
- Strands MCP Server:專注 Strands Agents 文件 → 深度優先,搜尋品質更高
- 自建 RAG MCP Server:需要向量資料庫和 embedding → 本專案只需 TF-IDF,零額外依賴
8. 優缺點分析 (Strengths & Limitations)
8.1 優點
| 項目 | 說明 |
|---|---|
| 極簡依賴 | 只依賴 mcp>=1.1.3 和 pydantic>=2.0.0,無向量資料庫、無 embedding 模型 |
| 零設定即用 | uvx strands-agents-mcp-server 一行指令啟動,不需 API key 或設定檔 |
| Token 效率 | Section-based browsing 設計,AI 助手只讀需要的段落 |
| 啟動速度快 | Lazy loading 架構——啟動時只載入標題清單,不預抓完整內容 |
| 安全性 | URL 白名單只允許 strandsagents.com,防止 SSRF |
| Markdown 感知搜尋 | TF-IDF 加權考慮標題、程式碼、連結等結構元素 |
| 廣泛 MCP Client 支援 | 支援 40+ 個 MCP 相容工具,含一鍵安裝按鈕 |
| PyPI 發佈 | 正式的 Python 套件,版本管理規範 |
8.2 限制
| 項目 | 說明 |
|---|---|
| 僅限 Strands Agents 文件 | 不能用來查其他框架的文件 |
| 僅限 strandsagents.com | URL 白名單是硬編碼的,無法自訂文件來源 |
| 無語意搜尋 | TF-IDF 是關鍵字匹配,不是語意理解;搜「如何讓 agent 記住對話」可能不如搜 “conversation management” |
| 無離線模式 | 每次啟動和查詢都需要網路連線 |
| 無快取持久化 | 每次重啟伺服器都要重新抓取文件內容 |
| 單一語言 | 文件僅提供英文,無多語言支援 |
| 無版本控制 | 無法指定文件版本(如 v1.0 vs v2.0) |
8.3 品味評分
1品味評分:🟢 好品味
2
3理由:
4- 設計極簡:只有 2 個 tool、6 個模組檔案、2 個依賴
5- 問題定義精準:不做通用文件伺服器,只做 Strands Agents 的文件伺服器
6- 效率導向:lazy loading + section-based browsing + 小文件自動全文回傳
7- 安全預設:URL 白名單 + 唯讀操作
8- 零配置:開箱即用,不需要使用者理解內部原理
9. 實戰應用場景 (Real-world Use Cases)
9.1 場景一:Vibe Coding 開發 Strands Agent
情境:你想用 Strands Agents 建立一個能搜尋學術論文的 AI Agent,但不熟悉框架 API。
流程:
- 在 Claude Code 或 Cursor 中安裝 MCP Server
- 用自然語言描述需求:「幫我用 Strands Agents 建一個 agent,能搜 PubMed、讀取 PDF、做摘要」
- AI 助手自動呼叫
search_docs("tools MCP integration")查詢如何整合外部工具 - AI 再呼叫
fetch_doc(uri="...", section="3")讀取工具設定細節 - 基於正確的文件內容,AI 產生能直接執行的程式碼
效益:
- 不需要自己翻文件
- AI 生成的程式碼基於最新文件,不是過時的訓練資料
- 減少 debug 時間,因為 API 用法一開始就是正確的
9.2 場景二:多模型提供者切換
情境:你的 Strands Agent 原本使用 Amazon Bedrock,現在需要改用 Ollama 做本地推論。
流程:
- 詢問 AI:「如何把 Strands Agent 從 Bedrock 切換到 Ollama?」
- AI 呼叫
search_docs("ollama model provider configuration") - 取得 Ollama 設定文件的 URL 後,呼叫
fetch_doc()瀏覽目錄 - 精讀設定段落,取得確切的參數名稱和格式
- AI 產生遷移程式碼和設定變更建議
效益:
- 精確的 API 差異比較(Bedrock vs Ollama 的參數不同)
- 不會寫出混用兩個 provider API 的錯誤程式碼
9.3 場景三:團隊培訓與知識傳遞
情境:你的團隊決定採用 Strands Agents,需要讓所有成員快速上手。
流程:
- 每位開發者的 AI 工具都安裝 Strands MCP Server
- 新成員可以直接問 AI:「Strands Agents 的 agent loop 是怎麼運作的?」
- AI 從文件中取得準確資訊,產生詳細的中文解說
- 開發者寫程式碼時,AI 隨時參考最新文件給予正確建議
效益:
- 降低學習曲線——不需要每個人都從頭讀完整份文件
- 確保團隊使用一致的 best practices (最佳實務)
- 文件更新時,MCP Server 自動同步,不需要人工通知
附錄 A:完整檔案結構
1strands-agents/mcp-server/
2├── .github/
3│ ├── CODEOWNERS
4│ ├── dependabot.yml
5│ └── workflows/
6│ ├── mcp-pr-and-push.yml # PR 和 push 時的 CI
7│ ├── mcp-pypi-publish-on-release.yml # Release 時自動發佈到 PyPI
8│ └── mcp-test-lint.yml # 測試和 lint
9└── strands-mcp/ # 主要套件目錄
10 ├── pyproject.toml # 套件設定 + 依賴
11 ├── CODE_OF_CONDUCT.md
12 ├── CONTRIBUTING.md
13 ├── LICENSE # Apache-2.0
14 ├── NOTICE
15 ├── README.md
16 ├── .pre-commit-config.yaml
17 ├── src/strands_mcp_server/
18 │ ├── __init__.py
19 │ ├── __main__.py # python -m 入口
20 │ ├── config.py # 全域設定(llms.txt URL、timeout)
21 │ ├── server.py # FastMCP 應用 + tool 定義
22 │ └── utils/
23 │ ├── __init__.py
24 │ ├── cache.py # 全域快取 + 懶載入管理
25 │ ├── doc_fetcher.py # HTTP 抓取 + HTML 清理
26 │ ├── indexer.py # TF-IDF 搜尋引擎
27 │ └── text_processor.py # Markdown 解析 + snippet 產生
28 ├── tests/
29 │ ├── conftest.py
30 │ ├── test_server.py
31 │ └── test_text_processor.py
32 └── tests_integ/
33 ├── __init__.py
34 ├── conftest.py
35 ├── test_fetch_doc.py
36 └── test_parse_pipeline.py
附錄 B:關鍵設定參數
| 參數 | 預設值 | 說明 |
|---|---|---|
llm_texts_url | ["https://strandsagents.com/llms.txt"] | 策展文件清單來源 |
timeout | 30.0 秒 | HTTP 請求逾時 |
user_agent | "strands-mcp-docs/1.0" | HTTP User-Agent 標頭 |
SMALL_DOC_THRESHOLD | 8192 bytes | 小型文件閾值(以下回傳全文) |
SNIPPET_HYDRATE_MAX | 5 | 搜尋結果中最多預載幾筆的完整內容 |
_PARAGRAPH_MIN_CHARS | 120 字元 | snippet 中一段最少字元數 |
FASTMCP_LOG_LEVEL | 環境變數 | 日誌等級(INFO / DEBUG / WARNING) |
最後更新:2026-06-18 資料來源:strands-agents/mcp-server @ GitHub (commit as of 2026-06-14) 教學作者:AI-Knowledge Template v1 — gh-tutorial-qd workflow
Comments