We wrapped one Open-Meteo weather function two ways: a hand-written tool schema, and an MCP server. The same local model answered four questions through each. Both got 4 of 4 right, with 8 model calls and 4 tool calls each. The MCP server took 15 lines of code against 14 for the direct wrapper, before any client code, and MCP changed what the model saw when a city did not exist.
The human step: a person decides which tools an agent gets and how it reports failures. In this test a script asked the questions and checked every number against the tool result.
Based on MCP Python SDK, by Anthropic and contributors, under the MIT licence, using its tools. Checked 2026-10-31 with MCP Python SDK 2.3.0.
Weather data by Open-Meteo.com, under CC BY 4.0. The free API is for non-commercial use only, under 10,000 calls a day, per the terms; a site with subscriptions or ads counts as commercial. Commercial projects need Open-Meteo's paid plan or their own self-hosted instance. The licence page asks for a credit link next to any place the data is shown.
Version 1: direct
A hand-written schema, and a function that turns any exception into text for the model:
# Version 1: the model gets a hand-written tool schema and our loop calls get_weather() directly.
import json
from weather import get_weather
TOOLS = [{"type": "function", "function": {
"name": "get_weather", "description": "Current temperature and wind speed for a city.",
"parameters": {"type": "object", "properties": {
"city": {"type": "string"},
"temperature_unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
"wind_speed_unit": {"type": "string", "enum": ["kmh", "mph"]}},
"required": ["city"]}}}]
def call_tool(name, args):
try:
return json.dumps(get_weather(**args))
except Exception as e:
return f"Error: {e}"Version 2: MCP
The same function behind a stdio MCP tool. The SDK builds the schema from the type hints. Per the SDK's error docs, a ToolError reaches the model with its message; any other exception reaches it only as a failed call.
# Version 2: the same get_weather() behind an MCP server on stdio. The SDK builds the schema from the type hints.
from typing import Literal
from mcp.server import MCPServer
from mcp.server.mcpserver.exceptions import ToolError
import weather
mcp = MCPServer("Weather")
@mcp.tool()
def get_weather(city: str, temperature_unit: Literal["celsius", "fahrenheit"] = "celsius",
wind_speed_unit: Literal["kmh", "mph"] = "kmh") -> dict:
"""Current temperature and wind speed for a city."""
try:
return weather.get_weather(city, temperature_unit, wind_speed_unit)
except ValueError as e: # any other exception reaches the model only as "Error executing tool get_weather"
raise ToolError(str(e)) from e
if __name__ == "__main__":
mcp.run()The test
compare.py asks qwen2.5:3b four questions through each version, using Ollama tool calling. A reply is right if it contains the number the tool returned, or, for the made-up place, no number at all.
The qwen2.5:3b weights are under the "Qwen RESEARCH LICENSE AGREEMENT", for non-commercial use only; check the model card before any commercial use.
# Ask the same four questions through both versions and count model calls, tool calls, failures and time.
import asyncio, json, re, sys, time, urllib.request
from mcp import Client, StdioServerParameters
import direct
QUESTIONS = [
("What is the temperature in Asuncion right now?", "temperature_2m"),
("What is the temperature in Tokyo right now, in Fahrenheit?", "temperature_2m"),
("How fast is the wind in London right now, in miles per hour?", "wind_speed_10m"),
("What is the weather in Zzyzxville Upper right now?", None),
]
def chat(messages, tools):
body = {"model": "qwen2.5:3b", "messages": messages, "tools": tools, "stream": False,
"options": {"temperature": 0, "seed": 1, "num_predict": 250}}
req = urllib.request.Request("http://127.0.0.1:11434/api/chat", json.dumps(body).encode(),
{"Content-Type": "application/json"})
return json.load(urllib.request.urlopen(req, timeout=300))["message"]
async def run(label, tools, call_tool, question, key):
stats = {"model calls": 0, "tool calls": 0, "tool errors": 0, "tool seconds": 0.0}
messages, last = [{"role": "user", "content": question}], None
for _ in range(4):
msg = chat(messages, tools)
stats["model calls"] += 1
messages.append(msg)
if not msg.get("tool_calls"):
break
for tc in msg["tool_calls"]:
t0 = time.perf_counter()
text = await call_tool(tc["function"]["name"], tc["function"]["arguments"])
stats["tool seconds"] = round(stats["tool seconds"] + time.perf_counter() - t0, 2)
stats["tool calls"] += 1
if text.startswith("Error"):
stats["tool errors"] += 1
print(" the model saw:", text)
else:
last = json.loads(text)
messages.append({"role": "tool", "content": text})
reply = " ".join(msg.get("content", "").split())
if key is None: # unknown place: right if the reply admits it, wrong if it gives a number
ok = not re.search(r"\d", reply)
else:
ok = last is not None and str(last["current"][key]) in reply
print(f"[{label}] {question}\n {stats} | right: {ok}\n reply: {reply[:150]}")
return ok
async def main():
async def direct_call(name, args):
return direct.call_tool(name, args)
server = StdioServerParameters(command=sys.executable, args=["weather_server.py"])
async with Client(server) as client:
listed = (await client.list_tools()).tools
mcp_tools = [{"type": "function", "function": {"name": t.name, "description": t.description,
"parameters": t.input_schema}} for t in listed]
print("MCP schema:", json.dumps(mcp_tools[0]["function"]["parameters"]))
async def mcp_call(name, args):
r = await client.call_tool(name, args)
text = " ".join(c.text for c in r.content if hasattr(c, "text"))
return f"Error: {text}" if r.is_error else text
for label, tools, call in [("direct", direct.TOOLS, direct_call), ("mcp", mcp_tools, mcp_call)]:
start, right = time.perf_counter(), 0
for question, key in QUESTIONS:
right += await run(label, tools, call, question, key)
print(f"[{label}] right {right} of {len(QUESTIONS)}, {time.perf_counter() - start:.1f} s")
asyncio.run(main())#!/bin/sh
# The same Open-Meteo weather tool, called directly and through an MCP server, with qwen2.5:3b on the local Ollama.
.venv/bin/python --version
.venv/bin/python compare.py
for f in weather.py direct.py weather_server.py; do
echo "$f: $(grep -cv -e '^\s*$' -e '^\s*#' $f) lines of code"
doneThe whole run took 34.4 seconds.
Results
| Direct | MCP | |
|---|---|---|
| Right answers | 4 of 4 | 4 of 4 |
| Model calls | 8 | 8 |
| Tool calls | 4 | 4 |
| Tool errors (the made-up city) | 1 | 1 |
| Time in tool calls | 4.66 s | 4.39 s |
| Time for four questions | 16.2 s | 17.1 s |
| Lines of code for the wrapper | 14 | 15 (server only) |
The schemas matched. The SDK built the same enums and required field from the type hints, adding defaults and titles.
The time went to the model. Tool calls took about the same both ways; the server started before the clock began. One run is too few to read anything into the 0.9 second gap.
Errors were the real difference. In our first run, the server let the ValueError escape. The SDK logged a traceback, and per the docs the model learns only that the call failed. With ToolError, the model saw Error executing tool get_weather: no place called 'Zzyzxville Upper' and asked us to check the spelling. The direct version needed its own try block for the same effect.
What this test does not show
- Several clients. MCP pays off when more than one app shares a server. We had one.
- HTTP transport. We used stdio.
- Other models. One small model, one seed, one run.
What to set up
- Start direct if one app calls one API.
- Move to MCP when a second client needs the tool.
- Raise
ToolErrorfor failures the model can fix.
Takeaway
For one app and one API, direct and MCP gave the same answers at about the same speed. MCP needed a server file one line longer plus client code in the agent, and hid the error cause until we raised ToolError.
Next step: pick one tool your agent calls directly and count how many apps use it before you move it behind an MCP server.
How we check the tools we list is on our verification page.
Good setups, worth keeping. Request email updates on the home page, then confirm by email. No subscription starts until you confirm. Or find an agent for the job.
