mcp-weather-rust

sujinnair/mcp-weather-rust

3.2

If you are the rightful owner of mcp-weather-rust and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

A Model Context Protocol (MCP) server that provides real-time weather and forecast information using the Tomorrow.io API.

Tools
2
Resources
0
Prompts
0

Weather MCP Server

A Model Context Protocol (MCP) server that provides real-time weather and forecast information using the Tomorrow.io API.

Overview

This server implements the MCP protocol to expose two weather tools:

  • get_realtime_weather: Retrieve current weather conditions for a specified location
  • get_weather_forecast: Get hourly or daily weather forecasts

Requirements

Setup

  1. Clone the repository and install dependencies:
   cargo build
  1. Create a .env file in the project root with your API key:
   echo "WEATHER_API_KEY=your_api_key_here" > .env

Important: Never commit the .env file to version control. It's already listed in .gitignore.

  1. Update configuration in config/config.json:
   {
     "weather_forecast_url": "https://api.tomorrow.io/v4/weather/forecast?location={location}&timesteps={timestep}&apikey={apiKey}",
     "weather_realtime_url": "https://api.tomorrow.io/v4/weather/realtime?location={location}&apikey={apiKey}"
   }

Running the Server

cargo run

The server listens on stdin for JSON-RPC requests and outputs responses to stdout.

API Tools

get_realtime_weather

Get current weather for a location.

Parameters:

  • location (string, required): City name or location

Example Response:

Current weather for London: 15.5°C, Partly Cloudy. Humidity: 65%, Wind: 3.2 m/s (as of 2024-10-19T14:30:00Z)

get_weather_forecast

Get weather forecast for a location.

Parameters:

  • location (string, required): City name or location
  • timestep (string, optional): 1h for hourly or 1d for daily forecasts (default: 1d)

Example Response:

Weather forecast for London:
2024-10-19T15:00:00Z: 16°C, Partly Cloudy. Humidity: 63%, Precipitation: 10%, Wind: 3.1 m/s
2024-10-20T00:00:00Z: 12°C, Cloudy. Humidity: 72%, Precipitation: 20%, Wind: 2.8 m/s
...

Environment Variables

  • WEATHER_API_KEY: Your Tomorrow.io API key (required)

License

MIT