MCP Weather Server
Provides real-time weather forecasts and active weather alerts for US locations using the National Weather Service API. It enables users to retrieve detailed local forecasts via coordinates and monitor state-specific weather warnings.
README
MCP WEATHER SERVER WRITTEN IN TYPESCRIPT
Protocol Map
This weather MCP server implements the Model Context Protocol (MCP) to provide weather data through a standardized interface. Below is the complete protocol mapping showing how the server communicates with MCP clients.
Server Information
- Name:
weather - Version:
1.0.0 - Transport: STDIO (Standard Input/Output)
- Protocol: Model Context Protocol
Capabilities
{
"capabilities": {
"tools": {
"listChanged": true
}
}
}
Tools
The server exposes two tools for weather data retrieval:
1. get_alerts
Retrieves active weather alerts for a US state.
Input Schema:
{
"type": "object",
"properties": {
"state": {
"type": "string",
"description": "Two-letter US state code (e.g. CA, NY)",
"minLength": 2,
"maxLength": 2
}
},
"required": ["state"]
}
Example Request:
{
"method": "tools/call",
"params": {
"name": "get_alerts",
"arguments": {
"state": "CA"
}
}
}
Example Response:
{
"content": [
{
"type": "text",
"text": "Event: Heat Advisory\nArea: Los Angeles County\nSeverity: Moderate\nDescription: Dangerously hot conditions...\nInstructions: Drink plenty of fluids..."
}
]
}
Error Response:
{
"content": [
{
"type": "text",
"text": "Unable to fetch alerts or no alerts found."
}
]
}
2. get_forecast
Retrieves weather forecast for a specific location using latitude and longitude coordinates.
Input Schema:
{
"type": "object",
"properties": {
"latitude": {
"type": "number",
"description": "Latitude of the location",
"minimum": -90,
"maximum": 90
},
"longitude": {
"type": "number",
"description": "Longitude of the location",
"minimum": -180,
"maximum": 180
}
},
"required": ["latitude", "longitude"]
}
Example Request:
{
"method": "tools/call",
"params": {
"name": "get_forecast",
"arguments": {
"latitude": 38.5816,
"longitude": -121.4944
}
}
}
Example Response:
{
"content": [
{
"type": "text",
"text": "Tonight:\nTemperature: 65°F\nWind: 5 mph SW\nForecast: Partly cloudy with a slight chance of showers.\n---\nTomorrow:\nTemperature: 78°F\nWind: 10 mph W\nForecast: Sunny skies throughout the day."
}
]
}
Error Responses:
{
"content": [
{
"type": "text",
"text": "Failed to retrieve grid point data for coordinates: 38.5816, -121.4944. This location may not be supported by the NWS API (only US locations are supported)."
}
]
}
Communication Flow
sequenceDiagram
participant Client as MCP Client (Claude)
participant Server as Weather Server
participant NWS as National Weather Service API
Client->>Server: Initialize Connection (STDIO)
Server->>Client: Server Info + Capabilities
Client->>Server: List Tools
Server->>Client: [get_alerts, get_forecast]
Client->>Server: Call Tool: get_forecast(lat, lon)
Server->>NWS: GET /points/{lat},{lon}
NWS->>Server: Grid Point Data
Server->>NWS: GET {forecast_url}
NWS->>Server: Forecast Data
Server->>Client: Formatted Forecast Text
Client->>Server: Call Tool: get_alerts(state)
Server->>NWS: GET /alerts/active/area/{state}
NWS->>Server: Active Alerts
Server->>Client: Formatted Alerts Text
Protocol Messages
Initialization
Client → Server:
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {
"name": "Claude Desktop",
"version": "1.0.0"
}
}
}
Server → Client:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"protocolVersion": "2024-11-05",
"capabilities": {
"tools": {
"listChanged": true
}
},
"serverInfo": {
"name": "weather",
"version": "1.0.0"
}
}
}
Tool Discovery
Client → Server:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list"
}
Server → Client:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"tools": [
{
"name": "get_alerts",
"description": "Get weather alerts for a US state.",
"inputSchema": {
"type": "object",
"properties": {
"state": {
"type": "string",
"description": "Two-letter US state code (e.g. CA, NY)"
}
},
"required": ["state"]
}
},
{
"name": "get_forecast",
"description": "Get weather forecast for a location.",
"inputSchema": {
"type": "object",
"properties": {
"latitude": {
"type": "number",
"description": "Latitude of the location"
},
"longitude": {
"type": "number",
"description": "Longitude of the location"
}
},
"required": ["latitude", "longitude"]
}
}
]
}
}
External API Integration
National Weather Service API
The server integrates with the following NWS API endpoints:
| Endpoint | Purpose | Rate Limit |
|---|---|---|
GET /alerts/active/area/{state} |
Retrieve active alerts for a state | User-Agent required |
GET /points/{latitude},{longitude} |
Get grid point metadata | User-Agent required |
GET {forecast_url} |
Retrieve detailed forecast | User-Agent required |
Required Headers:
User-Agent: weather-app/1.0
Accept: application/geo+json
Error Handling
The server implements graceful error handling for:
- Invalid coordinates: Returns error message for non-US locations
- Network failures: Returns "Unable to fetch..." messages
- Missing data: Returns "No active alerts" or similar user-friendly messages
- API errors: Catches and handles HTTP errors from NWS API
Transport Layer
- Type: STDIO (Standard Input/Output)
- Encoding: UTF-8
- Message Format: JSON-RPC 2.0
- Framing: Newline-delimited JSON
Security Considerations
- Input Validation: All parameters are validated against schema
- Rate Limiting: Respects NWS API rate limits
- Error Sanitization: External API errors are sanitized before returning to client
- No Authentication: Server uses public NWS API (no credentials required)
Logging
- STDIO Servers: All logs written to
stderr(neverstdout) - Log Location: Configured in MCP client (e.g.,
~/Library/Logs/Claude/mcp-server-weather.log) - Log Level: Errors and warnings only (to avoid STDIO corruption)
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。