RAG, MCP and A2A: The Three Jobs Inside an AI Agent
ยท 15 min read
If you spend any time around people building AI agents, three acronyms keep coming up: RAG, MCP and A2A. Most developers can explain at least one of them well enough. Far fewer can say where one stops and the next begins, and that fuzzy boundary is usually why an agent that demos beautifully turns slow, confused or unsafe the moment it meets real users.
The cleanest way I've found to keep them straight is that each one answers a different question:
- RAG answers what does the agent need to know?
- MCP answers what can the agent do?
- A2A answers who else can the agent work with?
Rather than define all three up front, I want to build one agent layer by layer and bring in each piece at the exact point where the agent hits a wall without it. The agent is a customer support assistant for an online kitchenware store, and the one request it has to handle the whole way through is this:
"My blender arrived with a cracked jug. Can you send me a replacement before Saturday?"
Software has been talking to other software through APIs for decades. An API is really just a contract: it says what you can ask for, how to format the request, and what you'll get back. Send the expected input to the expected endpoint and you get a predictable response, and that predictability is the whole point. It's how a store checks stock, takes a payment, or fires off a shipping notification.
Traditional software gets along fine with APIs because a developer plans every step ahead of time. A large language model breaks that assumption. The input is no longer a tidy form, it's a sentence like the one above, and handling it means understanding the problem, checking a few systems, maybe asking a follow-up question, and adjusting the plan as it goes. The model understands the goal, but the APIs still want exact instructions: which endpoint, which fields, which credentials, and what to do when a call fails. Being intelligent doesn't hand you an interface for free.
The first fix people reached for was brute force: describe every function to the model in the prompt. "To look up an order, call this function with these fields, and expect this shape back." That holds up for a handful of tools. Once you have dozens, the instructions balloon, and when an API quietly changes its schema, things start breaking in ways nobody notices for a while. Every integration becomes a custom connector that somebody has to write and then keep alive.
Hold onto that problem, because it comes back later. First, though, our support agent runs into something more basic.
The model behind the support agent knows plenty about blenders in general. What it has no way of knowing is anything specific to this customer or this store: that the order was delivered three days ago, that it shipped from the warehouse in Lagos, or that the store promises a free replacement for items damaged in transit as long as they're reported within 30 days. Those facts are private, specific, and liable to change, and none of them were anywhere in the model's training data.
When a model doesn't know something, it can still answer with total confidence, filling the gap with something that sounds right and isn't. That's a hallucination, and in customer support it costs real money. Promise a refund the policy doesn't allow and you haven't helped anyone, you've created a second problem on top of the first.
The obvious move is to train the model on the store's data. Fine-tuning is genuinely good for teaching behaviour, tone and repeated patterns, but it's a poor place to keep facts that change. The day the policy is updated or a new order comes in, whatever the model memorised is already stale.
So instead of asking the model to memorise moving facts, you fetch the relevant ones at the moment it needs them. That's retrieval-augmented generation, or RAG, the pattern laid out in a 2020 paper from researchers at Facebook AI. Think of it as an open-book exam. The model still does the reasoning, but before it answers you hand it a small packet of evidence that's relevant to the question.
A basic RAG pipeline runs like this:
- Ingest the source material: the returns policy, the shipping FAQs, the product manuals.
- Split it into useful chunks and index them. The index can use keyword search, semantic search with embeddings (which matches text by meaning rather than exact wording), or a hybrid of the two.
- When a request comes in, check permissions, so the agent only ever sees what this particular user is allowed to see.
- Retrieve the best-matching chunks and drop them into the model's context before it writes a word.
The agent isn't remembering the returns policy, then. It's reading the current, authorised copy right when it needs it, which makes the answer fresher and far easier to check after the fact.
Different kinds of information want different homes, though. Unstructured text like the returns policy suits semantic search. A precise fact like the order's delivery date should come straight from the order system, which is the source of truth, behind strict access controls, not from some document index that might be a day behind. The methods differ, but the job is the same: put fresh, authorised evidence in front of the model at the point of use.
RAG has limits worth knowing before you lean on it:
- It gives context, not capability. It can tell the agent what the policy says, but it can't create a replacement order or book a courier.
- Retrieved content can mislead. An outdated policy page produces outdated answers, and a document that somebody has seeded with hidden instructions can try to hijack the model. That's a flavour of prompt injection.
- It over-shares if you let it. A full customer record carries far more than this task needs, payment details and old addresses included. Retrieve only what the request actually calls for.
With RAG in place, the agent can give a well-grounded answer: your order qualifies for a free replacement. What it still can't do is send one. Knowing what to do and being able to do it are two different things, and that gap is the second wall.
To act, the agent needs tools, and the usual mechanism is function calling. The model writes a structured request, something like "call check_stock with product ID BL-200 and warehouse Lagos". The application wrapped around the model, the host, checks that request, runs the real code, and hands the result back to the model, which then decides what to do next. That loop of request, check, run, return is the engine underneath most agents that do anything useful.
Function calling isn't a magic connect button, though. For every service, a developer still has to read the API docs, map its data format, and decide exactly what the model is allowed to see and do. Then they do the whole thing again for the order system, the inventory system, email, payments. Other teams go off and build their own versions of the same connectors. What you end up with is a drawer full of custom glue code that snaps the moment a service changes its API, which is the same problem we parked earlier, back again.
The Model Context Protocol, MCP, is the industry's answer to that repeated work. Anthropic introduced it in November 2024 as an open standard, and in December 2025 donated it to the Agentic AI Foundation, a directed fund under the Linux Foundation. By then the Linux Foundation counted more than 10,000 published MCP servers.
MCP spread because nearly every agent needs the same thing: a standard way for its application to reach outside tools and data. You'll often see it called "USB-C for AI applications", and the analogy holds up to a point. USB-C standardises the connection, but plugging something in doesn't make it safe or guarantee it supports every feature. MCP is the same. It standardises how an AI application talks to an outside service, not whether that service deserves your trust.
The MCP specification names three roles:
- Host: the AI application, here the support agent's application.
- Client: a connector that lives inside the host. The host runs one client per server it connects to.
- Server: a service that offers capabilities, such as the store's order system.
The order system could run an MCP server that exposes tools like lookup_order, check_stock and create_replacement_order, each with a description and a machine-readable input schema. Because the server speaks MCP, any MCP-compatible application can discover those tools and call them in the same format, with no custom integration per app.
Underneath, the messages travel as JSON-RPC 2.0. A local server usually runs as a process on the same machine and talks over standard input and output; a remote one is reached over HTTP. One detail changed recently and is worth flagging. Earlier versions of MCP had the client and server agree on capabilities in a handshake at the start of a connection. The current spec, dated 28 July 2026, makes the protocol stateless: every request carries its own protocol version and the client's capabilities, so a server never has to lean on earlier messages to know what it's dealing with.
MCP servers can offer more than actions. The spec defines three server features:
- Tools: functions the model can call, like
create_replacement_order.
- Resources: data for the model or the user, such as files or database records.
- Prompts: reusable templates and workflows.
Clients can offer features back to servers, too. One is elicitation, where a server pauses to ask the user for something it's missing mid-task, for example "which delivery address should we use?"
Marketing copy tends to make MCP sound more magical than it is, so two things are worth saying plainly.
First, MCP doesn't replace APIs. An MCP server very often sits on top of an existing REST API. The API still defines how the service actually works; MCP just gives AI applications a standard way to discover and use it. It isn't MCP or APIs, it's usually MCP on top of APIs.
Second, MCP doesn't do RAG for you. You could expose the store's policy documents as MCP resources, but MCP won't search them, rank them, or decide who's allowed to see them. The application still has to retrieve the right passages, check permissions, and put the evidence in the model's context. That part is yours.
MCP also doesn't look after security on its own. The spec says a host must get explicit user consent before invoking any tool, and that tool descriptions should be treated as untrusted unless they come from a server you trust. In practice that means connecting only to servers you trust, handing each one the least credential it can get away with, validating every request, and logging every action.
With MCP wired in, the agent can look up the order, check stock, and create a replacement order. Notice how tightly scoped those tools are: the agent can create a replacement under the store's policy, but nothing here lets it issue refunds or move money around freely. That restraint is deliberate, and it's the kind of boundary you want to draw on purpose rather than discover later.
The replacement is in stock in Lagos, but the customer wants it before Saturday, and delivery is handled by a separate courier company. The courier has its own systems, its own rules about delivery slots and pricing, and increasingly its own AI agent handling booking and rescheduling.
You can't just hand the support agent the courier's internal tools. They belong to another company, which gets to decide what outsiders are allowed to do with them. What the support agent needs is a way to make a request to the courier's agent and let that agent carry it out under its own rules.
This is also how real organisations have always worked. Specialists own their patch and pass work to each other. Splitting work across agents keeps responsibilities and permissions cleanly separated, but it buys you delays, coordination problems and new security risks in return. When both agents live inside the same application, that application can usually coordinate them directly. A shared protocol only starts to earn its place once the agents are built by different teams, or different companies, on different stacks.
That's the gap Agent2Agent, A2A, is meant to fill. Google announced it in April 2025 and that June handed it to the Linux Foundation, where it launched as a project alongside AWS, Cisco, Microsoft, Salesforce, SAP and ServiceNow. A2A gives independent agents a shared way to discover what each other can do, exchange messages, manage tasks and return results.
Discovery in A2A starts with the agent card, which the A2A specification describes as a JSON metadata document published by an A2A server. It covers the agent's identity, its capabilities and skills, its service endpoint, and what authentication it requires. Agents usually publish it at a well-known address on their domain, /.well-known/agent-card.json.
Treat it as a service listing, not a social profile. It tells you what an agent claims it can do; it doesn't prove the agent is safe or trustworthy. So a few things follow:
- The support agent should find the courier's agent only through a trusted route, like the courier's official domain, a direct arrangement between the two companies, or an approved directory.
- It then authenticates using whatever method the card requires.
- The courier's side decides what the support agent is actually allowed to do. Finding an agent card grants no permission on its own.
Once they're connected, the support agent can ask the courier's agent to deliver the replacement before Saturday. Work in A2A is organised as tasks that move through states. A task can be working, pause in input-required when the courier's agent needs more information such as a gate code, or sit in auth-required, and it ends as completed, failed, canceled or rejected. That's what lets long-running work happen in the background, with updates along the way instead of one call that blocks until it's done. The spec defines these operations independently of the wire format, with bindings for JSON-RPC, gRPC and HTTP+JSON.
The shortest way to keep the two protocols apart: MCP lets an AI application use another system's tools; A2A lets independent agents work together on a task.
Here's the whole request once all three layers are in place.
The customer writes: "My blender arrived with a cracked jug. Can you send me a replacement before Saturday?"
RAG supplies the facts. The agent retrieves only what it needs: the transit-damage section of the returns policy, and from the order system, the delivery date and the product. It doesn't pull the customer's full record or their payment details. The policy says damaged items reported within 30 days get a free replacement, and the order was delivered three days ago, so it qualifies. If something didn't add up, say an order the system can't find, the agent would flag it instead of guessing its way past it.
MCP lets it act. Through the order system's MCP server, the agent calls check_stock and finds the blender sitting in Lagos. It then calls create_replacement_order. The host checks the call is allowed under the policy, validates the request, and logs it, and the replacement is created at no charge.
A2A brings in the courier. The support agent finds the courier's agent through the store's existing integration, authenticates, and sends a task: deliver this parcel to this address before Saturday. The courier's agent moves the task to working, then to input-required to ask whether the customer's building has a gate code. The support agent puts that question to the customer, passes the answer back, and the task completes with a Friday slot and a tracking number.
The agent closes the loop. It tells the customer the replacement is on its way for Friday, shares the tracking link, and asks them to hold onto the cracked jug until the courier collects it, because the policy says so.
One request, three layers, each doing one clear job.
| Layer |
Question it answers |
In the example |
What it doesn't do |
| RAG |
What does the agent need to know? |
Returns policy and order details |
Take any action |
| MCP |
What can the agent do? |
Check stock, create the replacement order |
Search documents for you, or decide which servers to trust |
| A2A |
Who else can the agent work with? |
Book delivery with the courier's agent |
Prove the other agent is trustworthy, or grant permissions |
Most of the agent trouble that shows up in production comes from blurring these layers: expecting retrieval to take actions, expecting a protocol to handle security for you, or giving one agent every tool in the building instead of letting specialists own their own work. Keep each layer to its own job, and put a guardrail at every boundary where one hands off to the next.