weather-china-mcp

weather-china-mcp

Provides real-time weather and 3-day forecast for Chinese cities using the QWeather API, working with any MCP-compatible client.

Category
Visit Server

README

🌀 Weather China MCP Server

<p align="center"> <a href="README.zh.md">πŸ‡¨πŸ‡³ δΈ­ζ–‡</a> Β |Β  <b>πŸ‡ΊπŸ‡Έ English</b> </p>

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

πŸ“‹ 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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured