Weather Api
БесплатноНе проверенProvides weather forecasts and alerts for US locations via the National Weather Service API, enabling AI assistants to deliver real-time weather information.
Описание
Provides weather forecasts and alerts for US locations via the National Weather Service API, enabling AI assistants to deliver real-time weather information.
README
A Model Context Protocol (MCP) server that provides weather data tools for AI assistants and applications. This server integrates with the National Weather Service (NWS) API to deliver real-time weather forecasts and alerts for locations within the United States.
Features
- Weather Forecasts: Get detailed weather forecasts for any US location using latitude/longitude coordinates
- Weather Alerts: Retrieve active weather alerts for any US state
- NWS Integration: Direct integration with the official National Weather Service API
- MCP Protocol: Built using the Model Context Protocol SDK for seamless AI assistant integration
Installation
Prerequisites
- Node.js 18+
- npm or yarn
Setup
- Clone the repository:
git clone <repository-url>
cd weather-mcp
- Install dependencies:
npm install
- Build the project:
npm run build:server
Usage
Running the MCP Server
Start the server:
npm run start:server
The server runs on stdio and is designed to be used with MCP-compatible AI assistants like Claude Desktop.
Available Tools
The server provides two main tools:
1. get-forecast
Retrieve weather forecast for a specific location.
Parameters:
latitude(number): Latitude of the location (-90 to 90)longitude(number): Longitude of the location (-180 to 180)
Example Usage:
// Get forecast for San Francisco
{
"tool": "get-forecast",
"parameters": {
"latitude": 37.7749,
"longitude": -122.4194
}
}
2. get-alerts
Retrieve active weather alerts for a US state.
Parameters:
state(string): Two-letter state code (e.g., "CA", "NY", "TX")
Example Usage:
// Get alerts for California
{
"tool": "get-alerts",
"parameters": {
"state": "CA"
}
}
Integration with AI Assistants
Claude Desktop Integration
To integrate with Claude Desktop, add the following to your Claude Desktop configuration:
{
"mcpServers": {
"weather": {
"command": "node",
"args": ["/path/to/weather-mcp/dist/core/server/index.js"]
}
}
}
Other MCP-Compatible Applications
This server follows the Model Context Protocol specification and can be integrated with any MCP-compatible application. The server communicates via stdio using the MCP protocol.
API Data Sources
This server uses the following National Weather Service endpoints:
- Forecasts:
https://api.weather.gov/points/{lat},{lon}and associated forecast URLs - Alerts:
https://api.weather.gov/alerts?area={STATE}
Coverage
- Forecasts: All US territories and locations
- Alerts: All US states and territories (using two-letter state codes)
Development
Project Structure
src/
├── core/
│ ├── constants/ # API endpoints and configuration
│ ├── interfaces/ # TypeScript type definitions
│ ├── utils/ # Utility functions for API calls and formatting
│ ├── server/ # Server bootstrap and transport setup
│ └── index.ts # Main MCP server implementation
└── client/ # (Empty - for future client implementations)
Building
The project uses TypeScript and compiles to the dist/ directory:
npm run build:server
Adding New Tools
To add new weather-related tools:
- Define the tool schema in
src/core/index.ts - Implement the tool handler function
- Add any necessary interfaces in
src/core/interfaces/index.ts - Add utility functions in
src/core/utils/index.tsif needed
Example:
server.tool(
"tool-name",
"Tool description",
{
param1: z.string().describe("Parameter description"),
},
async ({ param1 }) => {
// Implementation
return {
content: [
{
type: "text",
text: "Result",
},
],
};
}
);
Error Handling
The server includes comprehensive error handling:
- API Failures: Graceful handling of NWS API errors with informative messages
- Invalid Coordinates: Validation for latitude/longitude bounds
- Missing Data: Proper handling when forecast or alert data is unavailable
- Network Issues: Timeout and connection error handling
Dependencies
- @modelcontextprotocol/sdk: MCP server implementation
- @anthropic-ai/sdk: Anthropic SDK (for potential future features)
- zod: Runtime type validation
- dotenv: Environment variable management
License
ISC License
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
Support
For issues and questions:
- Check the National Weather Service API documentation for data availability
- Ensure your coordinates are within US territories for forecasts
- Verify state codes are valid two-letter abbreviations for alerts
Limitations
- US Only: The NWS API only provides data for US territories
- Rate Limits: Subject to National Weather Service API rate limits
- Data Availability: Some remote locations may not have detailed forecast data
Установить Weather Api в Claude Desktop, Claude Code, Cursor
unyly install mcp-weather-apiСтавит в Claude Desktop, Claude Code, Cursor и VS Code — сам разбирается с npx, uvx и сборкой из исходников.
Впервые? Поставь CLI: curl -fsSL https://unyly.org/install | sh
Или настроить вручную
Выполни в терминале:
claude mcp add mcp-weather-api -- npx -y weather-mcpFAQ
Weather Api MCP бесплатный?
Да, Weather Api MCP бесплатный — установка в пару кликов через Unyly без оплаты.
Нужен ли API-ключ для Weather Api?
Нет, Weather Api работает без API-ключей и переменных окружения.
Weather Api — hosted или self-hosted?
Доступен hosted-вариант: Unyly запускает сервер в облаке, локальная установка не обязательна.
Как установить Weather Api в Claude Desktop, Claude Code или Cursor?
Открой Weather Api на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.
Похожие MCP
Fetch
Web content fetching and conversion for efficient LLM usage.
AWS KB Retrieval
Retrieval from AWS Knowledge Base using Bedrock Agent Runtime.
автор: modelcontextprotocolSpring AI MCP Server
Provides auto-configuration for setting up an MCP server in Spring Boot applications.
llm-analysis-assistant
A very streamlined mcp client that supports calling and monitoring stdio/sse/streamableHttp, and can also view request responses through the /logs page. It also
автор: xuzexin-hzCompare Weather Api with
Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории ai
