OpenWeatherMap MCP Server
Provides weather data integration using the OpenWeatherMap API, enabling users to fetch current weather conditions, hourly and daily forecasts, weather alerts, and geocoding services for any location worldwide.
README
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:
npx @tristau/openweathermap-mcp
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
{
"mcpServers": {
"openweathermap": {
"command": "npx",
"args": ["@tristau/openweathermap-mcp", "--apikey", "your_api_key_here"]
}
}
}
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
{
"servers": {
"openweathermap": {
"command": "npx",
"args": ["@tristau/openweathermap-mcp", "--apikey", "your_api_key_here"],
"type": "stdio"
}
}
}
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:
{
"mcpServers": {
"openweathermap": {
"command": "node",
"args": ["/path/to/openweathermap-mcp/dist/index.js", "--apikey", "your_api_key_here"]
}
}
}
Running the Server
For end users (recommended):
npx @tristau/openweathermap-mcp --apikey YOUR_API_KEY
For development/local modifications:
# Development mode (with hot reload)
pnpm run dev
# Local production build
node dist/index.js --apikey YOUR_API_KEY
# Testing the server
node test-server.js
Example Usage
Get current weather for a city:
{
"tool": "get_current_weather",
"arguments": {
"location": {
"city": "New York",
"state": "NY",
"country": "US"
},
"units": "metric"
}
}
Get hourly forecast by coordinates:
{
"tool": "get_hourly_forecast",
"arguments": {
"location": {
"lat": 40.7128,
"lon": -74.0060
},
"hours": 24,
"units": "imperial"
}
}
Geocode a location:
{
"tool": "geocode_location",
"arguments": {
"query": "Paris, France",
"limit": 1
}
}
API Reference
Location Input
All weather tools accept a flexible location object:
interface LocationInput {
// Option 1: Coordinates (most efficient)
lat?: number;
lon?: number;
// Option 2: Address components
city?: string;
state?: string;
country?: string;
// Option 3: Zip/postal code
zipCode?: string;
country?: string; // optional, defaults to US
}
Weather Options
Most weather tools accept these options:
interface WeatherOptions {
units?: 'standard' | 'metric' | 'imperial'; // Default: 'metric'
lang?: string; // Language code, default: 'en'
exclude?: string[]; // Data parts to exclude
}
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-mcp -
Install dependencies:
pnpm install -
Build the project:
pnpm run build
Available Scripts
# Development
pnpm run dev # Start development server with hot reload
pnpm run build # Build TypeScript to JavaScript
pnpm run start # Start production server
# Code Quality
pnpm run lint # Run ESLint
pnpm run lint:fix # Fix ESLint issues automatically
pnpm run format # Format code with Prettier
pnpm run typecheck # Check TypeScript types
# Testing
pnpm run test # Run tests
pnpm run test:watch # Run tests in watch mode
Project Structure
├── src/
│ ├── types/ # TypeScript type definitions
│ │ └── weather.ts
│ ├── services/ # API service classes
│ │ ├── geocoding.ts
│ │ └── weather.ts
│ ├── utils/ # Utility functions
│ │ └── formatters.ts
│ └── index.ts # MCP server implementation
├── tests/ # Test files
│ ├── geocoding.test.ts
│ ├── weather.test.ts
│ └── formatters.test.ts
├── dist/ # Compiled JavaScript (generated)
└── coverage/ # Test coverage reports (generated)
Running Tests
# Run all tests
pnpm test
# Run tests with coverage report
pnpm run test:coverage
# Run specific test file
pnpm test geocoding.test.ts
# Run tests in watch mode
pnpm run test:watch
# Open coverage report in browser (after running test:coverage)
pnpm run coverage:open
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:coverage - Opening
coverage/index.htmlin your browser, or - Running
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-name - Make your changes with tests
- Run the test suite:
pnpm test - Run linting:
pnpm run lint - Use semantic commits:
pnpm run commit(orgit cz) - Push to the branch:
git push origin feature-name - Submit 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:
# Use the interactive prompt
pnpm run commit
# Or manually
git commit -m "feat: add weather alerts functionality"
git commit -m "fix: handle missing API response data"
git commit -m "docs: update installation instructions"
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 releases - Version 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
mainbranch - Require pull request reviews
- Require status checks to pass
- Protect
🔧 Manual Release (if needed):
pnpm run semantic-release
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
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。