Skip to main content
Glama
const5craciun

MCP Weather

MCP Weather

An MCP server that fetches real-time weather for any city — caching popular cities locally and falling back to a live Serper web search formatted by DeepSeek V4 Pro for everything else.

Architecture

                  ┌──────────────┐
  Claude / client │              │  MCP tool call
  ────────────────▶│  get_weather │──────────────┐
                  │  ("city")    │              │
                  └──────────────┘              │
                                                ▼
                                     ┌────────────────────┐
                                     │  models.WeatherInput│
                                     │  Pydantic validation │
                                     │  strip / reject junk │
                                     └────────┬───────────┘
                                              │
                                   ┌──────────▼──────────┐
                                   │   cache.get(city)    │
                                   │   case-insensitive   │
                                   └──────┬──────┬────────┘
                                     HIT  │      │  MISS
                                          │      │
                                          ▼      ▼
                              ┌──────────┐  ┌────────────────────┐
                              │  return  │  │ providers.lookup   │
                              │  summary │  │ _live(city)        │
                              └──────────┘  └────────┬───────────┘
                                                     │
                                          ┌──────────▼───────────┐
                                          │  Serper Google Search │
                                          │  "weather in {city}"  │
                                          │  (retries on failure) │
                                          └──────────┬───────────┘
                                                     │
                                          ┌──────────▼───────────┐
                                          │  DeepSeek V4 Pro      │
                                          │  JSON extraction      │
                                          │  (OpenRouter)         │
                                          └──────────┬───────────┘
                                                     │
                                          ┌──────────▼───────────┐
                                          │  WeatherData model    │
                                          │  structured response  │
                                          └──────────────────────┘

Related MCP server: Weather MCP Server

Quick start

1. Install

cd mcp_weather
uv sync

2. Set your API keys

Edit .env (or export the env vars):

# OpenRouter — used by DeepSeek V4 Pro to format search results
OPENROUTER_API_KEY="sk-or-v1-..."

# Serper — Google Search API (free tier at https://serper.dev)
SERPER_API_KEY="..."

3. Verify with the smoke test

uv run python tests/test_imports.py

4. Wire it into Claude Code

Add this to your claude_desktop_config.json or Claude Code MCP config:

{
  "mcpServers": {
    "weather": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/Users/konst/Documents/mcp_start/mcp_weather",
        "python",
        "-m",
        "mcp_weather"
      ]
    }
  }
}

Then restart Claude Code — get_weather will appear in your tool list.

Tool reference

get_weather(city: str) -> str

Returns a one-sentence weather summary for the requested city.

Behaviour

Description

Cache hit

12 major cities served instantly from an in-memory cache

Cache miss

Serper searches Google for current conditions; DeepSeek V4 Pro extracts structured data from the snippets. Retries on transient failures.

Validation

Pydantic rejects blank, "none", or "null" city names before any lookup

Cached cities: Copenhagen, London, New York, Tokyo, Paris, Sydney, Berlin, Dubai, Moscow, Rio de Janeiro, Mumbai, Cape Town.

Project layout

mcp_weather/
├── .env                        # API keys (git-ignored)
├── .gitignore
├── pyproject.toml              # uv project metadata + dependencies
├── README.md
├── src/
│   └── mcp_weather/
│       ├── __init__.py         # version
│       ├── __main__.py         # python -m entry-point
│       ├── config.py           # .env auto-discovery
│       ├── models.py           # Pydantic input / output schemas
│       ├── cache.py            # in-memory weather cache
│       ├── providers.py        # Serper search + DeepSeek formatting (with retries)
│       └── server.py           # MCP server definition + main()
└── tests/
    └── test_imports.py         # offline smoke test

Dependencies

Package

Purpose

mcp[cli]

MCP server framework

pydantic

Input validation & structured output

httpx

HTTP client for Serper API (with retries)

openai

OpenRouter client (DeepSeek V4 Pro)

polars

Fast DataFrames (available for data tasks)

python-dotenv

.env file loading

License

MIT

Available Tools

1 tool
get_weatherA

Get the current weather for a city.

Checks a local cache first. On a cache miss performs a live web search via Serper and formats the result with DeepSeek V4 Pro.

ParametersJSON Schema
NameRequiredDescriptionDefault
cityYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden, and it delivers: it discloses the cache-first behavior, the live web search via Serper on a miss, and the DeepSeek V4 Pro formatting. This is explicit about underlying mechanics and gives the agent a realistic mental model of the call.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two tightly written sentences: the first states the core purpose, the second reveals the processing pipeline. There is zero filler, and the most important information is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

This is a simple one-parameter tool with an output schema present, so return-value explanation is not required. The description covers the cache/search/format pipeline completely. The only notable gap is the ambiguous 'city' parameter format, which slightly reduces completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% – the schema only defines 'city' as a string with no format constraint. The description merely repeats 'for a city' and does not clarify format (e.g., 'London' vs 'London, UK'), case sensitivity, or acceptable values, so it fails to compensate for the schema's silence.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Get the current weather for a city.' This unambiguously states what the tool does, and even without sibling tools, the purpose is immediately clear to an agent.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There are no sibling tools, so no alternative-routing guidance is needed. The description provides clear context for when to use the tool (current weather retrieval) and implies an exclusion of forecasts through the word 'current', but it does not explicitly state when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev1.0.0
    • First observedget_weather

TDQS

A4/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of confusion or overlap. The tool's purpose is clearly defined as retrieving current weather for a city.

Naming Consistency4/5

The single tool name 'get_weather' follows a clear verb_noun pattern. While there are no other tools to compare against, the naming is predictable and conventional.

Tool Count2/5

A single tool for a weather server is extremely thin. Users would expect at least a forecast tool, and possibly historical data or location-based lookup, making the count feel inadequate for the domain.

Completeness2/5

The server only provides current weather, leaving obvious gaps such as forecasts, historical weather, or multi-day outlooks. Agents needing basic weather workflows will hit dead ends quickly.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables users to get real-time weather information for any city in the world. Provides current temperature and weather conditions through a simple city name query.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides real-time and historical weather data for any city worldwide, including forecasts, air quality, and marine conditions, using the free Open-Meteo API.
    5 npm
    MIT