sujinnair/mcp-weather-rust
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.
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 locationget_weather_forecast: Get hourly or daily weather forecasts
Requirements
- Rust 1.70+
- A Tomorrow.io API key (free tier available at https://www.tomorrow.io)
Setup
- Clone the repository and install dependencies:
cargo build
- Create a
.envfile 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.
- Update configuration in
config/config.json:
{
"weather_forecast_url": "https://api.tomorrow.io/v4/weather/forecast?location={location}×teps={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 locationtimestep(string, optional):1hfor hourly or1dfor 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