OpenWeatherMap MCP Server
A Model Context Protocol (MCP) server that provides weather data integration using the OpenWeatherMap API. This server allows Claude, GitHub Copilot, and other MCP clients to fetch current weather conditions, forecasts, and weather alerts for any location worldwide.
Features
π‘οΈ Current Weather: Get real-time weather conditions
π Weather Forecasts: Hourly (up to 48 hours) and daily (up to 8 days) forecasts
π¨ Weather Alerts: Active weather warnings and alerts
πΊοΈ Geocoding: Convert city names and zip codes to coordinates
π Multiple Units: Support for metric, imperial, and standard units
π£οΈ Internationalization: Weather descriptions in multiple languages
π§ͺ Full Test Coverage: Comprehensive test suite with Jest
π TypeScript: Full type safety and excellent developer experience
Tools Provided
Weather Tools
get_current_weather- Get current weather conditions for a locationget_hourly_forecast- Get hourly forecast for up to 48 hoursget_daily_forecast- Get daily forecast for up to 8 daysget_weather_alerts- Get active weather alerts for a location
Geocoding Tools
geocode_location- Convert location names to coordinatesgeocode_zipcode- Convert zip/postal codes to coordinates
Prerequisites
OpenWeatherMap API key with One Call API 3.0 subscription
Node.js 18+ (for development only)
Installation
You can use this MCP server directly via NPX without needing to clone or build locally:
For development or local modifications, see the Development section below.
Configuration
For Claude Desktop
Add the following to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
For GitHub Copilot (VS Code)
Add the following to your MCP configuration file:
Linux: ~/.config/Code/User/mcp.json
Windows: %APPDATA%\Code\User\mcp.json
macOS: ~/Library/Application Support/Code/User/mcp.json
API Key Configuration
Your OpenWeatherMap API key is configured through the --apikey argument in the MCP client configuration above.
Obtaining an API Key
Sign up at OpenWeatherMap
Subscribe to the "One Call API 3.0" plan
Use your API key in the
--apikeyargument when configuring the MCP server
Note: The One Call API 3.0 requires a paid subscription after 1,000 free calls per day.
Usage
Once configured with your MCP client, you can ask your AI assistant:
"What's the current weather in Paris?"
"Show me the 5-day forecast for Tokyo"
"What's the weather like in Herndon, Virginia?"
"Get me weather alerts for Miami"
MCP Client Configuration (Development)
For development or local modifications, add this server to your MCP client configuration:
Running the Server
For end users (recommended):
For development/local modifications:
Example Usage
Get current weather for a city:
Get hourly forecast by coordinates:
Geocode a location:
API Reference
Location Input
All weather tools accept a flexible location object:
Weather Options
Most weather tools accept these options:
Units
metric: Celsius, m/s, km/himperial: Fahrenheit, mphstandard: Kelvin, m/s
Languages
The API supports 40+ languages. Some examples:
en- English (default)es- Spanishfr- Frenchde- Germanja- Japanesezh_cn- Chinese Simplified
Development
Local Development Setup
If you want to modify or contribute to this MCP server:
Clone the repository:
git clone <repository-url> cd openweathermap-mcpInstall dependencies:
pnpm installBuild the project:
pnpm run build
Available Scripts
Project Structure
Running Tests
Test Coverage
This project maintains high test coverage with the following thresholds:
Statements: 80% minimum
Branches: 80% minimum
Functions: 80% minimum
Lines: 80% minimum
Coverage reports are generated locally and can be viewed by:
Running
pnpm run test:coverageOpening
coverage/index.htmlin your browser, orRunning
pnpm run coverage:opento open automatically
Coverage is automatically checked during pre-commit hooks to ensure quality standards are maintained.
Code Style
This project uses:
ESLint for linting
Prettier for code formatting
TypeScript for type checking
Code is automatically formatted on commit using git hooks.
Error Handling
The server includes comprehensive error handling:
Invalid API Key: Returns clear error message about API key issues
Invalid Coordinates: Validates latitude/longitude ranges
Location Not Found: Helpful error when geocoding fails
Network Errors: Graceful handling of API timeouts and connectivity issues
Rate Limiting: Clear messaging about API rate limits
API Rate Limits
OpenWeatherMap API limits:
One Call API 3.0: 1,000 free calls/day, then paid tiers
Geocoding API: 60 calls/minute, 1,000,000 calls/month
The server handles rate limiting gracefully and provides informative error messages.
Contributing
Fork the repository
Create a feature branch:
git checkout -b feature-nameMake your changes with tests
Run the test suite:
pnpm testRun linting:
pnpm run lintUse semantic commits:
pnpm run commit(orgit cz)Push to the branch:
git push origin feature-nameSubmit a pull request
Semantic Commits
This project uses Conventional Commits for semantic versioning and automated changelog generation.
Commit Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasksci: CI/CD changesperf: Performance improvementsrevert: Reverting previous commits
Examples:
Commit messages are automatically validated using commitlint and husky hooks.
Automated Releases
This project uses semantic-release for automated versioning and publishing:
π How it Works:
Commits to
mainbranch trigger automated releasesVersion is determined by commit types:
fix:β patch version (0.1.0 β 0.1.1)feat:β minor version (0.1.0 β 0.2.0)feat!:orBREAKING CHANGE:β major version (0.1.0 β 1.0.0)
π¦ What Gets Released:
β Version bumped in
package.jsonβ
CHANGELOG.mdupdated automaticallyβ GitHub release created with release notes
β Package published to npm
β Git tag created
βοΈ Setup Requirements:
GitHub Repository Secrets:
NPM_TOKEN- npm authentication token for publishingGITHUB_TOKEN- automatically provided by GitHub Actions
Branch Protection:
Protect
mainbranchRequire pull request reviews
Require status checks to pass
π§ Manual Release (if needed):
License
This project is licensed under the ISC License. See the LICENSE file for details.
Support
For issues and questions:
Check the OpenWeatherMap API Documentation
Review the test files for usage examples
Open an issue in this repository
Changelog
v1.0.0
Initial release
Full OpenWeatherMap One Call API 3.0 integration
Geocoding support for addresses and zip codes
Comprehensive test coverage
TypeScript support
MCP protocol compliance