Skip to content
Bridge MCP and A2A v1.0: One Agent, Two Protocols — ContentBuffer guide

Bridge MCP and A2A v1.0: One Agent, Two Protocols

K
Kodetra Technologies··12 min read Intermediate

Summary

Build a Python agent that speaks A2A v1.0 outward and calls MCP tools inward.

On August 20, 2026, Google formally handed the Agent2Agent protocol to the Linux Foundation's Agentic AI Foundation, the same neutral home that already hosts Anthropic's Model Context Protocol. The foundation went from 49 founding members to more than 250 in under a year, with AWS, Anthropic, Google, Microsoft, OpenAI, Bloomberg and Cloudflare all signed on.

The headline is governance. The part that actually changes your code is quieter: A2A shipped v1.0, and v1.0 is not backwards compatible with the v0.2 tutorials that dominate search results. The well-known URL moved. The JSON-RPC method names changed. The kind discriminator on message parts is gone. If you copy a blog post from six months ago, your first request comes back -32601 Method not found.

This guide builds one small agent that gets both halves right. Outward it speaks A2A v1.0 so any other agent can discover and call it. Inward it uses MCP to reach its actual tools. That is exactly the division of labour the A2A spec describes in Appendix B: MCP is how an agent uses a capability, A2A is how agents delegate to each other. Every snippet below was executed against a2a-sdk 1.1.2 and mcp 2.1.0, and the outputs are copied from the terminal.


What you need

  • Python 3.10 or newer
  • About 20 minutes
  • Working knowledge of async Python — everything here is async/await
  • No API keys and no model calls. The agent is deterministic so you can see the protocol clearly.
pip install "a2a-sdk[http-server]" mcp uvicorn fastapi

# Versions this guide was verified against:
#   a2a-sdk 1.1.2
#   mcp     2.1.0

One note before you start: a2a-sdk ships its types as protobuf messages, not Pydantic models. That means Python attributes are snake_case (supported_interfaces) while the JSON on the wire is camelCase (supportedInterfaces). The SDK converts for you. Do not fight it.


Step 1: The MCP server that holds the real tools

Start at the bottom of the stack. This MCP server owns the warehouse data and exposes two tools over stdio. Save it as inventory_mcp.py.

"""A tiny MCP server exposing two warehouse tools over stdio."""
from mcp.server import MCPServer

mcp = MCPServer("inventory", version="1.0.0")

_STOCK = {
    "SKU-1042": {"name": "Thermal Receipt Paper", "on_hand": 8,   "reorder_at": 25},
    "SKU-2298": {"name": "USB-C Dock 90W",        "on_hand": 143, "reorder_at": 40},
    "SKU-3310": {"name": "Label Ribbon 110mm",    "on_hand": 0,   "reorder_at": 15},
}


@mcp.tool()
def check_stock(sku: str) -> dict:
    """Return on-hand quantity and reorder threshold for a SKU."""
    item = _STOCK.get(sku.upper())
    if item is None:
        return {"sku": sku, "found": False}
    return {"sku": sku.upper(), "found": True, **item}


@mcp.tool()
def list_below_reorder() -> list[dict]:
    """List every SKU at or below its reorder point."""
    return [{"sku": s, **v} for s, v in _STOCK.items() if v["on_hand"] <= v["reorder_at"]]


if __name__ == "__main__":
    mcp.run(transport="stdio")

If you last touched the MCP Python SDK when it was FastMCP, note the rename: in mcp 2.x the class is MCPServer and lives at mcp.server. from mcp.server.fastmcp import FastMCP raises ModuleNotFoundError.

Verify it in isolation before wiring anything else. The high-level Client accepts StdioServerParameters and launches the server as a subprocess:

import asyncio
from mcp import Client, StdioServerParameters

async def main():
    params = StdioServerParameters(command="python3", args=["inventory_mcp.py"])
    async with Client(params) as c:
        tools = await c.list_tools()
        print("TOOLS:", [t.name for t in tools.tools])
        r = await c.call_tool("check_stock", {"sku": "sku-1042"})
        print("TEXT:", r.content[0].text)

asyncio.run(main())

Output:

TOOLS: ['check_stock', 'list_below_reorder']
TEXT: {
  "sku": "SKU-1042",
  "found": true,
  "name": "Thermal Receipt Paper",
  "on_hand": 8,
  "reorder_at": 25
}

Step 2: Write an Agent Card that A2A v1.0 accepts

The Agent Card is how other agents discover you. In v1.0 it is served at /.well-known/agent-card.json. Not agent.json — that was v0.1/v0.2, and the string does not appear anywhere in the v1.0 spec. The IANA registration in section 14.3 names the suffix agent-card.json explicitly.

The bigger change is structural. v0.2 cards had a top-level url plus preferredTransport plus additionalInterfaces. v1.0 collapses all three into a single ordered supportedInterfaces array, and the first entry is the preferred one.

from a2a.types import AgentCapabilities, AgentCard, AgentInterface, AgentSkill

AGENT_CARD = AgentCard(
    name="Inventory Desk",
    description="Answers stock-level questions for the warehouse.",
    version="1.0.0",
    supported_interfaces=[
        AgentInterface(
            url="http://localhost:9999/",
            protocol_binding="JSONRPC",
            protocol_version="1.0",
        ),
        AgentInterface(
            url="http://localhost:9999",
            protocol_binding="HTTP+JSON",
            protocol_version="1.0",
        ),
    ],
    capabilities=AgentCapabilities(streaming=True),
    default_input_modes=["text/plain"],
    default_output_modes=["text/plain", "application/json"],
    skills=[
        AgentSkill(
            id="stock-lookup",
            name="Stock Lookup",
            description="Look up on-hand quantity for a SKU, or list SKUs below reorder point.",
            tags=["inventory", "warehouse", "stock"],
            examples=["How many SKU-1042 do we have?", "What needs reordering?"],
        )
    ],
)

Note that protocol_version now lives per interface, not at the top of the card. That is deliberate: it lets one deployment expose a v1.0 JSON-RPC endpoint and a v0.3 endpoint side by side while clients migrate. There is no top-level protocolVersion field in v1.0.

