This quickstart builds a deliberately small server with one tool. The goal is a complete path from code to a client-visible tool, not a production architecture. Once it works, move to the Python or TypeScript tracks for schemas, transport, testing, and deployment.
1. Create the project
uv init weather-mcp
cd weather-mcp
uv add "mcp[cli]"
uv creates a virtual environment and lockfile. If you prefer pip, create a virtual environment and install mcp[cli] there instead. Pin the SDK version once you move beyond the quickstart; MCP revisions and SDK APIs change.
2. Write the server
Create server.py:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("weather-demo")
@mcp.tool()
def forecast(city: str) -> str:
"""Return a deterministic sample forecast for a city.
The data is intentionally fake. Replace this with a real API call
and keep credentials in environment variables.
"""
city = city.strip()
if not city:
raise ValueError("city must not be empty")
return f"{city}: 22C, clear (sample data)"
if __name__ == "__main__":
mcp.run()
Two details matter more than they look:
- The docstring becomes the tool description shown to the model. Write it for a reader who cannot see your code.
print()writes to stdout, which is the protocol stream for stdio transport. Use logging to stderr instead. This example avoids printing entirely.
3. Test it in MCP Inspector
uv run mcp dev server.py
Inspector opens a local UI where you can list tools, inspect the input schema, and invoke forecast. Try an empty string to see how the server reports the error. A tool that fails should return a clear message, not crash the process.
You can also test with a raw stdio client, but Inspector is faster for the first run.
4. Connect a coding client
For a project-scoped Claude Code configuration, add .mcp.json at the repository root:
{
"mcpServers": {
"weather-demo": {
"command": "uv",
"args": ["run", "--directory", "/absolute/path/to/weather-mcp", "server.py"]
}
}
}
Use an absolute path. GUI clients often do not inherit your shell’s working directory, and uv may not be on their PATH. If uv is not visible to the client, use its absolute path as the command. The Config Generator can produce the correct structure for Codex, Claude Code, Cursor, Windsurf, Cline, and VS Code.
For Codex, the equivalent TOML is:
[mcp_servers.weather-demo]
command = "uv"
args = ["run", "--directory", "/absolute/path/to/weather-mcp", "server.py"]
5. Verify the whole path
Do not stop at “the server starts.” Check the following:
- The client lists
weather-demowithout a connection error. - The tool inventory contains
forecast, with acitystring argument. - A normal call returns the sample forecast.
- An empty city produces a visible error.
- Restarting the client still finds the server.
If the server is missing, check the command and PATH first. If it appears and immediately disconnects, inspect stderr and confirm nothing is writing to stdout. The error guide for unexpected exits walks through that case.
6. Where to go next
- Add a real HTTP call with timeouts and typed results: Python Pydantic tools.
- Expose the server to remote clients: Python Streamable HTTP.
- Harden errors, limits, and logs before sharing it: Python production checklist.
The quickstart is intentionally not a production server. It has no authentication, no rate limiting, no cancellation handling, and fictional data. Those gaps are the curriculum, not an oversight.
Sources
Sources were checked on Oct 23, 2026. Versions and client behavior can change; confirm the current documentation before relying on a configuration.