← Build an AI Team Lesson 5 of 12

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

Change the numbers. Compare.

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

Pick a server. See its answer, and the lines the bot gets.

the server's answer (JSON)

lines in the bot's instructions

These messages are JSON: lists and dictionaries written as text.

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

Change the call. Send it.

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)

Work each one out. Type the answer, press Check.
4 AI apps, 5 services, no standard. How many connections must be built?
Same apps and services, with MCP. How many pieces must be built?
Same setup, with MCP. You add one new service, a payments app. How many new pieces must be built?
Operations is connected to two MCP servers: the order sheet with 3 tools and the courier with 2. How many tool lines are added to its instructions?

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 Instagram server's tools. Which should Marketing get?

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

Operations books a pickup with the courier's agent. Step through.

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.

Pick for each one.

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.

Work each one out. Type the answer, press Check.
An Instagram server has 4 tools: read_comments, draft_post, publish_post, delete_post. Marketing only drafts. How many should it get?
The order sheet server has 6 tools. Production is given only 3 of them. How many tool lines are in Production's instructions?
An A2A task to the courier: it starts, then the courier asks “how heavy are the parcels?”, gets the answer, and finishes. How many times is the task working?
Same task. How many times does its status change, from 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

Example lines, made for this page. Does the tool run?

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"])

The 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.

1. Work it out2 AI apps and 6 services, with MCP. How many pieces must be built?
2. IdeaHow does a bot find out what tools an MCP server has?
3. PredictA call sends {"id": 101} to a tool that needs order_id. What comes back?
4. DecideShould Marketing get the Instagram tool publish_post?
5. PickA fabric supplier runs an agent that checks stock, asks which colour you want, and places the order. MCP or A2A?

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?

This leaves a question
You've built it all by hand. What does a ready-made team app look like?
Lesson 6 answers it.
For your business: list the services your work lives in. For each, write MCP (a tool to use) or A2A (another company's agent), and which bot should get it.