Skip to main content
Glama
Weather MCP Server

Weather MCP Server

by mailmirza

Weather MCP Server

A small, beginner-friendly Model Context Protocol (MCP) server built with FastMCP that lets an AI assistant look up current weather. It is meant as a first server to read and modify: the common building blocks fit in about 100 lines.

What it demonstrates

  • Tools with typed parameters and defaults: get_weather(latitude, longitude, unit="celsius"), plus two trivial ones, add and get_word_count

  • Input validation and clear errors (bad coordinates, bad unit, upstream timeout)

  • A resource (config://server-info) and a prompt (weather_report)

  • Optional GitHub OAuth (docs/auth.md), and a shared bearer token pattern

  • Running locally over stdio, or over the network over HTTP (docs/deployment.md)

Weather data comes from Open-Meteo, which needs no API key.

Quick start

git clone https://github.com/mailmirza/weather-mcp-server.git
cd weather-mcp-server
python -m venv venv
source venv/bin/activate         # Windows PowerShell: .\venv\Scripts\Activate.ps1
pip install -r requirements.txt
python server.py                 # stdio mode: it waits for an MCP client

Test it with the MCP Inspector. Let the Inspector launch the server, and do not type into the server's own terminal:

npx @modelcontextprotocol/inspector python server.py

Related MCP server: MCP Weather Server

Use it from an MCP client

Local (stdio). For Claude Desktop, add this to claude_desktop_config.json (use full paths; on Windows use venv\\Scripts\\python.exe with double backslashes):

{
  "mcpServers": {
    "weather": {
      "command": "/full/path/to/venv/bin/python",
      "args": ["/full/path/to/weather-mcp-server/server.py"]
    }
  }
}

Over the network (HTTP). Run with MCP_TRANSPORT=http. Claude's custom connector dialog expects an https:// URL, so put the server behind a reverse proxy with a certificate. See docs/deployment.md.

Example prompts once it is connected:

  • "Use the weather connector's get_weather tool for latitude 25.2048, longitude 55.2708."

  • "Same place, in fahrenheit."

  • "Use the weather connector to compare the current temperature in Dubai and London."

Naming the connector matters: if your AI app has its own built-in weather feature, it may use that instead.

Configuration

Variable

Meaning

MCP_TRANSPORT

stdio (default) or http

MCP_HOST

Bind address for HTTP, default 127.0.0.1. Use 0.0.0.0 only behind a proxy or firewall

MCP_PORT

HTTP port, default 8000

GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, MCP_BASE_URL

Turn on GitHub OAuth, see docs/auth.md

Lessons learned

  1. stdio and print() do not mix. In stdio mode stdout carries the protocol. Print to sys.stderr (or use logging), and never type into the terminal of a running stdio server.

  2. Docstrings are instructions. FastMCP turns a tool's docstring and type hints into the schema the model reads. Say valid ranges and units there.

  3. The host may prefer its own tool. Name the connector in your prompt.

  4. Client support varies. When this was written (August 2026), Claude Desktop used the tools from a connector but did not surface its prompts or resources in chat. MCP Inspector shows all three.

  5. Auth options depend on the client. A static bearer token works with Inspector, but Claude Desktop's connector dialog offered only OAuth client ID and secret fields. See docs/auth.md.

  6. Windows notes. The command is python, not python3. A new PATH needs a new terminal. If Activate.ps1 is blocked, run Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned.

Attribution

Weather data by Open-Meteo.com, licensed CC BY 4.0. Their free API is meant for non-commercial use, so check their terms before building on it.

License

MIT

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      A simple server that implements the Model Context Protocol, allowing AI models like Claude to fetch real-time weather information for any location using the wttr.in API.
      4
      1
      ISC
    • A
      license
      B
      quality
      F
      maintenance
      A simple Model Context Protocol server that provides real-time weather data to AI agents like GitHub Copilot, allowing users to get current weather information for any city through natural language queries.
      2
      97
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables users to check weather conditions using Open-Meteo's free API with GitHub OAuth authentication and personalized location management. Users can save custom location labels (like 'home' or 'office') and query weather using these convenient shortcuts.
      11
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A lightweight Model Context Protocol (MCP) server that gives AI assistants the ability to fetch real-time weather data for any city using the OpenWeatherMap API.
      1
      -