What we’ll be building
We’ll build a server that exposes two tools:get_alerts and get_forecast. Then we’ll connect the server to an MCP host (in this case, Claude for Desktop):

Servers can connect to any client. We’ve chosen Claude for Desktop here for simplicity, but we also have a guide on building your own client.
Core MCP Concepts
MCP servers can provide three main types of capabilities:- Resources: File-like data that can be read by clients (like API responses or file contents)
- Tools: Functions that can be called by the LLM (with user approval)
- Prompts: Pre-written templates that help users accomplish specific tasks
- Python
- TypeScript
- Java
- Kotlin
- C#
- Ruby
- Rust
- Go
Let’s get started with building our weather server! You can find the complete code for what we’ll be building here.Make sure to restart your terminal afterwards to ensure that the Now let’s dive into building your server.Your server is complete! Run You’ll then add your servers in the This tells Claude for Desktop:
Prerequisite knowledge
This quickstart assumes you have familiarity with:- Python
- LLMs like Claude
Logging in MCP Servers
When implementing MCP servers, be careful about how you handle logging:For STDIO-based servers: Never write to stdout. Writing to stdout will corrupt the JSON-RPC messages and break your server. Theprint() function writes to stdout by default, so keep it out of a STDIO server entirely.For HTTP-based servers: Standard output logging is fine since it doesn’t interfere with HTTP responses.Best Practices
- Use the standard library
loggingmodule, which writes to stderr. - Create one logger per module with
logging.getLogger(__name__)and call it from your tools.
Quick Examples
System requirements
- Python 3.10 or higher installed.
- You must use the Python MCP SDK 2.0.0 or higher.
Set up your environment
First, let’s installuv and set up our Python project and environment:uv command gets picked up.Now, let’s create and set up our project:Building your server
Importing packages and setting up the instance
Add these to the top of yourweather.py:httpx2 is the HTTP client the SDK itself depends on, so installing mcp already brought it in.The MCPServer class uses Python type hints and docstrings to automatically generate tool definitions, making it easy to create and maintain MCP tools.Helper functions
Next, let’s add our helper functions for querying and formatting the data from the National Weather Service API:Implementing tool execution
The tool execution handler is responsible for actually executing the logic of each tool. Let’s add it:Running the server
Finally, let’s initialize and run the server:uv run weather.py to start the MCP server, which will listen for messages from MCP hosts.Let’s now test your server from an existing MCP host, Claude for Desktop.Testing your server with Claude for Desktop
First, make sure you have Claude for Desktop installed. You can install the latest version here. If you already have Claude for Desktop, make sure it’s updated to the latest version.We’ll need to configure Claude for Desktop for whichever MCP servers you want to use. To do this, open your Claude for Desktop App configuration at~/Library/Application Support/Claude/claude_desktop_config.json in a text editor. Make sure to create the file if it doesn’t exist.For example, if you have VS Code installed:mcpServers key. The MCP UI elements will only show up in Claude for Desktop if at least one server is properly configured.In this case, we’ll add our single weather server like so:Make sure you pass in the absolute path to your server. You can get this by running
pwd on macOS/Linux or cd on Windows Command Prompt. On Windows, remember to use double backslashes (\\) or forward slashes (/) in the JSON path.- There’s an MCP server named “weather”
- To launch it by running
uv --directory /ABSOLUTE/PATH/TO/PARENT/FOLDER/weather run weather.py