home / mcp / xinzhi weather mcp server

Xinzhi Weather MCP Server

Provides real-time weather data by querying Xinzhi Weather API for MCP clients.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "508364-xinzhi-weather-mcp": {
      "command": "python",
      "args": [
        "server.py"
      ],
      "env": {
        "PYTHONPATH": ".",
        "XZ_PUBLIC_KEY": "YOUR_PUBLIC_KEY",
        "XZ_PRIVATE_KEY": "YOUR_PRIVATE_KEY",
        "XZ_DEFAULT_LOCATION": "yulin"
      }
    }
  }
}

You run a dedicated MCP server that provides real-time weather queries by connecting to the Xinzhi Weather API. This server lets clients fetch current weather data for a given location through a simple, self-contained HTTP-like interface, powered by a model context protocol. It’s useful when you want weather data as an accessible service within your MCP ecosystem without building the integration from scratch.

How to use

You will use an MCP client to invoke the weather tool exposed by this server. The tool is designed to fetch real-time weather data for a location you specify. To perform a query, call the tool named get_weather and provide the location along with your API key pair. The server will return the current weather information for that location.

How to install

Prerequisites you need before installing this MCP server are Python 3.9 or newer and a working MCP client capable of calling tools.

1. Create a working directory for the MCP server.

2. Place the following MCP configuration in a file named mcp.json in that directory. This configuration is the exact snippet you will use to define the MCP server for the Xinzhi Weather service.

{
  "mcpServers": {
    "xinzhi-weather": {
      "command": "python",
      "args": ["server.py"],
      "env": {
        "PYTHONPATH": ".",
        "XZ_PUBLIC_KEY": "您的心知天气公钥",
        "XZ_PRIVATE_KEY": "您的心知天气私钥", 
        "XZ_DEFAULT_LOCATION": "yulin"
      }
    }
  }
}

Run the MCP server locally

3. Run the server from the directory where you placed mcp.json and server.py. Ensure the required environment variables are set as shown in the configuration.

export PYTHONPATH=.
export XZ_PUBLIC_KEY=YOUR_PUBLIC_KEY
export XZ_PRIVATE_KEY=YOUR_PRIVATE_KEY
export XZ_DEFAULT_LOCATION=YOUR_DEFAULT_LOCATION
python server.py

Notes on usage

- The client uses the get_weather tool to request weather data. You will provide a location (for example, a city name) and your API keys. The server will respond with the current weather information for that location.

Available tools

get_weather

Tool to fetch real-time weather data for a specified location using Xinzhi Weather API. Pass the target location and your API keys to retrieve current conditions.