mcp-test
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-test What's the current temperature in Tokyo?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-test — learning the Model Context Protocol
A minimal MCP server in Python: one tool that returns the current temperature for a city. Plus a client that calls it, so you can see both halves of the protocol as plain Python.
No API key required — it uses Open-Meteo, which is free and needs no signup.
server.py the MCP server — one tool, get_temperature
test_client.py a real MCP client that launches the server over stdioRun it
Requires uv and Python 3.12+.
uv run test_client.pyThat launches server.py as a subprocess, connects over stdio, and walks through
four things: tool discovery, a successful call, a recoverable error, and schema
validation rejecting a bad argument.
Related MCP server: MCP Weather Server Demo
⚠️ This uses SDK v2, not v1
The MCP Python SDK is at v2.x, a major rework. Most tutorials online are v1 and will not run against it:
v1 (most tutorials) | v2 (this repo) |
|
|
|
|
|
|
What the code demonstrates
The three primitives, split by who decides to use them: tools (the model decides), resources (the application decides), prompts (the user decides). This server exposes a tool, because "get the temperature" is a model-driven action.
Your function is the contract. From
async def get_temperature(city: str) -> Temperature, the SDK derives the tool name,
the description (from the docstring), the input schema (from the type hints), and the
output schema (from the return annotation). No JSON Schema is written by hand — and
the type hints are enforced, so a client sending city=42 is rejected before the
function runs.
Two results, two audiences. Every call returns content (text the model reads)
and structured_content (typed data the application reads). Returning a Pydantic
model rather than a string is what makes the second one useful.
Errors: raise, never return. A ToolError comes back with is_error=True and
your message where the model can read it, so the model can retry. A returned error
string has is_error=False — the model would read it as the answer.
stdio means stdout is the wire. The client launches the server as a subprocess and
speaks JSON-RPC over its stdin/stdout, so a stray print() in a server corrupts the
protocol stream. Use logging, which writes to stderr.
Try it in the MCP Inspector
A browser UI over your server, showing the raw protocol messages (needs npx):
uv run mcp dev server.pyConnect it to Claude Code
claude mcp add weather -- uv run --directory "$PWD" server.pyAvailable Tools
1 toolget_temperatureA
Get the current air temperature for a city, by name.
Inputs: city (required). Returns: The current temperature at a place.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 1 tool
Only one tool exists, so there is no possibility of overlapping purposes or misselection. The single get_temperature action is completely unambiguous.
The one tool uses a clear get_ + noun naming convention. There are no competing conventions or mixed styles to create inconsistency.
A single tool is on the 'too few' end of the scale, making the server feel like a minimal stub rather than a useful service. Unless the intended purpose is literally only a current temperature lookup, this is insufficient.
For a temperature/weather-related domain, the surface lacks related operations such as unit selection, forecast, geocoding, or validation. The single lookup creates a dead end and leaves obvious gaps for broader temperature use cases.
Related MCP Connectors
Current temperature for a city via Open-Meteo. Query discarded after the call.
Weather MCP — wraps Open-Meteo API (free, no auth)
Unofficial OpenWeather MCP — wraps the OpenWeatherMap API (openweathermap.org)
Unofficial Climate MCP — wraps Open-Meteo Climate API (free, no auth)
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides real-time weather information for any city worldwide using the Open-Meteo API, returning current temperature, wind speed, and geographic coordinates through a containerized MCP server.-
- AlicenseNot gradedqualityDmaintenanceFetches current weather information for any city using the Open-Meteo API through a simple MCP tool interface.MIT
- AlicenseNot gradedqualityDmaintenanceEnables fetching current temperature for any city using the Open-Meteo API, requiring no API key.ISC
- AlicenseAqualityDmaintenanceMCP server that provides current weather for any city using Open-Meteo APIs. It exposes a single tool 'get_weather' returning temperature, humidity, wind, and other weather data.19 npmMIT