Skip to main content
Glama
weather-china-mcp

weather-china-mcp

by killerfirst

🌤 Weather China MCP Server

A Model Context Protocol (MCP) server that provides real-time weather and 3-day forecast for Chinese cities, powered by QWeather (å’Œé£Žå¤©ę°”) API.

Inspiration: This project is a learning exercise by the author, inspired by the MCP server weather tutorial on modelcontextprotocol.io — which demonstrated building a US weather MCP server. This is the Chinese weather counterpart, adapted for the QWeather API.


✨ Features

  • Real-time weather — temperature, feels-like, humidity, wind, visibility, and more

  • 3-day forecast — daily high/low, day/night weather, humidity, wind

  • MCP-native — works with any MCP-compatible client (Claude Code, Codex, OpenClaw, etc.)

  • Secure — API credentials stored in .env, never committed to Git

Related MCP server: AMap Weather MCP

šŸ“‹ Prerequisites

Requirement

Description

Python

≄ 3.11

uv

Python package manager (install)

QWeather Account

Free tier: 1,000 calls/day. Register at console.qweather.com

After registering on QWeather Console:

  1. Create a project → get your API Key

  2. Go to Settings → copy your dedicated API Host (format: xxx.xxx.qweatherapi.com)

šŸš€ Quick Start

# 1. Clone the repo
git clone <your-repo-url>
cd weather-china

# 2. Set up environment variables
cp .env.example .env
# Edit .env and fill in your QWeather API Key & API Host

# 3. Install dependencies
uv sync

# 4. Run the server (for testing)
uv run weather.py

šŸ”§ MCP Client Configuration

Claude Code

Add to .mcp.json in your project root (or ~/.claude/mcp.json for global):

{
  "mcpServers": {
    "weather-china": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/weather-china",
        "run",
        "weather.py"
      ]
    }
  }
}

Restart Claude Code or run /mcp reload to pick up the change.

Codex (OpenAI)

In Codex, open Settings → MCP Servers → Add:

{
  "mcpServers": {
    "weather-china": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/weather-china",
        "run",
        "weather.py"
      ]
    }
  }
}

OpenClaw

Add to your OpenClaw MCP configuration file:

mcp_servers:
  weather-china:
    command: uv
    args:
      - --directory
      - /path/to/weather-china
      - run
      - weather.py

Other MCP Clients (Generic stdio)

Any MCP client that supports stdio transport:

{
  "mcpServers": {
    "weather-china": {
      "command": "uv",
      "args": ["--directory", "/path/to/weather-china", "run", "weather.py"],
      "env": {
        "QWEATHER_API_KEY": "<your-api-key>",
        "QWEATHER_API_HOST": "<your-api-host>"
      }
    }
  }
}

Note: If your client doesn't inherit shell environment variables, pass QWEATHER_API_KEY and QWEATHER_API_HOST via the env field as shown above. When using .env file, the server loads them automatically.

šŸ›  Available Tools

get_weather

Get real-time weather for a Chinese city.

Parameters:
  city: string — City name (e.g., "åŒ—äŗ¬", "上海", "å¹æå·ž")

get_forecast

Get 3-day weather forecast for a Chinese city.

Parameters:
  city: string — City name (e.g., "åŒ—äŗ¬", "上海", "å¹æå·ž")

šŸ“ Project Structure

weather-china/
ā”œā”€ā”€ weather.py          # MCP server — main entry point
ā”œā”€ā”€ main.py             # Placeholder entry
ā”œā”€ā”€ .env.example        # Environment variable template
ā”œā”€ā”€ .env                # Your credentials (gitignored)
ā”œā”€ā”€ .gitignore
ā”œā”€ā”€ .mcp.json           # Claude Code MCP config (example)
ā”œā”€ā”€ pyproject.toml      # Python project metadata & dependencies
ā”œā”€ā”€ uv.lock             # Dependency lock file
ā”œā”€ā”€ README.md           # English readme
└── README.zh.md        # Chinese readme

šŸ”’ Security

  • .env is listed in .gitignore — never commit your API credentials

  • .env.example provides a template for others to set up their own credentials

  • Both QWEATHER_API_KEY and QWEATHER_API_HOST are read from environment variables, not hardcoded

šŸ“„ License

MIT

Available Tools

2 tools
get_forecastA

čŽ·å–äø­å›½åŸŽåø‚ęœŖę„3å¤©ēš„å¤©ę°”é¢„ęŠ„

Args:
    city: åŸŽåø‚åē§°ļ¼Œä¾‹å¦‚"åŒ—äŗ¬"态"上海"态"å¹æå·ž"

Inputs: city (required). Returns: result

get_weatherA

čŽ·å–äø­å›½åŸŽåø‚ēš„å®žę—¶å¤©ę°” Get weather for chinese city

Args:
city:åŸŽåø‚åē§°,例如"åŒ—äŗ¬","上海","å¹æå·ž" 

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

    A3.7/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools are clearly distinct: one provides real-time current weather, the other provides a 3-day forecast. There is no overlap or ambiguity in their purposes.

    Naming Consistency5/5

    Both tools follow the exact same verb_noun pattern (get_weather, get_forecast), using consistent snake_case and a clear 'get_' prefix.

    Tool Count3/5

    With only 2 tools, the server feels thin for a weather service, but it is functional for basic real-time and forecast queries. This falls on the borderline low end.

    Completeness3/5

    The core weather operations (current conditions and forecast) are covered, but gaps exist for additional useful features like air quality, historical data, or location suggestions, which agents might expect from a comprehensive weather server.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that provides real-time weather information, 4-day forecasts, and city search functionality for Chinese cities via the AMap API. It enables users to query weather data using city names or administrative codes through natural language interactions.
      1
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      An MCP server integrated with the QWeather API that provides real-time weather forecasts and meteorological warnings for AI assistants. It enables users to query current conditions and disaster alerts for specific cities or coordinates.
      34 npm
      -