The three official protocol_binding values are JSONRPC, GRPC and HTTP+JSON. The field is an open string, so custom bindings are allowed, but the spec asks you to use a URI for those (for example https://example.com/bindings/websocket/v1).


Step 3: The executor that turns an A2A message into an MCP call

AgentExecutor is the one interface you implement. It gets a RequestContext and an EventQueue, and it publishes events rather than returning a value.

Here is the piece that trips up almost everyone, and it cost me a debugging cycle before I read the framework source:

# WRONG — looks reasonable, fails at runtime
updater = TaskUpdater(event_queue, context.task_id, context.context_id)
await updater.submit()      # publishes a TaskStatusUpdateEvent
await updater.start_work()

That returns:

{"error": {"code": -32006,
           "message": "Agent should enqueue Task before TaskStatusUpdateEvent event",
           "data": [{"@type": "type.googleapis.com/google.rpc.ErrorInfo",
                     "reason": "INVALID_AGENT_RESPONSE",
                     "domain": "a2a-protocol.org"}]}}

TaskUpdater.submit() publishes a status update, and a status update for a task the client has never seen is meaningless. You have to enqueue the Task object itself first. Here is the corrected executor:

import json, re

from mcp import Client, StdioServerParameters

from a2a.server.agent_execution import AgentExecutor, RequestContext
from a2a.server.events import EventQueue
from a2a.server.tasks import TaskUpdater
from a2a.types import Part, Task, TaskState, TaskStatus

MCP_PARAMS = StdioServerParameters(command="python3", args=["inventory_mcp.py"])


def _tool_json(result):
    """MCP returns text content reliably; structured_content is schema-dependent."""
    if result.structured_content is not None:
        payload = result.structured_content
        return payload.get("result", payload) if isinstance(payload, dict) else payload
    return json.loads(result.content[0].text)


class InventoryExecutor(AgentExecutor):
    """Routes an A2A message to an MCP tool call and returns an A2A artifact."""

    async def execute(self, context: RequestContext, event_queue: EventQueue) -> None:
        updater = TaskUpdater(event_queue, context.task_id, context.context_id)

        # v1.0 rule: a Task object must hit the queue before any status update,
        # otherwise the framework returns -32006 InvalidAgentResponseError.
        if context.current_task is None:
            await event_queue.enqueue_event(
                Task(
                    id=context.task_id,
                    context_id=context.context_id,
                    status=TaskStatus(state=TaskState.TASK_STATE_SUBMITTED),
                )
            )
        await updater.start_work()

        question = context.get_user_input()
        sku = re.search(r"SKU-\d+", question, re.IGNORECASE)

        async with Client(MCP_PARAMS) as mcp:
            if sku:
                res = await mcp.call_tool("check_stock", {"sku": sku.group(0)})
                data = _tool_json(res)
                if not data.get("found"):
                    text = f"No such SKU: {sku.group(0)}"
                else:
                    text = (
                        f"{data['sku']} ({data['name']}): {data['on_hand']} on hand, "
                        f"reorder at {data['reorder_at']}."
                    )
            else:
                res = await mcp.call_tool("list_below_reorder", {})
                rows = _tool_json(res)
                text = "Below reorder point:\n" + "\n".join(
                    f"  {r['sku']} - {r['on_hand']}/{r['reorder_at']}" for r in rows
                )

        await updater.add_artifact([Part(text=text)], name="stock-report")
        await updater.complete()

    async def cancel(self, context: RequestContext, event_queue: EventQueue) -> None:
        updater = TaskUpdater(event_queue, context.task_id, context.context_id)
        await updater.cancel()

Two details worth pausing on.

The _tool_json helper exists for a real reason. MCP's structured_content is derived from your tool's return annotation, and it is inconsistent. check_stock is annotated -> dict, which carries no schema, so structured_content comes back None. list_below_reorder is annotated -> list[dict], which does produce a schema — but because the top level is not an object, MCP wraps it: {"result": [...]}. The content[0].text field is always populated, so parse that as the fallback and unwrap result when it appears.

Part is flat now. In v0.2 you wrote {"kind": "text", "text": "hi"}. In v1.0 Part is a protobuf oneof across text, raw, url and data, with shared filename and media_type siblings. You write Part(text="hi") and the wire format is {"text": "hi"}. The kind key is gone entirely.


Step 4: Serve it

The v1.0 SDK dropped the old A2AStarletteApplication wrapper in favour of route factories you mount yourself. Mounting all three route groups means one process answers the Agent Card, JSON-RPC and REST bindings at once.

import uvicorn
from fastapi import FastAPI

from a2a.server.request_handlers import DefaultRequestHandler
from a2a.server.routes import (
    add_a2a_routes_to_fastapi,
    create_agent_card_routes,
    create_jsonrpc_routes,
    create_rest_routes,
)
from a2a.server.tasks import InMemoryTaskStore

handler = DefaultRequestHandler(
    agent_executor=InventoryExecutor(),
    task_store=InMemoryTaskStore(),
    agent_card=AGENT_CARD,
)

app = FastAPI()
add_a2a_routes_to_fastapi(
    app,
    agent_card_routes=create_agent_card_routes(AGENT_CARD),
    jsonrpc_routes=create_jsonrpc_routes(handler, rpc_url="/"),
    rest_routes=create_rest_routes(handler),
)

if __name__ == "__main__":
    uvicorn.run(app, host="127.0.0.1", port=9999, log_level="warning")

Start it and fetch the card:

$ python3 agent.py &
$ curl -s http://127.0.0.1:9999/.well-known/agent-card.json | python3 -m json.tool
{
    "name": "Inventory Desk",
    "description": "Answers stock-level questions for the warehouse.",
    "supportedInterfaces": [
        {
            "url": "http://localhost:9999/",
            "protocolBinding": "JSONRPC",
            "protocolVersion": "1.0"
        },
        {
            "url": "http://localhost:9999",
            "protocolBinding": "HTTP+JSON",
            "protocolVersion": "1.0"
        }
    ],
    "version": "1.0.0",
    "capabilities": { "streaming": true },
    "defaultInputModes": ["text/plain"],
    "defaultOutputModes": ["text/plain", "application/json"],
    "skills": [
        {
            "id": "stock-lookup",
            "name": "Stock Lookup",
            "description": "Look up on-hand quantity for a SKU, or list SKUs below reorder point.",
            "tags": ["inventory", "warehouse", "stock"],
            "examples": ["How many SKU-1042 do we have?", "What needs reordering?"]
        }
    ]
}

Notice the automatic snake_case to camelCase conversion. You wrote supported_interfaces; the wire carries supportedInterfaces.


Step 5: Call it over raw JSON-RPC

Two things here are easy to get wrong. The method is SendMessage in PascalCase, matching the gRPC service definition. And you must send the A2A-Version header.

curl -s -X POST http://127.0.0.1:9999/ \
  -H "Content-Type: application/json" \
  -H "A2A-Version: 1.0" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "SendMessage",
    "params": {
      "message": {
        "messageId": "m-1",
        "role": "ROLE_USER",
        "parts": [{"text": "How many SKU-1042 do we have?"}]
      }
    }
  }' 

