MCP and A2A
One plug for everything
Amal Designers' work lives in many services: an order sheet, Instagram, a courier, WhatsApp. And there are many AI apps that run agents. Without a shared standard, every app needs its own connection to every service: 3 apps × 4 services = 12 to build.
With MCP, each service is wrapped once, as an MCP server, and each app learns MCP once, as an MCP client: 3 + 4 = 7.
without a standard: apps × services · with MCP: apps + services
So what does an MCP server actually say?
A server lists its tools
First, the client asks the server: what tools do you have? This question is called tools/list. For each tool, the server answers with its name, a description, and the inputs it needs. The client then writes one line per tool into the bot's instructions, so the bot knows what it can use.
tools/list → name, description, inputs
the server's answer (JSON)
lines in the bot's instructions
These messages are JSON: lists and dictionaries written as text.
tools/list, tools/call, and each tool's name, description and inputSchema. Real messages carry a few more fields, like the protocol version (the current one is dated 2026-07-28). The services here are made up.The bot knows the tool. How does it use it?
Calling a tool
To use a tool, the client sends tools/call with the tool's name and its arguments. The server checks them, runs the tool, and sends back the result, or an error that says what was wrong. The error goes back to the bot, like any tool result, so it can try again.
tools/call {name, arguments} → result or error
tools/call
the server's reply
Count it on new numbers.
✏️ Practice 5.1
Remember:
without a standard: apps × services · with MCP: apps + services
tools/list → name, description, inputs (one line per tool for the bot)
Should every bot get every tool?
Only the tools it needs
An MCP server may offer tools that change things for real: publish a post, delete one, refund an order. A bot that only drafts captions doesn't need those. So you choose, bot by bot, which tools it sees. Fewer tools also means shorter instructions.
each bot gets only the tools its role needs
The social media manager still publishes. Marketing drafts, she decides.
Some services aren't tools, though. They're agents.
A2A: agent to agent
Say the courier company runs its own agent. You can't call it like a tool: it's a whole agent that works on its own side. A2A is the standard for this. First, you read its Agent Card: who it is, its address, and its skills. Then you send it a task in plain words, and follow the task's status until it's done.
MCP: a bot uses a tool · A2A: an agent asks another agent
MCP or A2A: how do you tell?
MCP or A2A?
Ask: is the other side a tool that does one thing when called, or an agent that thinks and works on its own, maybe asking questions back? A tool → MCP. An agent → A2A.
Try it on new numbers.
✏️ Practice 5.2
Remember:
each bot gets only the tools its role needs
MCP: a bot uses a tool · A2A: an agent asks another agent
An A2A task's status: submitted → working → completed, with input-required when it needs an answer from you.
read_comments, draft_post, publish_post, delete_post. Marketing only drafts. How many should it get?working?submitted to completed?What happens when a real LLM writes the call?
A real LLM writes the call
In Colab, a real model gets the tool lines in its instructions and asks for a tool by writing one line: CALL, then the JSON. The program reads the JSON, checks the tool and its inputs, and only then runs it. Anything wrong comes back as an error.
the program checks every call before it runs
Here's all of it in Python.
The code
A tiny MCP server and client, and an A2A task, all in plain Python, with no network. Guess each print, then press ▶ Run.
import json # JSON: text that holds lists and dictionaries, so programs can send them to each other
# An MCP server for the order sheet. It lists its tools, and runs one when asked.
ORDERS = {101: "red frock, size 5, paid", 102: "pastel frock, size 3, packed"}
def order_status(args):
return ORDERS.get(args["order_id"], "No order with that number")
order_server = {
"tools": [{"name": "order_status",
"description": "Look up one order by its number.",
"inputSchema": {"type": "object",
"properties": {"order_id": {"type": "integer"}},
"required": ["order_id"]}}],
"run": {"order_status": order_status},
}
# tools/list: the first thing a client asks
def list_tools(server):
return {"jsonrpc": "2.0", "id": 1, "result": {"tools": server["tools"]}}
# The client turns the list into lines for the bot's instructions
def describe(server):
lines = []
for t in list_tools(server)["result"]["tools"]:
needs = ", ".join(t["inputSchema"]["required"])
lines.append(f'{t["name"]}({needs}): {t["description"]}')
return "\n".join(lines)
print(describe(order_server))
# tools/call: run one tool with its arguments, or send back an error
def call_tool(server, request):
name = request["params"]["name"]
args = request["params"]["arguments"]
tool = None
for t in server["tools"]:
if t["name"] == name:
tool = t
if tool is None:
return {"jsonrpc": "2.0", "id": request["id"], "error": {"message": "Unknown tool: " + name}}
for need in tool["inputSchema"]["required"]:
if need not in args:
return {"jsonrpc": "2.0", "id": request["id"], "error": {"message": "Missing: " + need}}
text = server["run"][name](args)
return {"jsonrpc": "2.0", "id": request["id"], "result": {"content": [{"type": "text", "text": text}]}}
# A bot asks for a tool by writing one line: CALL, then JSON
def handle(line, server):
try:
call = json.loads(line.replace("CALL ", "", 1))
except Exception:
return "Error: not valid JSON"
request = {"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": call}
reply = call_tool(server, request)
if "error" in reply:
return "Error: " + reply["error"]["message"]
return reply["result"]["content"][0]["text"]
print(handle('CALL {"name": "order_status", "arguments": {"order_id": 101}}', order_server))
print(handle('CALL {"name": "order_status", "arguments": {"id": 101}}', order_server))
# A2A: another company's agent. First, read its Agent Card: who it is, what it can do.
courier_card = {"name": "SwiftShip Courier Agent",
"url": "https://swiftship.example/a2a",
"skills": [{"id": "book_pickup", "description": "Book a parcel pickup"}]}
print(courier_card["name"], "can:", courier_card["skills"][0]["description"])
# Send it a task. It works on its own side; we watch the task's status change.
def send_task(card, message):
task = {"id": "t-7", "status": "submitted", "message": message}
print(task["status"])
for status in ["working", "completed"]: # what the courier's agent reports back
task["status"] = status
print(task["status"])
task["result"] = "Pickup booked: Saturday 4 PM, 6 parcels"
return task
task = send_task(courier_card, "Pick up 6 parcels from Kochi on Saturday.")
print(task["result"])
$ python lesson5.py
order_status(order_id): Look up one order by its number.
red frock, size 5, paid
Error: Missing: order_id
SwiftShip Courier Agent can: Book a parcel pickup
submitted
working
completed
Pickup booked: Saturday 4 PM, 6 parcelsThe notebook has all of this, then a real model choosing the tool and writing the call. Its first run downloads the model (about 3 GB). In Lesson 7, your bots use real MCP servers through Hermes.
Quick check: did it all make sense?
Lesson 5 test
5 questions, one for each idea in this lesson. Answer them all right to pass. A wrong answer tells you why, and which page to look at again.
{"id": 101} to a tool that needs order_id. What comes back?publish_post?What comes next.
Time for a real one
You've now built every part by hand: roles, a group chat, @mentions, a board, handoffs, MCP and A2A. A ready-made app does all of this for you, and runs all day. From Lesson 6, you set one up on your own laptop.
Will I get a real courier tool, and my own computer to work on?