Build an MCP Server (Official Tutorial)
by Model Context Protocol
Build your first MCP server and connect it to Claude.
Overview
This official modelcontextprotocol.io tutorial walks you through building a simple MCP weather server that exposes two tools, get_alerts and get_forecast, and connecting it to an MCP host such as Claude for Desktop. It introduces the three core server capabilities (Resources, Tools, and Prompts) while focusing on tools, and provides language-specific tracks (Python, and others) with setup using Python 3.10+ and the uv package manager, initializing a server with FastMCP, defining tools with the @mcp.tool() decorator, and connecting over stdio transport. It also covers practical gotchas like never writing to stdout in stdio servers (which would corrupt JSON-RPC messages) and how to test your server from a real host, with links to the complete example code.
At a Glance
- Topic
- MCP
- Level
- Beginner
- Format
- Tutorial
- Cost
- Free
- Duration
- ~30 min, hands-on
- Provider
- Model Context Protocol
- Hands-on
- Yes — code/exercises
- Certificate
- None
What You’ll Learn
- ✓Scaffolding an MCP server with the SDK and uv
- ✓Defining tools with decorators and stdio transport
- ✓Connecting your server to Claude for Desktop
- ✓Avoiding common pitfalls like stdout corruption in stdio servers
Highlights
- •The canonical, official first MCP project
- •Complete runnable example code provided
- •Multiple language tracks
Who It’s For
Best For
- ✓First-time MCP server builders
- ✓Developers wanting a quick, authoritative walkthrough
Prerequisites
- •Basic Python (or the chosen language)
- •Familiarity with LLMs like Claude
FAQ
What is Build an MCP Server (Official Tutorial)?
The official step-by-step tutorial for building a simple MCP weather server and connecting it to a host like Claude for Desktop. The canonical first hands-on project for MCP newcomers.
Is Build an MCP Server (Official Tutorial) free?
Build an MCP Server (Official Tutorial) is free to access.
What level is Build an MCP Server (Official Tutorial) for?
Build an MCP Server (Official Tutorial) is aimed at a beginner audience. Recommended background: Basic Python (or the chosen language), Familiarity with LLMs like Claude.
How long does Build an MCP Server (Official Tutorial) take?
Expect roughly ~30 min, hands-on. Most learners work through it at their own pace.
What will I learn from Build an MCP Server (Official Tutorial)?
You'll learn: Scaffolding an MCP server with the SDK and uv; Defining tools with decorators and stdio transport; Connecting your server to Claude for Desktop; Avoiding common pitfalls like stdout corruption in stdio servers.