Real response:

{
  "result": {
    "task": {
      "id": "d1097a78-ec0f-48e3-b7ab-ab7c273f762c",
      "contextId": "369a306f-aaf7-4123-9647-52b95441968b",
      "status": {
        "state": "TASK_STATE_COMPLETED",
        "timestamp": "2026-08-25T03:43:17.100024Z"
      },
      "artifacts": [
        {
          "artifactId": "80ba58c1-cc11-4f20-997e-1c8afd37c3eb",
          "name": "stock-report",
          "parts": [
            { "text": "SKU-1042 (Thermal Receipt Paper): 8 on hand, reorder at 25." }
          ]
        }
      ]
    }
  },
  "id": 1,
  "jsonrpc": "2.0"
}

Three v1.0 signatures visible in that payload. role is the full enum name ROLE_USER, not "user". state is TASK_STATE_COMPLETED, not "completed". And result is a SendMessageResponse wrapper containing exactly one of task or message — the task is nested, not returned bare.

Ask the open-ended question and the executor routes to the other MCP tool:

"parts": [{"text": "Below reorder point:\n  SKU-1042 - 8/25\n  SKU-3310 - 0/15"}]

Step 6: Call it with the typed client

For agent-to-agent traffic you normally use the SDK client, which resolves the card and picks a transport for you.

from a2a.client import ClientConfig, create_client
from a2a.types import Message, Part, Role, SendMessageRequest, TaskState

client = await create_client(
    "http://127.0.0.1:9999",
    ClientConfig(streaming=False, polling=False),
)

request = SendMessageRequest(
    message=Message(
        message_id="m-typed",
        role=Role.ROLE_USER,
        parts=[Part(text="What needs reordering?")],
    )
)

async for event in client.send_message(request):
    if event.HasField("task"):
        task = event.task
        print("state:", TaskState.Name(task.status.state))
        for artifact in task.artifacts:
            print("artifact:", repr(artifact.parts[0].text))

await client.close()

Output:

state: TASK_STATE_COMPLETED
artifact: 'Below reorder point:\n  SKU-1042 - 8/25\n  SKU-3310 - 0/15'

send_message takes a SendMessageRequest, not a bare Message — passing a Message fails with AttributeError: configuration, which is not a helpful error. It always returns an async iterator of StreamResponse, even with streaming=False; the SDK wraps the single non-streaming reply so your consumer code looks identical either way. Use event.HasField("task") to discriminate, since StreamResponse is a protobuf oneof across task, message, statusUpdate and artifactUpdate.


What breaks when you paste a v0.2 tutorial

This is worth seeing rather than reading about. Both requests below are exactly what a mid-2025 guide tells you to send.

Legacy method name and kind discriminator:

{"jsonrpc":"2.0","id":9,"method":"message/send",
 "params":{"message":{"messageId":"m","role":"user",
                      "parts":[{"kind":"text","text":"How many SKU-1042?"}]}}}
{"error": {"code": -32601, "message": "Method not found"}, "id": 9, "jsonrpc": "2.0"}

Correct v1.0 body, but no A2A-Version header:

{"error": {"code": -32009,
           "message": "A2A version '0.3' is not supported by this handler. Expected version '1.0'.",
           "data": [{"@type": "type.googleapis.com/google.rpc.ErrorInfo",
                     "reason": "VERSION_NOT_SUPPORTED",
                     "domain": "a2a-protocol.org"}]}}

An absent A2A-Version header is interpreted as 0.3, not as "latest". That default is what makes the failure so confusing: the request is well-formed v1.0 and still gets rejected. Send the header on every call. It carries Major.Minor only, so 1.0 rather than 1.0.0.

The full rename map for anything you are porting:

v0.2 / v0.3v1.0Notes
/.well-known/agent.json/.well-known/agent-card.jsonIANA-registered suffix
message/sendSendMessagePascalCase, matches gRPC
message/streamSendStreamingMessageSSE, same request shape
tasks/getGetTaskReturns a bare Task
tasks/cancelCancelTaskIdempotent
MessageSendParamsSendMessageRequestRemoval in >= 0.5.0
{"kind":"text",...}{"text": ...}Discriminator removed
{"kind":"file","file":{...}}{"raw"|"url", "filename", "mediaType"}Flattened
"role": "user""role": "ROLE_USER"Full proto enum name
"state": "input-required""state": "TASK_STATE_INPUT_REQUIRED"Full proto enum name
url + preferredTransportsupportedInterfaces[]First entry is preferred
supportsAuthenticatedExtendedCardcapabilities.extendedAgentCardMoved into capabilities
securitysecurityRequirementsRenamed on the card

