Weather MCP Server
Provides weather data including current conditions, daily forecasts up to 16 days, and hourly forecasts up to 7 days, using the free Open-Meteo API with no API key required.
README
Weather MCP Server
A Model Context Protocol (MCP) server that provides weather data using the free Open-Meteo API.
Features
- No API Key Required: Uses the free Open-Meteo API
- Current Weather: Get real-time weather conditions for any location
- Daily Forecast: Multi-day weather forecasts (up to 16 days)
- Hourly Forecast: Detailed hour-by-hour predictions (up to 7 days)
- Location Search: Find coordinates for any city worldwide
- Flexible Units: Support for metric and imperial units
- Multiple Formats: Both human-readable markdown and machine-readable JSON outputs
Tools
1. weather_search_location
Search for a city to get its coordinates.
Parameters:
city(str): City name to searchcount(int, optional): Maximum number of results (default: 5)response_format(str, optional): Output format - 'markdown' or 'json' (default: 'markdown')
Example:
{
"city": "London",
"count": 3
}
2. weather_get_current
Get current weather conditions for a location.
Parameters:
latitude(float): Latitude coordinate (-90 to 90)longitude(float): Longitude coordinate (-180 to 180)temperature_unit(str, optional): 'celsius' or 'fahrenheit' (default: 'celsius')wind_speed_unit(str, optional): 'kmh', 'ms', 'mph', or 'kn' (default: 'kmh')response_format(str, optional): Output format (default: 'markdown')
Example:
{
"latitude": 51.5074,
"longitude": -0.1278,
"temperature_unit": "celsius"
}
3. weather_get_forecast
Get daily weather forecast for up to 16 days.
Parameters:
latitude(float): Latitude coordinatelongitude(float): Longitude coordinatedays(int, optional): Number of forecast days 1-16 (default: 7)temperature_unit(str, optional): Temperature unit (default: 'celsius')wind_speed_unit(str, optional): Wind speed unit (default: 'kmh')response_format(str, optional): Output format (default: 'markdown')
Example:
{
"latitude": 40.7128,
"longitude": -74.0060,
"days": 5,
"temperature_unit": "fahrenheit"
}
4. weather_get_hourly
Get hourly weather forecast for up to 7 days (168 hours).
Parameters:
latitude(float): Latitude coordinatelongitude(float): Longitude coordinatehours(int, optional): Number of forecast hours 1-168 (default: 24)temperature_unit(str, optional): Temperature unit (default: 'celsius')wind_speed_unit(str, optional): Wind speed unit (default: 'kmh')response_format(str, optional): Output format (default: 'markdown')
Example:
{
"latitude": 35.6762,
"longitude": 139.6503,
"hours": 48
}
Installation
Prerequisites
- Python 3.10 or higher
- pip
Install Dependencies
cd weather_mcp
pip install -r requirements.txt
Usage
Running the Server
The server uses stdio transport for local integration:
python server.py
Using with Claude Desktop or Other MCP Clients
Add the following to your MCP client configuration:
For Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"weather": {
"command": "python",
"args": ["/path/to/weather_mcp/server.py"]
}
}
}
For Claude Code (.claude/settings.json):
{
"mcpServers": {
"weather": {
"command": "python",
"args": ["/path/to/weather_mcp/server.py"]
}
}
}
Testing with MCP Inspector
You can test the server using the MCP Inspector:
# Install MCP Inspector
npm install -g @modelcontextprotocol/inspector
# Run inspector
npx @modelcontextprotocol/inspector python server.py
Example Client
See client_example.py for a complete example of how to use the MCP server programmatically.
python client_example.py
Example Queries
Here are some example queries you can use with this MCP server:
-
Find a city and get its weather:
First, search for "Paris" to get coordinates, then get current weather for those coordinates. -
Get a weekly forecast:
Get a 7-day weather forecast for London (51.5074, -0.1278) in Fahrenheit. -
Check hourly conditions:
Get the next 24 hours of weather data for Tokyo (35.6762, 139.6503).
API Response Formats
Markdown Format (Default)
Human-readable format with headers, bullet points, and clear structure. Ideal for display to users.
JSON Format
Machine-readable structured data. Perfect for programmatic processing or integration with other tools.
Data Source
This server uses the Open-Meteo API, which provides:
- Free access for non-commercial use
- No API key required
- High-quality weather data from multiple national weather services
- Global coverage
Architecture
- FastMCP Framework: Uses the official MCP Python SDK with FastMCP
- Pydantic Validation: All inputs are validated using Pydantic v2 models
- Async HTTP: Non-blocking API calls using httpx
- Type Safety: Full type hints throughout the codebase
- Error Handling: Comprehensive error messages with actionable suggestions
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
License
MIT License - See LICENSE file for details.
Acknowledgments
- Weather data provided by Open-Meteo
- Built with Model Context Protocol
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。