Loading video player...
Do you build most of your AI agents and
tools from scratch? It might be time to
rethink this approach. Building agents
is similar to building software. And
just like you wouldn't build all the
libraries from scratch, you shouldn't do
that with your tools and agents.
Software engineering is all about
reusability and A2A and MCP are no
different. Joining us today is Lakshmi
who's a field solutions architect in
Google cloud which also means she's
actually building real world gen
solutions in the field and let's not
forget she's a twotime winner of the AI
agent pay off Lakshmi what are you going
to show us today Sitha hello everyone so
in today's workshop we'll be going over
the MCP and A2A protocols and how to
build agents that communicate using
these protocols and of Of course, we'll
be building these agents with ADK.
>> Amazing. And for the viewers at home,
feel free to download the source code
that Lakshmi has shared with us and
follow along as she walks us through her
implementation. But before we dive into
the code, let's do a quick crash course
on the core concepts. Today, we'll help
a large fictional business manage their
supply chain because inventory stockouts
can cost business millions. When stock
runs low for your favorite product, it
requires manual coordination. Someone
checks inventory databases, another
person contacts suppliers, and the third
approves purchase orders. This slow
process could lead to empty shelves and
loss sales. Let's fix that. Instead of
manually coordinating, we'll build AI
agents that automatically handle each of
these steps. When inventory drops,
agents will detect it, get approval, and
place orders. In this video, we'll build
three agents which Laxmi will go in
depth. But let's see a quick overview.
First, we'll be building the inventory
agent which continuously monitors stock
levels in company's database. Then a
financial agent which automatically
approves or rejects purchase orders. And
the third a supply chain agent which
orchestrates the old workflow. And these
three agents follow microservices
pattern meaning they are separate
specialized services rather than one
chain monolithic agent. And to connect
them to each other and to other tools,
we'll use the A2A and MCP protocols. A2A
is a protocol that standardizes how
different AI agents communicate and
collaborate with each other. Think of it
like creating a common language for a
team of specialized AI agents. Away lets
agents talk to each other across
networks even if they are returned in
different languages or hosted in
different places. And in our supply
chain architecture, our financial agent
runs as an A2A server. meaning it is a
web server that other agents can call
while a supply chain agent acts as an
A2A client making requests to the
financial agent to approve or reject the
orders. This also means we build a
financial agent once and any other agent
across the organization can use it. And
MCP is like having a standardized
marketplace plug-in for AI agents. Let's
say you need two different databases for
your agent. Instead of manually
connecting you two databases to your
agent, you can use an MCP server for
databases, which means it's like a proxy
that connects you to multiple different
tools and resources. Your agent makes
standard MCP calls regardless of whether
it's connecting to Postgress SQL,
MongoDB, or a REST API. The MCP server
handles all the implementation details.
And MCB lets you use pre-built tested
tools that others have created. You need
database access, use an existing MCP
database server. And you need Slack
integration and a Slack MCP server. So
using MCP and A28 together, when the
inventory gets low, our inventory agent
will use the MCP to check the database
and then use A2A to ask the remote
financial agent for approval, which then
responds with a yes or no decision. All
right, with this in mind, let's get
started.
Let's start by taking a look at the
architecture of the supply chain agent.
So we have an orchestrator agent whose
job is to coordinate between all the
other sub agents. We have three sub
aents available here. So one is the
inventory agent. Then we have a
logistics agent and a finance agent.
Let's now dive deeper into each of these
sub agents.
So with the inventory agent it has three
tools. So first is the get inventory
levels. Then we have the get item
details and then the calculate tool
cost.
With the logistics agents there are two
tools available. So one is find shipping
options and the second one is execute
shipment. The third agent which is the
finance agent is an A2A client. So what
it does is it initiates a call to the
remote A2A agent based on the user
request. Let's now take a look at the
code and see how the agents are defined
using ADK.
So let's start with the orchestrator
agent which is a LLM agent and it has
three sub agents inventory agent,
finance agent and logistics agent. And
the orchestrator agent also has
instructions saying that you know these
are the agents that you have access to
and you know to use these um agents to
the best of its judgment. Let's now
switch to how a inventory agent is
defined. So the inventory sub agent is
again a LLM agent and it has access to a
set of tools. The tools here are the MCP
toolbox for databases. So we'll come to
it in a minute but before that let's
also look into the logistics agent and
finance agent. So logistics agent has
two tools as we described earlier the uh
find shipping options and execute
shipment. Again the instructions say
that you know your goal is to find and
present the best shipping options to
solve the supply chain issues.
Let's now come to the finance agent. So
the finance agent as I talked about
earlier is nothing but a client for a
remote A2A agent. So we need not define
any specific tools for it. You know all
you need to do is call the agent card of
the remote A2A agent running here. So in
the other agents that we just saw there
was a model that was specified and an
instruction. But is it because the
remote A2A agent here is a client that
we don't specify these parameters?
>> Exactly Sitha. So this is the client to
the remote A2A server that we were
talking about. And instead of having a
model and a set of instructions and the
tools to call this client would just
have a field called agent card and that
would point to the URL where the remote
A2A server is hosted.
So even though this is technically an
agent, its only job is to actually call
the server to use the tools or agents in
the remote server, right?
>> Absolutely. Absolutely. So all this
client knows is that there is a A2A
server running remotely and it can have
you know it has some functionality right
and um it doesn't know what tools it has
or you know what language is it written
in it doesn't have any of this
information but all it knows is that
okay there's a agent running somewhere
and I can get all the information that I
need with just this one URL.
So how is this remote A2A server
actually set up?
>> Before we answer that question, let's
take a step back and then look at the
architecture. So on the left side of the
screen, you see a agent which is our
supply chain agent. So it has its own
set of sub aents as well as the APIs and
other applications that it calls. And
this agent has been developed using ADK.
But in your organization or out in the
world there could be other agents each
of which having its own um local agents
or the sub agents as well as the tools.
So in this example this would map to our
financial agent. And for these two
agents to talk to each other we need a
A2A protocol. But in order for them to
communicate we need to kind of make them
A2A ready. So how we do it uh in this
case I'll just show you in the code.
So the remote agent here which is a
finance agent it's a ADK agent and it's
been defined exactly the same way as a
as the supply chain agent. Right? So we
do have the uh name the model
instructions and the tool that it uses.
But to make it uh A2A compatible, all
you have to do is add this one line
which says A2A app equal to 2 A2A root
agent and give it a port uh number. So
what's happening behind the uh scenes is
that ADK has a uh function called 2 A2A
and this would take this uh root agent
and then convert it into a A2A
compatible agent which is running on a
port that you specify in this case this
is 801.
So once you have this root agent, all
you have to do is to invoke the function
to A2A. Specify the agent as well as the
port on which you want the agent to run.
That's how easy it is to do it with ADK.
So does that answer your question,
Sitha? Yes. What we're seeing here is
basically a separate completely
different library and ADK is a different
library. But what ADK has done is it
created a nice little utility function
that wraps your agent and you can call
this utility function to pass it your
agent and that will give you an A2A
agent. Right? If not for this utility,
we'd have to do a bunch of other setup
to convert an agent into an A2A
compatible agent. Right.
>> Absolutely. Absolutely. So this makes it
very easy and then you can even deploy
it onto you know the local host which
I've done here or onto any of your
servers uh with just one command.
>> So at the end of the day I think the
282A is still a blackbox function right
we don't exactly know what's going
underneath it. Uh can you talk a little
bit more about what's happening there?
Sure to understand you know what exactly
is the capability of a agent you know
which is acting as the A2A server here
is how we use the agent.json
file. So we have built a server here
which is a financial agent and we have
kind of hosted it as the A2A server and
the A2A uh client which is the finance
um agent here in our supply chain agent
uses the URL to access the agent.json
JSON and when it does that it gets a lot
of information about the server
basically you know kind of it's kind of
peeking into the black box over here. So
one it will know that there's a agent
there whose name is the finance agent
and it also knows you know a description
of that server
and the tools which it has right which
is like a tool like get approval uh
threshold. So this is a tool which uh
the remote agent is having and also if
there are any authentication uh
mechanisms over here you know how to do
that all of this would be part of the
agent.json along with the URL in which
it is hosted. So in this case I've kind
of hosted it locally but it could also
be hosted on any server. I think we're
starting to get a clearer picture here.
To quickly recap what we've seen there
are two agents. one is a financial agent
which is a remote server and then the
other is a a client agent which then
calls the server using a URL and that
URL actually points to this JSON file
and what this file contains is basically
a bunch of information about the server
itself like what the server what's the
name of the server what's its
description what are its tools so that
our client agent can access this URL get
all the information and know what the
remote server is about but one final
missing piece in this is how do you
actually start the server and host this
URL
>> that also again you know you can host as
I said earlier you can host the server
either locally or on a specific server
and you can do this with just one
command for ucon right so all you have
to specify is uvcon and then the uh host
in which you have to host along with the
port so we talked about the MCP toolbox
for databases Right. So this toolbox is
what sits between your applications
orchestration framework and your
database. So what it does is it's
basically providing a control plane and
that can be used to you know manage
distribute or invoke tools.
So to use this, it's kind of quite
simple, right? So you can install the
binary version of the MCP toolbox for
databases and once you do that, you can
configure a tools.yamel
file to define your tools and then all
you need to do is to execute this
toolbox from the uh binary. So let me
show you the code for that. So this is
the file which basically defines all the
tools that uh we are using. So in this
case let's take the example of the
search item by name. So this is a
posgress uh SQL that I'm using and then
we give a description which is like
search for inventory items based on
name. We give the parameters and then we
do have the statement which says you
know select all the details from the
inventory uh based on the name. And what
we also do is at the end of the uh uh
file the YAML file we specify the tool
sets. We give it a name which is the
inventory tool set and then we just
specify the four tools that it has
access to. Now if you kind of come to
the
um to the inventory agent here. So
earlier sitha tal about you know how the
inventory agent uses the um um MCP
toolbox for databases right so what it
does is it doesn't define any tools of
of its own instead it uses the toolbox
uh to kind of load the tool set called
the inventory tool set so uh how do we
when we talk about the local host 5000
URL which is kind of running here so
that's why where I kind of talked about
earlier that we kind of run the binary
toolbox so which is running on the port
5000. So this is how the whole thing is
tied together.
Good. Now let's take a look at the
actual demo.
So we are running the demo using the ADK
web and what I will uh do here is kind
of take you through the different
functionalities uh that we kind of
discussed earlier right so
let's start with this database uh is
basically a database of the parts of a
car right so what I the first question
that I do is you know how does the stock
of alternator look like so alternator is
one of the parts and this is stored in
the Postgress database and here what
happens is when we kind of ask the
question it gets into the orchestrator
agent
which calls the inventory agent to fetch
this information in this case this is 90
units right so now let's kind of get
into the next question where it is like
you know um okay
I want to
order 100 more uh units.
So what is happening over here is that
uh you know the um inventory agent is
called again over here and the inventory
agent um has a function as we discussed
earlier which is called the calculate uh
order cost and this agent basically
finds what is the unit cost of one item
of alternator and then it uh understands
how many more units that you need and
then that is 100 right so it's it kind
of gives you that now let's kind of see
how the financial agent can get invoked
right so you can say that um you know
can I get the uh financial can you help
me with the approvals maybe that's
better yeah can you uh help me with the
approvals here
right so this is where uh the remote A2A
uh server is being called here. So here
one thing that I want uh you to note is
that all the earlier calls it was kind
of specifying which tool was being
called. So this is a remote agent. So it
just says you know transferred to agent
and
the cost of the alternator you know it's
a it's a huge amount. It's like $25k.
So what the financial agent uh does is
that you know it identifies this as a
high cost item and then it says that you
know this require this exceeds the
pre-approved limit which is $1,000 and
the excess amount would be charged to
your uh department. Do you kind of agree
with this or not? So this is a classic
case of you know where you need a
approval a human approval in this case
to kind of proceed. So you just say yes
and then what happens is the expenditure
has been approved. I'll show you the
finance agent being called here. Yeah.
So this is the case where you know the
finance agent is being called and then
what we do next is you know we say uh
you know can you uh ship it uh to me. So
what should ideally happen here is the
logistics agent must get call. So it
first asks to what destination should I
ship then I say uh ship it to you know
one main avenue LA right so I just give
an address
and uh what happens here is that the uh
logistics agent is getting called and
it's using the find shipping options
tool and then here uh the um logistics
agent basically has two options. One is
the standard flight which is like $800
and which would take you know 5 days to
arrive and again the ex the other one is
the expedited air fry uh you know which
costs 5,000 and the estimated day uh
arrival is 1 day. Which option would you
like? So I I wanted a fast delivery. So
what I would say is um the air option
in this organization there's a
pre-approved budget limit which is
1,000. So what happens here is it
requires a human approval. So I would
say no because I don't want that. So in
which case the shipping would should not
happen right and just to actually
clarify the concept of approvals and
workflows here this would wouldn't
technically in real world be an
operation that you would approve
yourself right this is let's say for
example the financial agent would create
an email to someone else to approve it
or maybe it creates a ticket uh in Jira
or somewhere else for a third person to
approve it and that would take a long
time before the approval comes through
and the agent would rescue,
>> right? Uh here what we are doing is we
are using a simple yes or no call to
show that a human interaction is
required and how that can alter the flow
but in reality you would have something
called the longunning operations right
which would kind of take maybe hours to
complete. So in this case, A2A supports
the um SSC event which are the server
sent events and um in uh simple terms
what it does is that the server
intermittently sends uh status updates
to the client and this client can kind
of monitor the tasks progress based on
these uh status updates which are kind
of coming from the server. So think of
this status as like you know completed
or say in progress or started or
cancelled or failed. And if you have
something which is kind of really
running for say multiple days um at a
stretch you could also have uh the push
notifications enabled so that the client
would know when this um operation is
completed.
>> That was a great demo. Thank you very
much Lakshmi.
Now onto the questions from the
community. Let's go.
Our first question is how does fastmcp
simplify the creation of MCP servers by
allowing tools to be exposed through
decorators?
Okay, so if you add the add mcp.tool
tool decorator to a Python function.
Fast MCP would automatically register
that function as a tool within the MCP
server.
>> Awesome. How is the JSON well-known card
for the A2A agent created?
>> So going back to the example that we saw
for the finance agent. So if you make a
agent A2A compatible using the two A2A
utility and then host it on a specific
host name using the UVcon the agent.json
gets created and it would be available
on the host name that you hosted it on.
So basically you're saying all we need
to do is run the uvicon command to start
up the server and if you're using the
A2A utility in ADK things should be
automatic and the JSON will be auto
created and we don't have to do
anything.
>> Exactly. If you use the 2 A2A utility
exactly
>> awesome next question is how is the A2A
Python library different from the
utility function that we use today? So
the A2A Python library is basically the
core library to implement A2A and the
utility in uh and the utility function
in ADK is a wrapper over it and it hides
away all the implementation from you and
looks like that's all the questions we
have for today. Thank you very much
Lakshmi. This has been great. 8way and
MCP are the buzzwords, but seeing you
strip down all the fluff and implement
it has been really phenomenal.
>> Thank you so much for having me, Sitha.
It was a pleasure.
>> And for the viewers, check out the
resources link in the video description
as you get started to build your own
multi- aent systems. Think about a
manual process in your organization that
involves multiple people checking
different systems and see if you could
like break that down into specialized
agents connected via A2A and MCP. Share
your ideas, your questions, and your
projects in the comments below. And we'd
love to see what you create. And until
next time, happy coding.
[Music]
This video demystifies Agent-to-Agent (A2A) communication Protocol and the Model Context Protocol (MCP), two key open standards for creating sophisticated AI agents that can work together. We'll show you how to use the Agent Development Kit (ADK) to create specialized agents that can communicate, delegate tasks, and collaborate securely and efficiently to solve complex problems. Follow along with our practical guide to implement A2A and MCP in your own ADK projects. Chapters: 0:00 - Introduction 1:10 - Agent usecase 2:19 - What is A2A protocol? 3:02 - What is MCP? 4:06 - Architecture 5:14 - Code walkthrough: Define agents 6:18 - Define client A2A agent 9:00 - Define remote A2A agent 11:06 - A2A Agent Card 12:57 - How to host remote agent? 13:25 - How to expose inventory tools as an MCP server 15:51 - Demo 22:20 - Community questions 24:18 - Outro and next steps Resources: Code from this tutorial → ADK documentation → https://google.github.io/adk-docs/ A2A Protocol official site → https://a2a-protocol.org/latest/ Learn more about the Agent Development Kit → https://google.github.io/adk-docs/ Subscribe to Google For Developers → https://www.youtube.com/user/GoogleDevelopers Products Mentioned: Agent Developer Kit (ADK)