Gotchas worth knowing before you ship

The client trusts the card, not the URL you gave it. I ran the server on port 9998 while the card still advertised 9999, and create_client resolved the card fine and then failed with A2AClientError: Network communication error: All connection attempts failed. The resolver reads supportedInterfaces[0].url and dials that. In containers this bites constantly: the card must advertise the externally reachable address, not localhost. Make the URL configurable from an environment variable.

Launching an MCP stdio subprocess per request is fine for a demo and wrong for production. The executor above opens Client(MCP_PARAMS) inside execute(), which forks a Python process on every message. For real traffic, open the MCP session once during app startup (a FastAPI lifespan handler works well) and reuse it, or point Client at a Streamable HTTP URL instead of a subprocess.

Expect BrokenPipeError noise on stdio teardown. When the MCP subprocess shuts down, its stdout writer can lose the pipe before it finishes flushing, and anyio surfaces that as a traceback in an exception group. The tool call already succeeded. It is cosmetic, but it will make your logs look broken — another argument for a long-lived session.

TaskUpdater refuses to leave a terminal state. Calling update_status after complete(), failed() or cancel() raises RuntimeError: Task ... is already in a terminal state. Terminal means COMPLETED, FAILED, CANCELED, REJECTED. INPUT_REQUIRED and AUTH_REQUIRED are interrupted, not terminal, so a task can resume from those.

Blocking is the default. SendMessageConfiguration.returnImmediately defaults to false, so SendMessage holds the connection until the task reaches a terminal or interrupted state. For work measured in minutes, either set returnImmediately and poll GetTask, or use SendStreamingMessage.

Streaming has to be declared. Calling the streaming method against an agent whose card says capabilities.streaming is false returns -32004 UnsupportedOperationError. The SDK client checks the card and silently falls back, which is convenient until you wonder why your SSE handler never fires.

error.data is an array, not an object. v1.0 uses ProtoJSON Any encoding, so each element carries an @type key. Code that does error["data"]["reason"] will raise TypeError; you want error["data"][0]["reason"].


Quick reference

ThingValue
Agent Card path/.well-known/agent-card.json
Required headerA2A-Version: 1.0 (absent means 0.3)
Send a messageSendMessage / POST /message:send
Stream a messageSendStreamingMessage / POST /message:stream
Fetch a taskGetTask / GET /tasks/{id}
Cancel a taskCancelTask / POST /tasks/{id}:cancel
Protocol bindingsJSONRPC, GRPC, HTTP+JSON
Terminal statesCOMPLETED, FAILED, CANCELED, REJECTED
Interrupted statesINPUT_REQUIRED, AUTH_REQUIRED
-32001TaskNotFoundError
-32002TaskNotCancelableError
-32004UnsupportedOperationError
-32005ContentTypeNotSupportedError
-32006InvalidAgentResponseError (Task not enqueued first)
-32009VersionNotSupportedError (missing/old A2A-Version)
MCP server classmcp.server.MCPServer (was FastMCP)
MCP result fieldstructured_content (snake_case in mcp 2.x)

Where to take this next

  1. Put a model behind the executor. Right now a regex picks the tool. Swap in an LLM tool-calling loop that reads mcp.list_tools() and chooses. The A2A surface does not change at all — that is the point of the split.
  2. Sign your Agent Card. v1.0 adds a signatures array carrying JWS over the card. Any agent that delegates to a card it fetched over the network should verify it; create_client takes a signature_verifier callable for exactly this.
  3. Move to streaming. Publish TaskArtifactUpdateEvent with append=True and last_chunk to stream partial results. The stream contract is strict: the Task goes first, then updates in generation order, and the stream closes on a terminal state.
  4. Add push notifications. CreateTaskPushNotificationConfig registers a webhook, and the server POSTs a StreamResponse with Content-Type: application/a2a+json. This is how you survive a client that disconnects mid-task.
  5. Swap the task store. InMemoryTaskStore loses everything on restart. DatabaseTaskStore ships in the same package, and the SDK includes Alembic migrations.

Sources

Comments

Subscribe to join the conversation...

Be the first to comment

Found this useful?

Get new AI guides for builders by email. Free.

Join 3,604 newsletter subscribers.

Also get