shaynemeyer/weather-mcp-server
If you are the rightful owner of weather-mcp-server 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.
The Weather MCP Server provides real-time weather information for cities worldwide using the Open-Meteo API, integrating seamlessly with MCP-enabled applications.
Weather MCP Server
A Model Context Protocol (MCP) server that provides real-time weather information for any city worldwide using the Open-Meteo API.
Features
- Real-time weather data - Get current weather conditions for any city
- Global coverage - Support for cities worldwide via geocoding
- MCP compliant - Integrates seamlessly with MCP-enabled applications
- Accurate location - Uses Open-Meteo's geocoding API for precise city identification
- Comprehensive data - Temperature, precipitation, wind speed, cloud cover, and more
Architecture
graph TD
A[MCP Client] -->|Request: get-weather| B[Weather MCP Server]
B -->|City name| C[Open-Meteo Geocoding API]
C -->|Coordinates| B
B -->|Coordinates| D[Open-Meteo Weather API]
D -->|Weather data| B
B -->|Formatted response| A
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#fff3e0
style D fill:#fff3e0
Weather Data Flow
sequenceDiagram
participant Client as MCP Client
participant Server as Weather Server
participant Geo as Geocoding API
participant Weather as Weather API
Client->>Server: get-weather("San Francisco")
Server->>Geo: Search for "San Francisco"
Geo-->>Server: Coordinates (37.7749, -122.4194)
alt City found
Server->>Weather: Get weather for coordinates
Weather-->>Server: Current weather data
Server-->>Client: Formatted weather response
else City not found
Server-->>Client: "City not found" error
end
Installation
-
Clone the repository
git clone <repository-url> cd weather-mcp-server -
Install dependencies
npm install -
Run the server
node main.ts
Usage
The server provides a single tool called get-weather that accepts a city name and returns current weather conditions.
Tool: get-weather
Parameters:
city(string): Name of the city to get weather for
Example Request:
{
"tool": "get-weather",
"arguments": {
"city": "London"
}
}
Example Response:
{
"content": [
{
"type": "text",
"text": "{
\"current\": {
\"temperature_2m\": 68.5,
\"apparent_temperature\": 70.2,
\"is_day\": 1,
\"precipitation\": 0.0,
\"rain\": 0.0,
\"weather_code\": 1,
\"cloud_cover\": 25,
\"wind_speed_10m\": 8.2
}
}"
}
]
}
Configuration
The server uses the following APIs with default settings:
- Geocoding API:
https://geocoding-api.open-meteo.com/v1/search - Weather API:
https://api.open-meteo.com/v1/forecast - Units: Fahrenheit, MPH, inches
- Timezone: America/Los_Angeles (configurable in code)
Weather Data Fields
The weather response includes:
| Field | Description | Unit |
|---|---|---|
temperature_2m | Current temperature | �F |
apparent_temperature | Feels-like temperature | �F |
is_day | Day/night indicator | 0/1 |
precipitation | Current precipitation | inches |
rain | Rain amount | inches |
showers | Shower amount | inches |
weather_code | Weather condition code | - |
cloud_cover | Cloud coverage | % |
wind_speed_10m | Wind speed at 10m | mph |
Error Handling
The server handles common error scenarios:
- City not found: Returns a user-friendly message when the geocoding API cannot locate the specified city
- API errors: Network and API response errors are propagated appropriately
- Invalid input: Input validation using Zod schemas
Dependencies
- @modelcontextprotocol/sdk - MCP server framework
- zod - Input validation and schema definition
API Credits
This project uses the Open-Meteo API, which provides:
- Free weather data with no API key required
- High-quality meteorological data
- Global coverage with 1km resolution
- Historical and forecast data
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request