返回全部文章AI 與智能體

MCP、A2A 與 AI 代理程式如何彼此溝通

On this page

Two protocol layers

MCPagent to tools and data
A2Aagent to agent
Interoperabilityswap implementations, keep contracts
Standardsfewer bespoke integrations

Where each protocol sits

One standardises capability access, the other delegation.

Where each protocol sits — flow diagramWhere each protocol sits. Flow diagram with 5 steps. Shapes: pill = input, rounded rect = process, diamond = decision, double border = output, dashed = loop. Steps in order: Step 1, Agent (input), the orchestrator; Step 2, MCP → tool / data source (process), schemas + typed results; Step 3, A2A → peer agent (process), tasks + messages; Step 4, structured result (output), same shape either way; Step 5, shared trace (loop), one audit log. Then loops back to step 1: loop.Agentthe orchestratorMCP → tool / data sourceschemas + typed resultsA2A → peer agenttasks + messagesstructured resultsame shape either wayshared traceone audit log
  • input
  • process
  • output
  • loop

MCP vs. A2A

MCPA2A
Connectsagent ↔ toolsagent ↔ agents
Payloadtool schemas + resultstasks + messages
Concerncapability accessdelegation
AnalogyUSB-C for toolshandoff protocol

One request across MCP and A2A

Both protocols return typed results, so the caller sees one shape.

One request across MCP and A2A — sequence diagramOne request across MCP and A2A. Sequence diagram with 4 participants: user (actor), agent (system), MCP (external), peer agent (external). Time flows downward. Messages in order: user calls agent: goal + context (list[Message]); agent calls MCP: tool.run(args) (MCP request); MCP returns to agent: ToolResult (typed); agent calls peer agent: A2A task (delegation); peer agent returns to agent: task result (structured); agent returns to user: final answer.useragentMCPpeer agentgoal + contextlist[Message]tool.run(args)MCP requestToolResulttypedA2A taskdelegationtask resultstructuredfinal answer
MCP handles capability access; A2A handles delegation. The caller receives the same typed result shape either way.

早期的 AI 代理程式彼此孤立:各有寫死的工具,只能在自己的系統內運作。這種情況正在快速改變。新的開放協定陸續出現,讓代理程式能發現工具、連接資料,並與其他代理程式協作,不論是誰打造它們。有兩個名字不斷出現:MCP 與 A2A。以下說明它們是什麼,以及為什麼重要。

代理程式為什麼需要協定

沒有標準,每個連線都得手工打造。如果你想讓代理程式 A 使用工具 B,就得有人為這一對寫客製程式。擴大到數十個代理程式與數百種工具,就變得難以管理。

協定透過定義共同語言來解決這個問題。按照標準打造的工具,能與任何說這種語言的代理程式搭配。代理程式可以發現有哪些工具可用,而不必為每一個預先寫死。這和讓全球資訊網運作的想法一樣:共同的協定讓差異極大的系統得以互通。

MCP:把代理程式連接到工具與資料

MCP(Model Context Protocol,模型脈絡協定)標準化了應用程式提供脈絡與工具給 AI 模型的方式。可以把它想成萬用連接器。

開發者不必為每個資料來源寫客製整合,而是透過 MCP 開放某項能力——檔案系統、資料庫、搜尋服務、商業 API。任何相容 MCP 的代理程式接著就能發現並使用它。

在實務上帶來的好處:

  • 代理程式可以詢問所連接的系統提供哪些能力。
  • 它可以一致、有結構地呼叫這些能力。
  • 開發者寫一次整合,就能在多個代理程式平台上使用。

有用的心智模型是「AI 工具的 USB-C」:一個標準插頭,取代塞滿專有線材的抽屜。

A2A:代理程式對代理程式

A2A(Agent2Agent protocol,代理程式對代理程式協定)處理的是不同的問題:獨立的代理程式如何彼此協調。當一個代理程式需要另一個代理程式幫忙——可能是不同供應商的專業代理程式——A2A 定義了它們如何:

  • 發現彼此的能力。
  • 協商如何移交任務。
  • 以結構化方式交換訊息與結果。
  • 追蹤長時間執行任務的狀態。

如果說 MCP 是關於代理程式使用工具,A2A 就是關於代理程式與其他代理程式協作。兩者是互補,而非競爭。

一個簡單的畫面

想像一個旅遊規劃代理程式需要訂機票並查詢天氣。

  • 透過 MCP,它連接到航班搜尋服務與行事曆,發現各自能做的事。
  • 透過 A2A,它把詳細的行程任務交給別人打造的行程專業代理程式,再接收結果。

這個代理程式不需要為這兩個連線寫客製程式。它使用的是共通的協定。

為什麼標準對每個人都重要

你不一定要打造代理程式才需要在意這件事。標準影響:

  • 選擇。 開放協定減少綁死。你可以更換工具或代理程式,不必全部重建。
  • 能力。 當連接成本低,代理程式能觸及的工具就多得多。
  • 安全。 共同的格式讓定義權限、記錄行動、稽核代理程式做了什麼更容易。
  • 成本。 可重複使用的整合,代表每種組合需要較少的客製工程。

對企業而言,實際效果是代理程式系統更容易組裝,也較不容易被鎖死在單一供應商的生態系中。

注意事項

協定很有潛力,但還很年輕。有幾點現實要牢記:

  • 標準仍在演進,細節可能改變。
  • 支援某個協定,並不保證整合安全或實作良好。
  • 把代理程式連接到強大的工具,會增加它做得到的事——包括它做錯事的能力。權限與監督仍然重要。
  • 互通性只有在底層代理程式可靠時才有用。協定無法修正糟糕的推理。

結論

MCP 與 A2A 試圖為代理程式世界提供共同語言:一個用於把代理程式連接到工具與資料,另一個用於把代理程式彼此連接。如果它們獲得廣泛採用,將讓代理程式系統更有能力、更容易替換,也更容易治理。對任何關注 AI 領域的人來說,這些協定都值得理解——它們是基礎設施,不是一時風潮。

Connect your agents without writing code

Everything above, running in Ball — no code, no install. Try it in your browser.

Try Ball free
Get the free AI agent kit

Only used to send Ball resources. No spam.

Try Ball in your browser — no install, no signup needed.

Try Ball in your browser — no install, no signup needed.

正在閱讀英文?可在選單中切換語言。