MCP Weather Server
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
A Model Context Protocol (MCP) server that provides hourly and daily weather forecasts using the AccuWeather API.
---
Quick Start
You need an AccuWeather API key (free tier available).
Sign up here and create an app to get your key.
Export your API key as an environment variable:
Then run the MCP Weather server directly with:
Or, for HTTP/REST access via supergateway:
---
MCP Server Config Example
For integration with Claude Desktop or other MCP-compatible clients, add this to your config (e.g. claude_desktop_config.json):
---
Overview
This MCP server allows large language models (like Claude) to access real-time weather data. When integrated with an LLM, it enables the model to:
- Fetch accurate, up-to-date weather forecasts
- Provide hourly weather data for the next 12 hours
- Access daily weather forecasts for up to 15 days
- Display data in both metric (°C) and imperial (°F) units
- View temperature, conditions, precipitation information, and other weather details
Available Tools
Hourly Weather Forecast
- Tool name: weather-get_hourly
- Provides hourly forecasts for the next 12 hours
- Parameters:
- location (required): City or location name
- units (optional): "metric" (Celsius, default) or "imperial" (Fahrenheit)
Daily Weather Forecast
- Tool name: weather-get_daily
- Provides daily forecasts for up to 15 days
- Parameters:
- location (required): City or location name
- days (optional): Number of forecast days (1, 5, 10, or 15; default is 5)
- units (optional): "metric" (Celsius, default) or "imperial" (Fahrenheit)
Prerequisites
- Node.js ≥18
- An AccuWeather API key (set via .env or your shell)
Setup
1. **Clone this repository:**
2. **Install dependencies:**
3. **Get an AccuWeather API key:**
- Register at AccuWeather API
- Create a new app and obtain an API key
4. **Create a .env file with your API key:**
5. **Build the project:**
Usage with Claude Desktop
1. Configure Claude Desktop to use this MCP server:
- Open Claude Desktop
- Go to Settings > Developer > Edit Config
- Add the following to your claude_desktop_config.json:
2. Restart Claude Desktop
3. In a new conversation, enable the MCP server by clicking the plug icon and selecting "weather"
4. Now you can ask Claude for weather forecasts, such as:
- "What's the hourly weather forecast for New York City?"
- "Give me the 5-day forecast for London."
- "What will the weather be like in Tokyo this week in Fahrenheit?"
- "Will it rain in San Francisco tomorrow?"
Development
- Install dev dependencies: npm install
- Lint your code: npm run lint
- Build: npm run build
- Run tests: npm test
- Start in dev mode: npm run dev
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.