inflearn logo

Python MCP Server & Agent: 60 Lessons

Go beyond toy tool examples and safely connect internal databases, documents, and external APIs to Claude, Cursor, and custom Python agents. Complete the full 60-lesson course, covering everything from JSON-RPC 2.0 packets and the three pillars (Resources, Tools, and Prompts) to Streamable HTTP, two-way Sampling and Elicitation, five security guardrails, multi-server orchestration, and in-memory pytest and Docker deployment.

3 learners are taking this course

Level Basic

Course period Unlimited

Model Context Protocol
Model Context Protocol
Python
Python
AI Agent
AI Agent
LLM
LLM
Docker
Docker
Model Context Protocol
Model Context Protocol
Python
Python
AI Agent
AI Agent
LLM
LLM
Docker
Docker

What you will gain after the course

  • The ability to analyze the Host·Client·Server isolation architecture and JSON-RPC 2.0 initialization handshake, and to design distinct roles for Resources·Tools·Prompts and self-healing responses using isError: true

  • Capabilities for local stdio (protection against stdout pollution) and remote Streamable HTTP (stateful vs. stateless scaling), shared lifespan connection pools, cursor-based pagination, and task cancellation and timeout control.

  • The ability to build five hands-on MCP servers for databases, FTS5 full-text search, Git, REST APIs, and multimodal use cases, leveraging real-time progress, standard logging, reverse sampling, user-input elicitation, and Roots boundaries

  • The capability to enforce physical path containment against path traversal, lock the DB in read-only mode (mode=ro), isolate indirect prompt injection, require two-stage human approval for Dry-Run, and implement OAuth 2.1 authentication and audit logs with sensitive information masking.

  • The ability to route multiple MCP servers using Python’s ClientSession and AsyncExitStack without a commercial host app, and rein in agent runaway with dynamic tool exposure, token trimming, and circuit breakers.

  • Ability to build an in-memory pytest integration test suite that completes in 0.36 seconds without launching external processes, package it as a uvx command, isolate it in a non-root Docker container, and deploy it with reverse-proxy streaming.

Recommended for
these people

Who is this course right for?

  • Backend and AI developers who have tried running simple @mcp.tool examples like weather or calculators, but are afraid to connect them to real internal databases or business APIs because of path traversal, accidentally executed deletion queries, and authentication mishaps.

  • Practicing engineers encountering unexplained JSON parsing failures in local stdio servers, or looking to define clear deployment standards for migrating to remote Streamable HTTP, managing sessions, and streaming through reverse proxies.

  • An agent builder who has experienced the problem of registering dozens of tools, wasting context tokens and causing the model to choose the wrong ones, and needs an architecture for separating Resources and Tools, dynamically exposing them, and orchestrating multiple servers.

  • For those who want to port a secure tool execution loop and automated pytest validation pipeline to their own Python service backend (ClientSession), in addition to integrating with Claude Desktop and Cursor.

Need to know before starting?

  • If you know basic Python syntax (functions, classes, type hints, and basic async/await), you can follow along step by step starting with Lesson 1: Packet Basics, even if you have no prior MCP experience.

  • This is conducted in a local environment using the free official Python MCP SDK, Pydantic, SQLite, and pytest. It does not cover beginner-level Python syntax, web frontend UI publishing, or the mathematical theory behind LLM fine-tuning.

Hello
This is catgpt

Career Verified

A through-and-through AI researcher, 'CatGPT', who busted their ass reading papers and fine-tuning models. Then one day, a bolt-from-the-blue mission landed in their lap: "You’ve finished building the model, right? Now write the front end and back end too so we can deliver it to the client."

To survive, I was forced to make a tearful career change into a full-stack developer. After successfully delivering the solution and making it back, AI had advanced so much that this time, instead of coding, I found myself taking on the role of a PM coordinating a team with AI...!

Not stopping there, this max-level engineer went all in and poured their full-stack soul into building a “lecture production automation pipeline” and even bringing an “AI instructor” to life. What fate awaits CatGPT, the full-stack AI engineer who has automated even their own livelihood(?)!

More

Curriculum

All

60 lectures ∙ (8hr 26min)

Course Materials:

Lecture resources
Published: 
Last updated: 

Reviews

Not enough reviews.
Please write a valuable review that helps everyone!

catgpt's other courses

Check out other courses by the instructor!

Similar courses

Explore other courses in the same field!

Limited time deal

$701,254.00

48%

$51.70