guimancuso/openweather-mcp-server
If you are the rightful owner of openweather-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 henry@mcphub.com.
The OpenWeather MCP Server provides weather information using the OpenWeather API, with support for multiple languages and integration with LangChain clients.
OpenWeather MCP Server
A Model Context Protocol (MCP) server that provides weather information using the OpenWeather API. This project includes both HTTP and stdio transport implementations, along with LangChain client integrations for Anthropic Claude and Amazon Bedrock.
Features
- Current weather temperature and conditions
- 5-day weather forecast with 3-hour intervals
- Support for multiple languages (Portuguese, English, Spanish, Italian)
- HTTP and stdio transport modes
- LangChain integration with Anthropic Claude
- LangChain integration with Amazon Bedrock
- Comprehensive error handling and validation
Prerequisites
- Python 3.11 or higher
- UV package manager
- OpenWeather API key
- Anthropic API key (for Anthropic client)
- AWS credentials (for Bedrock client)
Installation
- Clone the repository:
git clone https://github.com/guimancuso/openweather-mcp-server.git
cd openweather-mcp-server
- Install dependencies using UV:
uv sync
- Set up environment variables:
cp .env.example .env
- Edit the
.env
file with your API keys:
# Required for all clients
OPENWEATHER_KEY=your_openweather_api_key_here
# Required for Anthropic client
ANTHROPIC_API_KEY=your_anthropic_api_key_here
# Required for Bedrock client
AWS_DEFAULT_REGION=us-east-1
AWS_ACCESS_KEY_ID=your_aws_access_key_here
AWS_SECRET_ACCESS_KEY=your_aws_secret_key_here
API Key Setup
OpenWeather API
- Visit OpenWeatherMap
- Sign up for a free account
- Generate an API key
- Add the key to your
.env
file
Anthropic API (Optional)
- Visit Anthropic Console
- Create an account and generate an API key
- Add the key to your
.env
file
AWS Bedrock (Optional)
- Set up AWS credentials using one of these methods:
- AWS CLI:
aws configure
- Environment variables:
AWS_ACCESS_KEY_ID
,AWS_SECRET_ACCESS_KEY
- IAM role (if running on EC2)
- AWS credentials file (
~/.aws/credentials
)
- AWS CLI:
- Set the AWS region in your
.env
file
Usage
MCP Server (HTTP Mode)
uv run python mcp_server/weather_mcp_server_http.py
The server will start on http://0.0.0.0:8000
MCP Server (stdio Mode)
uv run python mcp_server/weather_mcp_server_stdio.py
Anthropic Client
# Interactive mode
uv run python clients/weather_client_anthropic.py
# Run examples
uv run python clients/weather_client_anthropic.py --examples
Bedrock Client
# Interactive mode
uv run python clients/weather_client_bedrock.py
# Run examples
uv run python clients/weather_client_bedrock.py --examples
Testing
# Test Anthropic client
uv run python clients_tests/weather_client_test_anthropic.py
# Test Bedrock client
uv run python clients_tests/weather_client_test_bedrock.py
Available Tools
get_current_temperature(city: str)
Get current weather temperature and conditions for a specific city.
Parameters:
city
: City name (e.g., "London", "New York", "São Paulo")
Returns: JSON object with current weather data
get_weather_forecast(city: str)
Get 5-day weather forecast with 3-hour intervals for a specific city.
Parameters:
city
: City name (e.g., "London", "New York", "São Paulo")
Returns: JSON object with forecast data
Example Queries
The system supports queries in multiple languages:
- "What is the current temperature in Prague?"
- "Give me the weather forecast for London in the coming days"
- "¿Cuál es la temperatura actual en Madrid?"
- "¿Cómo estará el clima en Barcelona mañana?"
- "Qual è la temperatura corrente a Roma?"
- "Che tempo farà a Milano nei prossimi giorni?"
- "Qual é a temperatura atual em São Paulo?"
- "Como estará o tempo no Rio de Janeiro amanhã?"
Project Structure
openweather-mcp-server/
├── clients/ # LangChain client implementations
│ ├── weather_client_anthropic.py # Anthropic Claude client
│ └── weather_client_bedrock.py # Amazon Bedrock client
├── clients_tests/ # Test files for clients
│ ├── weather_client_test_anthropic.py
│ └── weather_client_test_bedrock.py
├── mcp_server/ # MCP server implementations
│ ├── weather_mcp_server_http.py # HTTP transport server
│ └── weather_mcp_server_stdio.py # stdio transport server
├── .env.example # Environment variables template
├── .gitignore # Git ignore rules
├── pyproject.toml # Project dependencies
├── README.md # This file
└── uv.lock # Dependency lock file
Dependencies
fastmcp
: MCP server frameworkrequests
: HTTP client for API callsdotenv
: Environment variable managementlangchain-anthropic
: Anthropic Claude integrationlangchain-aws
: AWS Bedrock integrationlangchain-mcp-adapters
: MCP tool adapterslanggraph
: Agent framework
Error Handling
The application includes comprehensive error handling for:
- Missing API keys
- Invalid AWS credentials
- Network connectivity issues
- Invalid city names
- API rate limiting
Security
- All API keys are loaded from environment variables
- No hardcoded secrets in the codebase
- Proper error handling that doesn't leak sensitive information
- Input validation through the OpenWeather API
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
This project is open source. Please check the license file for details.
Support
For issues and questions:
- Check the error messages in the console
- Verify your API keys are correctly set
- Ensure all dependencies are installed
- Check the OpenWeather API documentation for city name formats