Build an MCP Server (Official Tutorial)
by Model Context Protocol
Build a working MCP weather server and connect it to a real host, in your language.
Overview
The official Model Context Protocol quickstart walks you from an empty directory to a working MCP server connected to Claude for Desktop. The worked example is a weather server exposing two tools, get_alerts and get_forecast, backed by the US National Weather Service API — small enough to finish in one sitting, real enough that the tools return live data. The page opens by naming the three server capability types MCP defines, resources, tools and prompts, and states plainly that this tutorial focuses on tools. From there the content is tabbed across eight languages — Python, TypeScript, Java, Kotlin, C#, Ruby, Rust and Go — each with its own prerequisite list, environment setup, SDK install, complete server source and host configuration steps. A shared section on logging in MCP servers covers the stdio transport rule that trips up nearly every first server: anything written to stdout corrupts the JSON-RPC stream, so logs must go to stderr. The tutorial closes with a command-level test pass, a 'What's happening under the hood' explanation of how a request travels between host, client and server, a troubleshooting section for Claude Desktop config and server startup failures, and next steps toward building a client. Complete runnable code lives in the separate modelcontextprotocol/quickstart-resources repository, which carries weather servers and matching clients in Python, TypeScript, Go, Rust and Ruby.
At a Glance
- Topic
- MCP
- Level
- Beginner
- Format
- Tutorial
- Cost
- Free
- Duration
- ~45-60 minutes, self-paced
- Provider
- Model Context Protocol
- Hands-on
- Yes — code/exercises
- Certificate
- None
What You’ll Learn
- ✓Scaffold an MCP server project and install the SDK for your language
- ✓Define tools with typed arguments and descriptions the model can read
- ✓Call an external HTTP API inside a tool and format the result
- ✓Register your server with Claude for Desktop through its JSON config
- ✓Keep logs on stderr so stdio JSON-RPC framing is not corrupted
- ✓Trace the request flow between host, client and server when a tool fires
- ✓Debug a server that never appears or fails to start in the host
Highlights
- •Eight language tabs — Python, TypeScript, Java, Kotlin, C#, Ruby, Rust and Go — from one canonical tutorial
- •Maintained alongside the protocol spec itself, so it tracks spec revisions instead of lagging them
- •Complete code lives in a separate runnable repo (modelcontextprotocol/quickstart-resources, 1.2k stars), not as fragments in prose
- •Deliberately scoped to tools rather than cramming resources and prompts into the same pass
- •Honest about its own limits: the example repo says the samples are intentionally minimal and need auth, CORS allowlists and rate limiting before any network deployment
Who It’s For
Best For
- ✓Developers writing their first MCP server
- ✓Engineers deciding which MCP SDK to standardise on
- ✓Teams wiring an internal API into Claude Desktop or Claude Code
Prerequisites
- •Working knowledge of at least one of the eight covered languages
- •Familiarity with LLM chat applications such as Claude
- •A local dev environment plus an MCP host installed to test against
FAQ
What is Build an MCP Server (Official Tutorial)?
The canonical first MCP tutorial, maintained alongside the protocol specification itself. You build a weather server exposing two live tools and register it with Claude for Desktop, following tabs for any of eight languages. By the end you understand the host-client-server request flow, the stdio logging rule that breaks most first servers, and where to look when a server refuses to start.
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: Working knowledge of at least one of the eight covered languages, Familiarity with LLM chat applications such as Claude, A local dev environment plus an MCP host installed to test against.
How long does Build an MCP Server (Official Tutorial) take?
Expect roughly ~45-60 minutes, self-paced. Most learners work through it at their own pace.
What will I learn from Build an MCP Server (Official Tutorial)?
You'll learn: Scaffold an MCP server project and install the SDK for your language; Define tools with typed arguments and descriptions the model can read; Call an external HTTP API inside a tool and format the result; Register your server with Claude for Desktop through its JSON config; Keep logs on stderr so stdio JSON-RPC framing is not corrupted; Trace the request flow between host, client and server when a tool fires; Debug a server that never appears or fails to start in the host.
Topics
Sources
This page was written from 2 sources, 1 on domains other than modelcontextprotocol.io.