mcp-weather-api
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-weather-apiwhat's the weather in Austin?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Weather MCP Server
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
Related MCP server: Weather MCP Server
Installation
Prerequisites
Node.js 18+
npm or yarn
Setup
Clone the repository:
git clone <repository-url>
cd weather-mcpInstall dependencies:
npm installBuild the project:
npm run build:serverUsage
Running the MCP Server
Start the server:
npm run start:serverThe 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 URLsAlerts:
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:serverAdding New Tools
To add new weather-related tools:
Define the tool schema in
src/core/index.tsImplement the tool handler function
Add any necessary interfaces in
src/core/interfaces/index.tsAdd 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
This server cannot be deployed
Maintenance
Related MCP Connectors
US weather & geo for AI agents: forecasts, alerts, earthquakes, elevation, geocoding. No keys.
US weather & geo for AI agents: forecasts, alerts, earthquakes, elevation, geocoding. No keys.
Provide real-time and forecast weather information for locations in the United States using natura…
Get US weather forecasts, active alerts, and current observations.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI assistants to access real-time US weather forecasts and alerts through the National Weather Service API.25 npmMIT
- FlicenseNot gradedqualityDmaintenanceEnables users to get weather forecasts and alerts for any US city and state through natural language queries using the National Weather Service API.-
- FlicenseBqualityDmaintenanceProvides real-time US weather alerts and forecasts by integrating with the National Weather Service API. It enables AI assistants to fetch state-specific alerts and detailed local forecasts using geographic coordinates.21-
- FlicenseNot gradedqualityDmaintenanceProvides real-time weather alerts and forecasts from the National Weather Service for US locations, integrating with AI assistants via the Model Control Protocol.-