All courses LLM apps

Build Your First MCP Server in Python

Beginner

Give an AI assistant tools, resources and prompts, test them and connect a real host.

Beginner 7 lessons 21 lab exercises Certificate Updated

You build

An MCP server that lets an AI assistant list, add and complete the tasks of a small task tracker stored in SQLite.

You need

  • Python basics: functions, lists, dictionaries and modules (the course Python for AI from Zero is one way to get them). No experience with classes or type hints is needed: both are explained where the course uses them.
  • Running commands in a terminal
  • Having used an AI chat assistant or a coding agent as a user; no experience of programming with language models is needed

To build it on your own machine

This is optional and comes with a plan. The course pack brings the starting files, a ready container and a check for every lesson. You need only Docker and git, plus your own AI coding agent if you want a tutor.

What you learn

Write the server once, and every AI app that speaks the protocol can use it

You build one small MCP server in Python: a task tracker an AI assistant can read and change. It starts as a single tool you call by hand and grows tools that add and complete tasks, input checks, errors a model can recover from, resources and a prompt. Every step is checked with no model involved, first with the Inspector and then by tests that call the server through a real client, and at the end you connect it to a real host and watch a model use it.

  • The Protocol and Its Roles. What MCP is for, who the host, the client and the server are, and the exchange in which a client first discovers what a server offers and then calls it.
  • Tools a Model Calls Correctly. A model sees only a name, a description and a schema. Typed parameters, constraints, structured results and errors it can read decide whether it uses a tool well.
  • Resources and Prompts. The two other things a server offers: data the application chooses to read, and message templates the user chooses to run, and how to pick between the three.
  • Tested, Then Connected. A server is ordinary code: you test it with a client and fixed arguments, then give a host its launch command and let a model drive it over stdio.

Lessons

Where it fits

Course 6 of 8 on the AI Engineer path.

How our courses are made Report a mistake