What is MCP (Model Context Protocol) and how does Google ADK integrate with it?

#google-adk#mcp#tools#protocol#integration

Answer

MCP (Model Context Protocol)

Model Context Protocol (MCP) is an open standard that provides a unified way for AI agents to connect to external tools, data sources, and services. Google ADK has native MCP support allowing agents to use any MCP-compatible server.


What MCP Provides

FeatureDescription
Standard InterfaceOne protocol for all tool integrations
Tool DiscoveryServers advertise available tools automatically
Two TransportsStdio (local) and SSE/HTTP (remote)
EcosystemGrowing library of pre-built MCP servers

MCP in Google ADK

Using MCP Filesystem Server

MCP Filesystem Demo
MCP Filesystem Demo

python
from google.adk.agents import Agent
from google.adk.tools.mcp_tool import McpToolset, StdioServerParameters

# Connect to the filesystem MCP server
mcp_tools = McpToolset(
    connection_params=StdioServerParameters(
        command="npx",
        args=["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"],
    )
)

file_agent = Agent(
    name="file_manager",
    model="gemini-2.5-flash",
    instruction="Help users manage files. List, read, and write files.",
    tools=[mcp_tools],
)

Using MCP Google Maps Server

MCP Maps Demo
MCP Maps Demo

python
from google.adk.tools.mcp_tool import McpToolset, StdioServerParameters

maps_tools = McpToolset(
    connection_params=StdioServerParameters(
        command="npx",
        args=["-y", "@modelcontextprotocol/server-google-maps"],
        env={"GOOGLE_MAPS_API_KEY": "your-api-key"}
    )
)

maps_agent = Agent(
    name="maps_agent",
    model="gemini-2.5-flash",
    instruction="Help users with directions and location queries.",
    tools=[maps_tools],
)

Using Remote MCP Server (SSE)

python
from google.adk.tools.mcp_tool import McpToolset, SseServerParams

remote_tools = McpToolset(
    connection_params=SseServerParams(
        url="https://mcp-server.example.com/sse",
        headers={"Authorization": "Bearer your-token"}
    )
)

ADK as MCP Server

Google ADK agents can also expose their tools as MCP servers:

python
from google.adk.mcp import serve_as_mcp

# Expose agent's tools via MCP protocol
serve_as_mcp(agent=my_agent, port=3000)

MCP vs A2A

FeatureMCPA2A
PurposeAgent-to-ToolAgent-to-Agent
ScopeTools, data sourcesRemote agent collaboration
TransportStdio / SSEHTTP / SSE
Standard byAnthropicGoogle

They are complementary: An agent uses MCP to access tools, and uses A2A to communicate with other agents.

Learn more at MCP Tools in ADK and MCP Protocol.