Skip to main content
Glama
MCP Weather

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: SteadyFetch

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.

Inputs: city (required). Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    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.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Unified real-time search engine skill for AI agents.
      2,062
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides AI agents with reliable web fetching capabilities, handling retries, caching, and anti-bot bypass automatically.
      MIT
    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables AI assistants to run real-time searches across Google, Bing, Yahoo, DuckDuckGo, YouTube, eBay and other engines, returning results such as answer boxes, news, images, shopping, weather and stock data. Responses are automatically detected and formatted as structured JSON or token-saving Markdown, with optional interactive UI tools for tabular and dashboard views.
      -