dulikvor/McpWeatherServer
If you are the rightful owner of McpWeatherServer and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The MCP Weather Server is a Model Context Protocol server that provides comprehensive weather information and related prompts for cities worldwide.
MCP Weather Server
A Model Context Protocol (MCP) server that provides weather information and weather-related prompts for any city worldwide.
Features
Tools
- GetCurrentWeather: Get real-time weather conditions for any city
- GetWeatherForecast: Multi-day weather forecast (1-7 days)
- CompareWeather: Compare weather between multiple cities
- GetWeatherJson: Weather data in JSON format for integration
Kusto/ICM Tools
- QueryIncidents: Query incident information from ICM Data Warehouse
- QueryIncidentDiscussions: Query incident discussions and comments
- ExecuteCustomKustoQuery: Execute custom KQL queries
- QueryGenevaMetrics: Query Geneva metrics for LAControlPlane
- QueryGenevaMetricsAdvanced: Advanced Geneva metrics with aggregation
Azure AI Search RAG Tools
- WriteIncidentSummary: Write incident summaries to Azure AI Search for RAG
- SearchIncidentSummaries: Search incident summaries for context and insights
- GetIncidentSummary: Retrieve specific incident summary by ID
- DeleteIncidentSummary: Delete incident summary from Azure Search
- GenerateContextualIncidentSummary: Generate intelligent summaries using RAG context
- ListAllIncidentSummaries: List all stored incident summaries
- SetIncidentVector: Set embedding vector for semantic search
- GetIncidentVector: Retrieve embedding vector for an incident
Prompts
- RequestWeatherInformation: Generate prompts for weather requests
- AnalyzeWeatherForActivity: Weather analysis for specific activities
- CompareWeatherForTravel: Travel destination weather comparison
- AnalyzeForecastTrends: Detailed forecast trend analysis
- ExplainWeatherConditions: Educational weather explanations
- PlanEventAroundWeather: Event planning with weather considerations
Installation
- Clone or download this project
- Navigate to the project directory
- Install dependencies:
dotnet restore
Configuration
Weather API (Optional)
The server includes mock weather data for demonstration. To use real weather data:
- Get an API key from OpenWeatherMap (free tier available)
- Update
appsettings.json:{ "WeatherApi": { "OpenWeatherMapApiKey": "your_actual_api_key_here" } } - Uncomment the real API implementation in
WeatherService.cs
Azure AI Search (For RAG Capabilities)
To enable incident summary storage and retrieval with RAG capabilities:
- Get your Azure Search API key from the Azure portal for your
hackathon2025search service - Update
appsettings.json:{ "AzureSearch": { "ApiKey": "your_azure_search_api_key_here" } }
The service will automatically connect to https://hackathon2025.search.windows.net and create the incident-summaries index with the required schema for storing incident summaries with vector support.
The in-memory search provides blazing-fast RAG capabilities for incident summaries. Data is lost when the application restarts, making it perfect for experimentation and testing.
Usage
As MCP Server
Run the server to make it available to MCP clients:
dotnet run
The server communicates via stdio and provides the following capabilities:
- Weather tools for real-time data
- Weather-related prompts for LLM interactions
- Support for multiple temperature units (Celsius, Fahrenheit, Kelvin)
- City comparison and forecast analysis
MCP Client Integration
To use this server with an MCP client:
var clientTransport = new StdioClientTransport(new StdioClientTransportOptions
{
Name = "WeatherServer",
Command = "dotnet",
Arguments = ["run"],
WorkingDirectory = "/path/to/McpWeatherServer"
});
var client = await McpClientFactory.CreateAsync(clientTransport);
// List available tools
foreach (var tool in await client.ListToolsAsync())
{
Console.WriteLine($"{tool.Name}: {tool.Description}");
}
// Get weather for a city
var result = await client.CallToolAsync(
"GetCurrentWeather",
new Dictionary<string, object?>
{
["city"] = "London",
["temperatureUnit"] = "celsius"
});
Integration with Chat Clients
The tools work seamlessly with AI chat clients:
// Get available weather tools
IList<McpClientTool> tools = await client.ListToolsAsync();
// Use with any IChatClient
IChatClient chatClient = ...;
var response = await chatClient.GetResponseAsync(
"What's the weather like in Tokyo and compare it with London?",
new() { Tools = [.. tools] });
Example Usage
Tools Examples
Get Current Weather:
{
"tool": "GetCurrentWeather",
"arguments": {
"city": "New York",
"countryCode": "US",
"temperatureUnit": "fahrenheit"
}
}
Compare Multiple Cities:
{
"tool": "CompareWeather",
"arguments": {
"cities": "London, Paris, Berlin, Rome",
"temperatureUnit": "celsius"
}
}
Get Forecast:
{
"tool": "GetWeatherForecast",
"arguments": {
"city": "Tokyo",
"days": 7,
"temperatureUnit": "celsius"
}
}
Prompt Examples
Activity Planning:
{
"prompt": "AnalyzeWeatherForActivity",
"arguments": {
"city": "San Francisco",
"activity": "hiking",
"scheduledTime": "this weekend"
}
}
Travel Comparison:
{
"prompt": "CompareWeatherForTravel",
"arguments": {
"cities": "Barcelona, Rome, Athens",
"travelPurpose": "vacation",
"travelDates": "next month"
}
}
Features
- 🌍 Global Coverage: Weather for any city worldwide
- 🌡️ Multiple Units: Celsius, Fahrenheit, and Kelvin support
- 📊 Rich Data: Temperature, humidity, wind, pressure, visibility
- 📅 Forecasting: Up to 7-day weather forecasts
- 🔄 Comparison: Side-by-side weather comparison
- 🎯 Activity Focus: Weather analysis for specific activities
- 📋 JSON Output: Structured data for integration
- 🤖 AI-Ready: Seamless integration with LLM chat clients
Development
Adding New Tools
Add methods to WeatherTools.cs with the [McpServerTool] attribute:
[McpServerTool]
[Description("Your tool description")]
public static async Task<string> YourNewTool(
IWeatherService weatherService,
[Description("Parameter description")] string parameter)
{
// Implementation
}
Adding New Prompts
Add methods to WeatherPrompts.cs with the [McpServerPrompt] attribute:
[McpServerPrompt]
[Description("Your prompt description")]
public static ChatMessage YourNewPrompt(
[Description("Parameter description")] string parameter)
{
return new ChatMessage(ChatRole.User, "Your prompt text");
}
Dependencies
- .NET 8.0
- ModelContextProtocol (MCP SDK)
- Microsoft.Extensions.Hosting
- Microsoft.Extensions.Http
- System.Text.Json
License
This project is provided as an example implementation. Modify and use according to your needs.
Notes
- The current implementation uses mock weather data for demonstration
- Real weather API integration is straightforward with the provided structure
- All logging goes to stderr for MCP protocol compliance
- Temperature conversions and formatting are built-in
- Error handling provides user-friendly messages