Share
Embed
Transcript
35 slides
-
An open protocol that defines a standardized way to provide
tools (functions) and context to your LLMs An MCP enabled tool becomes available to all MCP enabled clients modelcontextprotocol.io -
AI App Functions: getWeather getCurrency Gemini How’s the weather in
London? Recap: Traditional Tool Calling Weather Service {“forecast”:”rainy”} getWeather(“London”) It’s rainy in London Currency Service {“GBP:USD”:”1.36”} getCurrency(“GBP:USD) 1 British Pounds in US Dollars? 1 British Pounds is 1.36 US Dollars How’s the weather in London? Tools: getWeather, getCurrency getWeather(“London”) {“forecast”:”rainy”} It’s rainy in London 1 British Pounds in US Dollars? Tools: getWeather, getCurrency getCurrency(“GBP:USD”) {“GBP:USD”:”1.36”} 1 British Pounds is 1.36 US Dollars -
Traditional Tool Calling 1. You need to maintain the integration
code between your AI app and external services 2. No way to reuse these tools with other AI apps -
After MCP Tools MCP Server (local) MCP Server (remote) MCP
Server (remote) AI App MCP Host MCP Client MCP Client MCP Client -
MCP Data and Transport Layers MCP Server (local) MCP Client
MCP Server (remote) MCP Client ✉ JSON-RPC 2.0 Stdio transport Streamable HTTP transport Streamable HTTP transport ✉ ✉ -
MCP – Initialization MCP Client MCP Server notifications/initialized Params: •
protocolVersion • capabilities • clientInfo Result: • capabilities • serverInfo initialize request with protocol version & client capabilities initialize response with protocol version & server capabilities -
MCP Server – Tools • Tools enable AI models to
interact with external systems • Each tool defines a specific operation with inputs and outputs • Model-controlled: The model requests tool execution based on context -
MCP Server – Tools MCP Client MCP Server tools/list request
tools/list response with tools list tools/call request tools/call response with tool result -
MCP Server – Tools mcp = FastMCP(name="Tool Example") @mcp.tool() def
sum(a: int, b: int) -> int: """Add two numbers together.""" return a + b @mcp.tool() def get_weather(city: str, unit: str = "celsius") -> str: """Get weather for a city.""" # This would normally call a weather API return f"Weather in {city}: 22degrees{unit[0].upper()}" -
MCP Server – Resources Resources provide read-only access to data
that the AI application can retrieve and provide as context to models -
MCP Server – Resources mcp = FastMCP(name="Resource Example") @mcp.resource("file://documents/{name}") def
read_document(name: str) -> str: """Read a document by name.""" # This would normally read from disk return f"Content of {name}" @mcp.resource("config://settings") def get_settings() -> str: """Get application settings.""" return """{ "theme": "dark", "language": "en", "debug": false }""" -
MCP Server – Prompts Provide reusable prompts for a domain,
or showcase how to best use the MCP server -
MCP Server – Prompts mcp = FastMCP(name="Prompt Example") @mcp.prompt(title="Code Review")
def review_code(code: str) -> str: return f"Please review this code:\n\n{code}" @mcp.prompt(title="Debug Assistant") def debug_error(error: str) -> list[base.Message]: return [ base.UserMessage("I'm seeing this error:"), base.UserMessage(error), base.AssistantMessage("I'll help debug that. What have you tried so far?"), ] -
MCP Server – Tools, Resources, Prompts Who controls it? Use
Cases Tools Model-controlled: Model decides when to call these Allow LLM to interact with external systems Resources App-controlled: App decides when to call these Provide read-only access to data that the AI application can retrieve and provide as context to models Prompts User-controlled: The user decides when to use these Provide reusable prompts for a domain, or showcase how to best use the MCP server -
MCP Client – Roots Roots are a mechanism for clients
to communicate filesystem access boundaries to servers -
MCP Client – Roots from fastmcp import Client from fastmcp.client.roots
import RequestContext # Static client = Client( "my_mcp_server.py", roots=["/path/to/root1", "/path/to/root2"]) # Dynamic async def roots_callback(context: RequestContext) -> list[str]: print(f"Server requested roots (Request ID: {context.request_id})") return ["/path/to/root1", "/path/to/root2"] client = Client( "my_mcp_server.py", roots=roots_callback) -
MCP Client – Sampling Allows the MCP server to make
LLM calls through the MCP client on its behalf Shifts the responsibility & cost of LLM calls from the server to the client (each client pays for their own LLM usage) -
MCP Client – Elicitation Elicitation enables servers to request specific
information from users during interactions, creating more dynamic and responsive workflows -
MCP Client – Elicitation MCP Client MCP Server elicitation/create (Request
more information) Result: • user payload User Present elicitation UI Provides requested information Return user response Params: • custom properties -
MCP Code samples1 use outdated FastMCP 1.0 from mcp.server import
FastMCP ❌ Instead, you should use FastMCP 2.02 from fastmcp import FastMCP ✅ MCP Python SDK – FastMCP 1 modelcontextprotocol.io 2 gofastmcp.com -
Gemini CLI is good overall MCP testing Agent Development Kit
(ADK) supports MCP tools out of the box Claude Desktop is good in testing stdio based* MCP servers MCP support in different tools *For the rest - www.npmjs.com/package/mcp-remote -
MCP support in different tools Stdio transport Streamable HTTP transport
Tools Resources Prompts Claude Desktop ✅ ❌ ✅ ✅ ✅ Gemini CLI ✅ ✅ ✅ ❌ ✅ Agent Development Kit ✅ ✅ ✅ ❌ ❌ -
Deploy MCP servers to Cloud Run Agent MCP Client Cloud
Run MCP Server Cloud Run External resources ✅ Deploy your MCP server alongside your AI agents, one product to learn ✅ Scalable: Cloud Run will scale your MCP server automatically based on demand ✅ Centralized server: Share access to a centralized MCP server with team members through IAM privileges, allowing them to connect to it from their local machines instead of all running their own servers locally ✅ Security: Cloud Run provides an easy way to force authenticated requests to your MCP server -
Thank you! Mete Atamel Developer Advocate at Google @meteatamel atamel.dev
speakerdeck.com/meteatamel github.com/meteatamel/genai-beyond-basics/tree/main/samples/protocols/mcp