Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Model Context Protocol

Avatar for Mete Atamel Mete Atamel
September 22, 2025

Model Context Protocol

Avatar for Mete Atamel

Mete Atamel

September 22, 2025
Tweet

More Decks by Mete Atamel

Other Decks in Programming

Transcript

  1. 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
  2. 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
  3. 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
  4. After MCP Tools MCP Server (local) MCP Server (remote) MCP

    Server (remote) AI App MCP Host MCP Client MCP Client MCP Client
  5. 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 ✉ ✉
  6. 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
  7. 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
  8. 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
  9. 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()}"
  10. MCP Server – Resources Resources provide read-only access to data

    that the AI application can retrieve and provide as context to models
  11. 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 }"""
  12. MCP Server – Prompts Provide reusable prompts for a domain,

    or showcase how to best use the MCP server
  13. 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?"), ]
  14. 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
  15. MCP Client – Roots Roots are a mechanism for clients

    to communicate filesystem access boundaries to servers
  16. 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)
  17. 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)
  18. MCP Client – Elicitation Elicitation enables servers to request specific

    information from users during interactions, creating more dynamic and responsive workflows
  19. 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
  20. 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
  21. 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
  22. MCP support in different tools Stdio transport Streamable HTTP transport

    Tools Resources Prompts Claude Desktop ✅ ❌ ✅ ✅ ✅ Gemini CLI ✅ ✅ ✅ ❌ ✅ Agent Development Kit ✅ ✅ ✅ ❌ ❌
  23. 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
  24. 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