WeatherMcpServer
一个基于和风天气构造的天气服务MCP,支持SSE
claude mcp add --transport stdio cooosin-weathermcpserver node server.js \ --env HEFENG_API_KEY="your hefeng.api.key here"
How to use
WeatherMcpServer is a weather MCP server built on the HeFeng (QWeather) weather data service and supports Server-Sent Events (SSE) connections for real-time updates. To use it, obtain an API key from the HeFeng weather service and configure it in the server’s environment variable HEFENG_API_KEY. The server uses this key to fetch weather data and stream updates to connected clients via SSE. Once running, clients can connect to the MCP endpoint to receive weather information for configured locations with live updates.
The available capabilities focus on providing weather data and streaming updates. Configure the server with the desired location(s) and ensure your client supports SSE. The MCP protocol will expose endpoints for querying current conditions, forecasts, and ongoing weather streams, enabling lightweight, event-driven integration into your applications or dashboards.
How to install
Prerequisites:
- Node.js installed on the host machine
- Access to install npm packages if using a package-based setup
Step-by-step:
-
Prepare installation directory and navigate there: mkdir weather-mcp && cd weather-mcp
-
Initialize a basic Node.js project (if not using a pre-packaged distribution): npm init -y
-
Install the Weather MCP server package (if published as a package) or ensure you have the server files. For a local script setup, place server.js and related files in the directory.
-
Create a configuration file or set environment variables. At minimum, set the HeFeng API key:
- Create a .env file (optional): HEFENG_API_KEY=your_api_key_here
- Or set it directly in your environment before running the server.
-
Run the server: node server.js
-
Verify the MCP endpoint by connecting a client using the MCP protocol to the running server and confirm SSE connections are streaming weather updates.
Additional notes
Notes:
- Requires a valid HeFeng (QWeather) API key. Without it, the server cannot fetch data.
- SSE connections may require CORS and proper client support; ensure your client can handle event streams.
- If the API key is invalid or rate-limited, implement error handling on the client side to retry or fallback.
- If running behind a firewall or proxy, ensure the outbound access to HeFeng API endpoints is allowed.
- Consider configuring multiple locations and caching strategies to reduce API calls and improve latency.
- Monitor usage and set appropriate environment variables to manage secrets securely (e.g., using a secrets manager in production).