Introduction to MCP
Independent educational resource, not an official Anthropic course. Facts about the API, prices and limits were checked against Anthropic's documentation on 15 November 2026 and the code was run against a local mock of the API, not the live service. Check the linked official pages before relying on a number, and test with your own key.
Every AI application that needs your data ends up writing the same glue: one connector for the database, another for the ticket system, another for files, each shaped differently for each app. The Model Context Protocol, MCP, is an open standard that tries to replace that pile with one shared way for AI applications to talk to tools and data. This lesson explains what it is, what it isn't, and runs the smallest possible example so the idea is concrete before the details arrive.
What you'll learn
- The problem MCP solves, and what it deliberately leaves out.
- The three roles: host, client and server.
- The three things a server can offer: tools, resources and prompts.
- A working server and client in under 40 lines, tested.
Before you start
You'll need Python 3.10 or newer. The examples were run with the Python MCP SDK 2.3.0; the official quickstart says to use version 2.0.0 or higher. If you've followed an older tutorial that imports FastMCP, the current quickstart imports MCPServer instead, so check which SDK version a tutorial was written for.
The problem
In Module 4 you wrote tool definitions and a function for each one, inside your own application. That works, but it means every application re-implements every integration. If you have three AI apps and four systems, that's up to twelve connectors, each with its own quirks. MCP's pitch is simple: write the integration once as an MCP server, and any application that speaks MCP can use it.
The documentation describes MCP as a protocol for exchanging context. Its architecture page is careful to add that MCP "does not dictate how AI applications use LLMs or manage the provided context." That sentence matters. MCP is the plumbing between an application and its sources of context and actions. It doesn't choose the model, write your prompts or decide what your agent does.
Three roles
- Host: the AI application the user is working in, such as Claude Code or Claude Desktop. It coordinates everything.
- Client: a component inside the host that holds one connection to one server. A host with three servers has three clients.
- Server: a program that offers context or actions. "Server" says nothing about where it runs. It can be a local process launched on your machine or a remote service on the internet.
┌──────────── host (e.g. Claude Code) ────────────┐
│ client 1 ──────────────► server A (files) │
│ client 2 ──────────────► server B (database) │
│ client 3 ──────────────► server C (remote) │
└──────────────────────────────────────────────────┘
What a server can offer
| Primitive | What it is | Who decides when it's used |
| Tools | Functions that do something: look up an order, create an event | The model |
| Resources | Data to read: a file, a schema, a record | The application |
| Prompts | Reusable templates a user can start | The user |
That last column is a design idea worth remembering. Tools are the part the model controls, which is why they carry the most risk. Resources and prompts are chosen by the application and the user. Lessons 7.4 and 7.5 take each in turn.
The smallest working example
Here is a complete server with one of each primitive, and a client that uses all three. The client connects in-process, which is handy for tests, so there's nothing to install except the SDK:
import asyncio
from mcp.server import MCPServer
from mcp.client import Client
mcp = MCPServer("demo")
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers."""
return a + b
@mcp.resource("shop://policies/returns")
def returns_policy() -> str:
"""Return policy text."""
return "30 days."
@mcp.prompt()
def review(order_id: str) -> str:
"""Review an order."""
return f"Review order {order_id}"
async def main():
async with Client(mcp) as c:
print([t.name for t in (await c.list_tools()).tools]) # ['add']
print((await c.call_tool("add", {"a": 2, "b": 3})).structured_content) # {'result': 5}
print([str(r.uri) for r in (await c.list_resources()).resources]) # ['shop://policies/returns']
print((await c.read_resource("shop://policies/returns")).contents[0].text) # 30 days.
print([p.name for p in (await c.list_prompts()).prompts]) # ['review']
print((await c.get_prompt("review", {"order_id": "A1"})).messages[0].content.text)
asyncio.run(main())
Install the SDK with pip install "mcp[cli]". The type hints and the docstring become the tool's schema and description, so you rarely write JSON Schema by hand. We ran this and the comments show what it printed.
Where Claude fits
Claude doesn't "speak MCP" by itself. An application does, and gives Claude the tools. Three common arrangements, covered in lesson 7.7:
- Claude Code and Claude Desktop are hosts. You point them at servers and Claude can use the tools.
- The Messages API connector lets the API itself connect to remote MCP servers on your behalf. It's in beta and supports tools only.
- Your own application can run an MCP client, list the server's tools, give them to Claude as normal tool definitions, and run the calls. That's the approach used in the project in lesson 7.10.
When MCP is the right choice, and when it isn't
MCP helps when an integration will be used by more than one application, when you want to use servers other people have built, or when you want a clean boundary between "the AI app" and "the system it reaches". For a single application with two private tools, an ordinary function behind an ordinary tool definition (Module 4) is simpler, and adding a protocol buys you little. Neither is more advanced; they fit different situations.
Real-world use case (illustrative scenario)
This scenario is an invented example to show how the ideas fit together. It is not a case study and its details are not measured results.
A small shop wants Claude to help with support. The team writes one MCP server that exposes order lookup and a refund-proposal tool. The same server is used by the support agent from Module 6, by a developer's Claude Code session when debugging an order problem and, later, by a different internal assistant. Each of those applications would have needed its own copy of the order integration without MCP. With MCP there is one place to fix a bug or tighten a permission.
Mistakes to avoid
- Adding MCP to a project that has one app and two simple tools.
- Following an older tutorial without checking the SDK version it targets.
- Treating a connected server as trusted. Any server you connect can put text in front of your model.
- Assuming MCP handles prompts, context windows or agent logic. It doesn't.
Security notes
An MCP server is code that runs with real access, and its tool descriptions and results go straight into your model's context. Only connect servers you trust, give each one the minimum access it needs, and keep a person in front of anything that changes data. Lesson 7.9 is devoted to this.
Cost and speed
MCP itself adds little. What costs tokens is the tool definitions your host sends to the model, and the results it receives back. A server with many tools, or one that returns long outputs, makes every request bigger. Connect only the servers you need.
Key takeaways
- MCP is an open protocol between AI applications (hosts, via clients) and servers that offer context and actions.
- Servers offer tools (model-controlled), resources (application-controlled) and prompts (user-controlled).
- It standardises the connection; it doesn't decide what your model or agent does.
- Use it when an integration is shared or reusable; skip it for one tiny private tool.
Lesson recap: one shared protocol, three roles, three primitives.
Quick quiz
- What are the three roles in MCP?
- Name the three things a server can offer.
- Which of those is controlled by the model?
- Does MCP choose which model your application uses?
- When would a plain tool definition be simpler than an MCP server?
Answers and explanations
- Host (the AI application), client (one connection to one server, inside the host) and server (the program offering context and actions).
- Tools, resources and prompts.
- Tools. The model decides when to call them. Resources are chosen by the application and prompts by the user.
- No. MCP only standardises how context and actions are exchanged; it leaves model use and context management to the application.
- When a single application uses a couple of private tools. A function behind an ordinary tool definition is less to build and maintain.
Official references and further reading
Related tutorials