從問 AI 到用 Agent · 架構補充

一台 MCP Server 長怎樣

MCP 是「Agent 對外或對內操作的能力」。架一台 MCP Server,就是把你自己的能力或系統,包成任何支援 MCP 的 Agent 都能用標準方式呼叫的一端。這頁用一張分層結構圖,把它拆開給你看。

🧩 三層結構:誰呼叫、誰宣告、誰執行

資料 / 能力宣告 處理 / 執行 Agent(使用方) 你的系統(被接的)
flowchart LR
  subgraph AGENT["🤖 Agent 端 · 使用方(client)"]
    A(["Agent
要做事的那顆腦"]):::result end subgraph SERVER["🔌 MCP Server · 你架的那一台"] direction TB D["能力宣告
tools 動作 · resources 資料 · prompts 提示"]:::data X["執行核心
收到呼叫 → 執行 → 回結果"]:::proc end subgraph SYS["🏢 你的能力 / 系統 · 被接的一端"] direction TB S1[("資料庫")]:::infra S2["內部 API / 服務"]:::infra S3[("檔案 / 文件")]:::infra end A -->|① 你有哪些工具?| D D -->|② 回傳能力清單| A A -->|③ 帶參數呼叫某個工具| X X -->|④ 實際去操作| S1 X -->|④| S2 X -->|④| S3 X -->|⑤ 把結果回給 Agent| A classDef data fill:#fef3c7,stroke:#d97706,stroke-width:2px,color:#78350f classDef proc fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#17335e classDef result fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d classDef infra fill:#e5e9f0,stroke:#475569,stroke-width:2px,color:#1e293b style AGENT fill:#f0fdf4,stroke:#86efac,color:#166534 style SERVER fill:#eff6ff,stroke:#93c5fd,color:#1e40af style SYS fill:#f8fafc,stroke:#cbd5e1,color:#475569

重點:Agent 不用知道你系統的內部細節,它只認得那份「能力清單」。你把什麼放進清單、給多少權限,就決定了它能碰什麼。

🗺️ 架設四步驟

flowchart LR
  P1["① 決定
開放哪些能力"]:::proc --> P2["② 定義
每個能力=一個工具
(名稱·輸入·輸出)"]:::proc P2 --> P3["③ 跑起來
成一台 server"]:::proc P3 --> P4(["④ Agent 端設定
連上這台 server"]):::result classDef proc fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#17335e classDef result fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d

🔑 為什麼值得自己架

1一次架、到處接標準接頭
把你或公司的獨門能力,變成任何支援 MCP 的 Agent 都能用的標準能力,不用為每個 Agent 各寫一套膠水。
2對內、對外都行同一套做法
同樣的做法,可以接公司內部系統(對內),也可以接外部服務(對外);差別只在你開放給誰、放在哪。
3開放=開權限先想邊界
架 server 就是對外開放能力,所以架的時候就要想「這台開放什麼、給多少權限」,別把不該給的也開出去。

📺 對應單集:MCP 入門 · 架一台 MCP Server  |  📚 回課綱總表 →