Discover a TypeScript-based MCP weather server offering real-time forecasts and alerts for seamless client integration
A modern weather server built with the Model Context Protocol (MCP) using the TypeScript SDK. This project exposes real-time weather forecast and alert tools for integration with LLM clients like Claude for Desktop.
The MCP Weather Server is a robust solution designed to integrate real-time weather data into AI applications, enhancing their capabilities through standardized APIs. By leveraging MCP, this server ensures seamless communication between AI applications such as Claude for Desktop and external data sources like the National Weather Service (NWS).
The core features of the MCP Weather Server revolve around providing accurate weather forecasts and alerts to LLM clients. The primary functions include:
getAlerts(state: string)
: Retrieves real-time weather alerts for a specific U.S. state, ensuring users are informed about potential weather-related risks.getForecast(latitude: number, longitude: number)
: Provides short-term weather forecasts based on geographical coordinates, enabling AI applications to offer location-specific insights.Both functions are built using the TypeScript MCP SDK and powered by Axios for handling asynchronous HTTP requests. This infrastructure ensures reliable data retrieval, making it a comprehensive tool for integrating weather information into broader AI workflows.
The architecture of the MCP Weather Server adheres to strict MCP standards, ensuring compatibility with various AI applications through standardized communication protocols. The server is structured as follows:
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
graph TD
G[MCP Weather Server] -->|Fetches from API| I[Data Source]
I --> J[Process Data]
J --> K[Return to Client via MCP Protocol]
style G fill:#ffecff
style I fill:#ffe3e3
style K fill:#b2f0ca
To get started, clone the repository and follow these steps:
git clone https://github.com/your-username/mcp-weather-server-ts.git
.cd mcp-weather-server-ts
to enter the project directory.npm install
.By following this quickstart guide, developers can set up and start leveraging the MCP Weather Server in their AI workflows.
Imagine a home automation system that integrates with Claude Desktop. When severe weather alerts are received via the MCP Weather Server, the system can automatically activate hurricane preparedness protocols such as turning on backup power supplies or securing outdoor equipment.
const { getAlerts } = require('./getAlerts');
(async () => {
const alerts = await getAlerts('Florida');
if (alerts.length > 0) {
// Activate emergency preparedness measures
}
})();
In a scenario where users interact with Claude Desktop to check the weather, the MCP Weather Server can provide customized forecasts based on their location:
const { getForecast } = require('./getForecast');
(async () => {
const forecast = await getForecast(37.7749, -122.4194); // San Francisco coordinates
console.log(forecast);
})();
These use cases highlight the versatility of integrating real-time weather data into AI workflows, enhancing user experience and operational efficiency.
The MCP Weather Server is compatible with several prominent AI applications:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
Adding the MCP Weather Server to your configuration involves specifying it in the mcpServers
section. Here’s an example:
{
"mcpServers": {
"WeatherServer": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-weather-ts"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
This setup ensures that the server is properly recognized and configured within your broader MCP ecosystem.
The performance of the MCP Weather Server has been tested under various conditions, ensuring reliability across different AI applications:
Advanced users can customize the behavior of the MCP Weather Server by adjusting settings like logging levels or integrating custom error handling mechanisms. Secure configuration is achieved through environment variables, such as setting API_KEY
securely in your .env
file:
API_KEY=your-unique-api-key
A1: Yes, you can adjust alert thresholds based on your needs. Refer to the documentation for configuring minimum and maximum alert levels.
A2: Forecasts are refreshed every 5 minutes. However, you can configure this interval according to your specific requirements.
A3: Yes, implement caching strategies using Redis or Memcached to reduce the number of API calls and improve performance.
A4: The server includes built-in rate limiting mechanisms. Custom configuration allows you to adjust the number of requests per minute if necessary.
A5: Absolutely, support for multiple data sources can be added through custom plugins or by modifying the server’s API endpoints.
Contributions to the MCP Weather Server are welcome. To contribute:
Feel free to reach out for further assistance or to report issues.
Explore more about the Model Context Protocol (MCP) and its ecosystem at modelcontextprotocol.org. Join the community forums to connect with other developers working on similar projects.
By leveraging this MCP Weather Server, AI application developers can significantly enhance their tools and services, providing valuable real-time weather data directly from reliable sources like the NWS.
Learn to connect to MCP servers over HTTP with Python SDK using SSE for efficient protocol communication
Integrate AI with GitHub using MCP Server for profiles repos and issue creation
Next-generation MCP server enhances documentation analysis with AI-powered neural processing and multi-language support
Explore MCP servers for weather data and DigitalOcean management with easy setup and API tools
SingleStore MCP Server for database querying schema description ER diagram generation SSL support and TypeScript safety
Explore community contributions to MCP including clients, servers, and projects for seamless integration