home / mcp / weather mcp server

Weather MCP Server

Provides weather data and forecasts through MCP by querying a public weather source and returning current conditions and upcoming forecasts.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "koya-rama-mcp": {
      "command": "python",
      "args": [
        "weather_mcp_server.py"
      ],
      "env": {
        "PYTHONPATH": "."
      }
    }
  }
}

You can run the Weather Chat Assistant MCP Server to power a chat-based weather query experience. The MCP server exposes weather tools that let a client request current conditions and forecasts, enabling real-time, natural-language weather information in your app.

How to use

You will connect a client to the Weather Chat Assistant MCP Server and use its weather tools to ask for current conditions or forecasts. The server provides two primary tools you can invoke via the MCP protocol: get_weather and get_forecast. Use these tools through your MCP client to request weather data for a city, region, or country, and then display the results in your chat UI.

How to install

Prerequisites: you need Python installed on your system. You also need pip to install dependencies.

pip install -r requirements.txt

Navigate to the MCP server directory, install dependencies, and start the server.

cd weather-mcp-server
pip install -r requirements.txt
python weather_mcp_server.py

Other important notes

If you want to test the MCP server from another terminal, you can run a small client snippet that connects, invokes a weather query, and then disconnects. This example uses the WeatherMCPClient to fetch current weather for London.

python -c "
import asyncio
from mcp_client import WeatherMCPClient

async def test():
    client = WeatherMCPClient()
    if await client.connect():
        result = await client.get_weather('London')
        print(result)
        await client.disconnect()

asyncio.run(test())
"

Troubleshooting

Common issues include missing dependencies, network timeouts when querying the weather service, or port conflicts. Ensure you installed dependencies with the correct Python environment and that you can reach the required weather data sources.

If you encounter a module not found error, reinstall dependencies and retry.

Available tools

get_weather

Fetches current weather data for a given location, including temperature, conditions, humidity, and wind.

get_forecast

Returns a weather forecast for a specified location, typically covering upcoming days with conditions and temperatures.