After this lesson, you will be able to: Understand the Model Context Protocol (MCP), build an MCP server that exposes tools, and connect an LLM to real external systems via MCP.
MCP is the open protocol Anthropic published to standardise how agents talk to tools. Instead of writing custom tool wrappers per framework, you build an MCP server once, and any compatible client (Claude Desktop, Claude Code, Cursor, custom Python) can use it. This lesson builds and connects to one.
Before MCP: every framework had its own tool format. Want your CRM available as a tool in 5 frameworks? Write 5 wrappers. After MCP: you write one MCP server. It exposes tools, resources, and prompts via a standard JSON-RPC protocol. Any MCP-aware agent can plug in.
1. `pip install mcp` (Python SDK).
2. We'll build a tiny server that exposes one tool: `get_user_by_id`.
3. Then connect Claude Desktop (or write a Python client) and call it.
Exposes one tool over stdio.
from mcp.server.fastmcp import FastMCPmcp = FastMCP('demo-server')USERS = {1: {'name': 'Alex', 'role': 'student'}, 2: {'name': 'Jordan', 'role': 'tutor'}}@mcp.tool()def get_user_by_id(user_id: int) -> dict:"""Return user record by ID."""return USERS.get(user_id, {'error': 'not found'})@mcp.resource('users://list')def list_users() -> str:return str(list(USERS.values()))if __name__ == '__main__':mcp.run(transport='stdio')
1. Save the file as `server.py`.
2. Open Claude Desktop config (Settings → Developer → Edit Config).
3. Add: `{ "mcpServers": { "demo": { "command": "python", "args": ["/abs/path/to/server.py"] } } }`
4. Restart Claude Desktop. Look for the 🔌 plug icon, your tool should appear.
5. Ask Claude: 'Get user 1.', it calls your tool.
Real MCP servers wrap GitHub, Postgres, Slack, internal APIs. The Anthropic-built ones are open source, read them as reference. The killer use case: build one MCP server for your company's internal data → every agent + IDE in the company can use it without per-tool integration work.
Sign in and purchase access to unlock this lesson.