aiml
SearchMy learning
Menu

Model Context Protocol (MCP)

MCP SDK 2.3

Implement, test and secure MCP servers and clients, from stdio to a remote OAuth-protected service with scoped database access.

Prerequisites
Python 3.12 and async Python, and basic HTTP and SQL.
Duration
about 2 hours of reading
Cost
Free, no sign-up

What you'll learn

  • Implement typed MCP tools, serve them over stdio and Streamable HTTP, and pin their contracts in tests.
  • Build an MCP client that acts on discovery, checks each call before sending it and traces it across processes.
  • Expose resources, resource templates and prompts from an MCP server, and test each primitive.
  • Give MCP tools to Google ADK and LangGraph agents running Gemma, and handle a failing tool.
  • Secure a remote MCP server with OAuth 2.1 and scoped tokens, and serve a read-only database with scoped roles and row caps.

Lessons

  1. Implement an MCP server with typed tool contractsRead

    Implement a task-tracker server with the MCP Python SDK whose typed tool schemas reject bad arguments and keep tool errors apart from protocol errors.

    15 min readLabQuiz

  2. Serve MCP over stdio and Streamable HTTP, and test the contractsRead

    Serve one MCP Python SDK server over stdio and Streamable HTTP, read the JSON-RPC requests the client sends, and pin its tool contracts with pytest.

    20 min readLabQuiz

  3. Build an MCP client with discovery, calls and tracingRead

    Build an MCP client that acts on discovery, refuses bad calls before sending them, classifies every outcome and traces each call with OpenTelemetry.

    22 min readLabQuiz

  4. Expose resources and prompts from an MCP serverRead

    Build a docs server with the MCP Python SDK that offers a search tool, pages as resources and a review prompt, and returns the specified error codes.

    20 min readLabQuiz

  5. Integrate MCP tools into ADK and LangGraph agentsRead

    Connect one MCP server to a Google ADK agent with McpToolset and a LangGraph agent with langchain-mcp-adapters, and compare how each handles tool failures.

    20 min readLabQuiz

  6. Secure a remote MCP server with OAuth 2.1 and scoped tokensRead

    Serve an MCP server over Streamable HTTP that accepts only tokens issued for it, publishes Protected Resource Metadata and returns 403 for a missing scope.

    24 min readLabQuiz

  7. Build a read-only database MCP server with scoped rolesRead

    Let a model run SQL through an MCP tool on PostgreSQL 17 with a read-only role, a statement timeout and row and byte limits, and test what each layer stops.

    26 min readLabQuiz