home / mcp / weather mcp server

Weather MCP Server

mcp server and langgraph mcp adapeters

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "haichaozheng-weather-mcp": {
      "command": "python",
      "args": [
        "weather/mcp_third_party.py"
      ],
      "env": {
        "ZHIPU_API_KEY": "YOUR_ZHIPU_API_KEY",
        "MOONSHOT_API_KEY": "YOUR_MOONSHOT_API_KEY"
      }
    }
  }
}

You deploy a multi-source MCP server that unifies local tools, a weather data service, and third-party MCP tools into a single intelligent agent. This setup lets you perform complex tasks such as weather queries, math and string operations, and live web searches through a consistent MCP interface with automatic tool orchestration.

How to use

To use the MCP server, start all required local components and then connect your MCP client to the local endpoints. The system exposes three local stdio-based services you run from Python scripts, and a central agent that coordinates all tools. Your queries can combine weather lookups, math calculations, and web search results in a single conversation.

How to install

Prerequisites you need before starting are Python 3.11+ and a working Python environment. Ensure you have an active API key setup for Moonshot and Zhīpǔ in your environment.

# Step 1: Create and activate a Python virtual environment
python -m venv weather_venv
# Activate the virtual environment
# Windows
weather_venv\Scripts\activate
# Linux/Mac
source weather_venv/bin/activate

# Step 2: Install dependencies
pip install -r requirements.txt

Additional setup and run instructions

Set up environment variables in a .env file. You need keys for Moonshot and Zhīpǔ API access. The following are required entries.

MOONSHOT_API_KEY=your_actual_api_key
ZHIPU_API_KEY=your_actual_zhipu_api_key

Start the three local services in separate terminals. Each process must run from the project root and use Python to execute the provided scripts.

# Start the weather data server
python weather/weather.py

# Start the comprehensive proxy agent
python weather/agent_with_diverse_tools.py

# Start the Zhīpǔ web search MCP tool tester
python weather/mcp_third_party.py

Configuration notes

The weather server, the main proxy, and the third-party MCP tool rely on environment variables for API access. Ensure your .env file is loaded by the shells running the scripts. The default server runs on localhost, port 8000, and uses the NWS API for weather data. If you modify ports or endpoints, adjust your MCP client configuration accordingly.

Troubleshooting tips

If any component fails to start, check the console output for missing dependencies or invalid API keys. Verify that the .env file is loaded in each shell, and confirm that your Python version is 3.11+ and that the virtual environment is active when launching the services.

Available tools

get_alerts

Fetch US state weather alerts from the weather server's MCP API.

get_forecast

Retrieve weather forecast data by latitude and longitude from the weather server.

add

Add two numbers using the local math tool.

subtract

Subtract the second number from the first using the local math tool.

multiply

Multiply two numbers using the local math tool.

divide

Divide the first number by the second using the local math tool.

sqrt

Compute the square root of a number using the local math tool.

power

Raise a number to a power using the local math tool.

concat

Join multiple strings with a delimiter using the local string tool.

to_upper

Convert a string to upper case using the local string tool.

to_lower

Convert a string to lower case using the local string tool.

web_search

Perform real-time web searches via Zhīpǔ MCP tool to fetch up-to-date results.