/ 目錄 / 演練場 / fast-agent
● 社群 evalstate ⚡ 即開即用

fast-agent

作者 evalstate · evalstate/fast-agent

@fast.agent() 裝飾器以 Python 撰寫 MCP 原生 agent——Skills、MCP、ACP、多模型、評估和追蹤全部內建。

fast-agent 是一個認真對待 MCP 和 Skills 的主觀式 agent 框架。裝飾一個函式,附加伺服器和 skills,選擇模型,你就有了一個可執行的 agent,附帶追蹤、評估和可恢復執行的功能。既可作為獨立框架使用,也可作為 MCP 伺服器從 Claude 驅動。

為什麼要用

核心特性

即時演示

實際使用效果

fast-agent-mcp.replay ▶ 就緒
0/0

安裝

選擇你的客戶端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "fast-agent-mcp": {
      "command": "uvx",
      "args": [
        "fast-agent-mcp"
      ]
    }
  }
}

開啟 Claude Desktop → Settings → Developer → Edit Config。儲存後重啟應用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "fast-agent-mcp": {
      "command": "uvx",
      "args": [
        "fast-agent-mcp"
      ]
    }
  }
}

Cursor 使用與 Claude Desktop 相同的 mcpServers 格式。專案級設定優先於全域。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "fast-agent-mcp": {
      "command": "uvx",
      "args": [
        "fast-agent-mcp"
      ]
    }
  }
}

點擊 Cline 側欄中的 MCP Servers 圖示,然後選 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "fast-agent-mcp": {
      "command": "uvx",
      "args": [
        "fast-agent-mcp"
      ]
    }
  }
}

格式與 Claude Desktop 相同。重啟 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "fast-agent-mcp",
      "command": "uvx",
      "args": [
        "fast-agent-mcp"
      ]
    }
  ]
}

Continue 使用伺服器物件陣列,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "fast-agent-mcp": {
      "command": {
        "path": "uvx",
        "args": [
          "fast-agent-mcp"
        ]
      }
    }
  }
}

加入 context_servers。Zed 儲存後熱重載。

claude mcp add fast-agent-mcp -- uvx fast-agent-mcp

一行命令搞定。用 claude mcp list 驗證,claude mcp remove 移除。

使用場景

實戰用法: fast-agent

用 30 行 Python 建立深度研究 agent

👤 想要可重現研究 agent 的開發者 ⏱ ~60 min intermediate

何時使用: 你在聊天中反覆使用「研究 X」的流程,想將它包裝成可呼叫的 agent。

前置條件
  • Python 3.11+ 和 uv — 若缺少 uv 請先安裝;fast-agent 使用 uv
  • fast-agent 已安裝 — uvx fast-agent-mcp init;切換至專案目錄
步驟
  1. 建立骨架
    Use fast-agent. Generate a research agent skeleton with tavily search + fetch + summarize tools.✓ 已複製
    → agent.py 含 @fast.agent 裝飾器
  2. 串接 MCP
    Attach the tavily-mcp and filesystem MCP servers in fastagent.config.yaml.✓ 已複製
    → 設定已驗證;伺服器連線成功
  3. 執行並迭代
    Run with: research 'state of small embedding models 2026'. Inspect the trace.✓ 已複製
    → 追蹤顯示搜尋 → 擷取 → 摘要鏈;輸出為附有來源的簡報
  4. 加入評估
    Author a 5-prompt eval; run nightly. Fail if any source citation is missing.✓ 已複製
    → 評估輸出通過/失敗;夜間 cron 已設定

結果: 可交付給隊友的可重現研究管線。

注意事項
  • 裝飾器魔法遮蔽了 agent 的實際行為 — 務必閱讀追蹤記錄;在宣告 agent 正常運作前理解每個工具呼叫
搭配使用: tavily-mcp · filesystem

將你的 fast-agent 作為 MCP 伺服器暴露出來

👤 跨團隊共享 agent 的開發者 ⏱ ~25 min intermediate

何時使用: 你用 fast-agent 建立了一個內部 agent,希望其他人能從 Claude 呼叫它。

步驟
  1. 標記 agent 為暴露狀態
    Add @fast.agent(expose=True) to the decorator; specify name and description for tool discovery.✓ 已複製
    → Agent 現在也以 MCP 工具的形式顯示
  2. 作為 MCP 伺服器執行
    Run: fast-agent serve --transport stdio.✓ 已複製
    → Stdio MCP 伺服器執行中,你的 agent 列為工具
  3. 加入用戶端
    Add the fast-agent stdio config to my Claude Desktop config.✓ 已複製
    → 工具在 Claude 中可見;呼叫它會觸發你的 agent

結果: 你的自訂 agent 可像任何其他 MCP 一樣在團隊中重複使用。

注意事項
  • Agent 依賴只有作者才有的本機檔案 — 將設定和資源移入 agent 的套件;記錄所有必要的環境變數

用評估執行器比較兩個 prompt 版本

👤 任何正在為正式環境調整 prompt 的人 ⏱ ~45 min intermediate

何時使用: 你在考慮兩種 prompt 措辭,想用資料做選擇。

步驟
  1. 撰寫評估
    Define an eval with 12 representative inputs and golden outputs.✓ 已複製
    → evals/<name>.yaml
  2. 執行兩次
    Run eval against prompt v1, then v2. Compare pass rates + token usage.✓ 已複製
    → 含差異的比較表格
  3. 選定並鎖定
    Save the winning prompt to prompts/winning.md; tag the eval as the regression baseline.✓ 已複製
    → 已鎖定基準線;未來的 PR 以此為標準執行

結果: 以資料驅動的 prompt 選擇,加上迴歸保護網。

注意事項
  • 12 個輸入全是正常路徑 — 加入對抗性案例——空輸入、格式錯誤的輸入、矛盾的事實

組合

與其他 MCP 搭配,撬動十倍槓桿

fast-agent-mcp + tavily-mcp + filesystem

撰寫附有網路和檔案系統 MCP 的研究 agent

Build a research agent that uses tavily for search, filesystem for note persistence.✓ 已複製
fast-agent-mcp + mcpjam-inspector

發布前用 MCPJam 介面 inspect 你的 fast-agent 伺服器

Run fast-agent as MCP server; connect via mcpjam-inspector to verify tool schemas.✓ 已複製

工具

此 MCP 暴露的能力

工具輸入參數何時呼叫成本
agent.run messages, agent_name? 端對端驅動 agent 模型 + 工具呼叫費用
agent.list 探索已暴露的 agent 0
eval.run eval_name, prompt_version? 提交前/夜間迴歸 每個 prompt 的模型 API 費用
trace.get run_id 偵錯特定執行記錄 0

成本與限制

運行它的成本

API 配額
視你選擇的模型供應商配額而定
每次呼叫 Token 數
高度可變——取決於 agent 設計
費用
框架免費;向模型供應商付費
提示
開發時使用 --model haiku-4.5;正式執行和評估時切換至 sonnet

安全

權限、密鑰、影響範圍

最小權限: 視附加的 MCP 所需而定
憑證儲存: fastagent.secrets.yaml(已加入 .gitignore)或環境變數
資料出站: 連至附加的 MCP 伺服器和選定的模型供應商
切勿授予: 在開發環境使用正式環境的寫入 token

故障排查

常見錯誤與修復

Agent 陷入迴圈無法收斂

設定 max_steps;查看追蹤找出迴圈。通常是工具回傳了模糊的輸出,導致模型無限重試

驗證: trace.get(run_id)
評估回報 0%,但手動執行正常

確認 golden_output 格式——嚴格相等 vs 語意匹配

設定中的 MCP 伺服器無法附加

先單獨執行伺服器指令;確認環境變數在 fastagent.secrets.yaml 中存在

首次執行緩慢

uv 在第一次呼叫時拉取依賴項;後續會快取。在 CI 中預先暖機

替代方案

fast-agent 對比其他方案

替代方案何時用它替代權衡
PrefectHQ/fastmcp你需要的是官方 MCP 伺服器框架,而非完整的 agent 框架fastmcp 是用來建構伺服器的;fast-agent 是用來建構(和協調)消費它們的 agent
LangGraph你的團隊已深度投資 LangChain 生態系更通用;MCP 原生程度較低
mcp-agent(lastmile-ai)你偏好更精簡的教學級框架範圍較小;附帶功能較少

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

🔍 瀏覽全部 400+ MCP 伺服器和 Skills