Yazhodha/Weather-MCP
If you are the rightful owner of Weather-MCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
Weather-MCP is a server designed to provide weather information, built using .Net 8.
Weather MCP Web API Server
A comprehensive Model Context Protocol (MCP) server for weather data, built with .NET 8 and Clean Architecture principles. This server provides Claude Desktop with access to real-time weather information, forecasts, alerts, and weather-related calculations.
š¤ļø Features
Weather Tools
- Current Weather - Get real-time weather conditions for any city
- Weather Forecast - 1-5 day weather forecasts with detailed information
- Weather Alerts - Active weather warnings and alerts for any region
- Weather Comparison - Side-by-side weather comparison between cities
- Weather History - Historical weather data (simulated for demonstration)
- Temperature Conversion - Convert between Celsius, Fahrenheit, and Kelvin
- Heat Index Calculator - Calculate apparent temperature from temperature and humidity
- Sunrise/Sunset Times - Get sunrise and sunset times for any city (simulated)
Technical Features
- Clean Architecture - Proper separation of concerns with Domain, Application, Infrastructure, and API layers
- Real Weather Data - Integration with National Weather Service (weather.gov) API
- Fallback Simulation - Graceful degradation with simulated data when external APIs are unavailable
- MCP Protocol Compliance - Full support for Model Context Protocol with Claude Desktop
- Comprehensive Error Handling - Robust error handling with informative responses
- Dependency Injection - Modern .NET DI container with proper service registration
šļø Architecture
This project follows Clean Architecture principles:
āāā WeatherMCPWebAPI.Domain/ # Core business logic and entities
ā āāā Entities/ # Weather, WeatherForecast, WeatherAlert
ā āāā ValueObjects/ # Temperature, Location
āāā WeatherMCPWebAPI.Application/ # Application services and interfaces
ā āāā Interfaces/ # IWeatherService, IWeatherApiClient
ā āāā Services/ # WeatherService business logic
ā āāā Models/ # DTOs and API models
āāā WeatherMCPWebAPI.Infrastructure/ # External integrations
ā āāā External/ # NationalWeatherServiceClient
ā āāā Services/ # Infrastructure services
āāā WeatherMCPWebAPI/ # API layer and MCP tools
āāā Tools/ # MCP tool implementations
āāā Program.cs # Application startup
š Quick Start
Prerequisites
- .NET 8 SDK
- Claude Desktop (for MCP integration)
Installation
-
Clone the repository
git clone https://github.com/Yazhodha/Weather-MCP.git cd weather-mcp
-
Build the project
dotnet build --configuration Release
-
Publish for MCP usage
cd WeatherMCPWebAPI dotnet publish --configuration Release --self-contained false --output ../published
Claude Desktop Configuration
Add this configuration to your claude_desktop_config.json
:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"weather-mcp-server": {
"command": "dotnet",
"args": ["path/to/published/WeatherMCPWebAPI.dll"],
"cwd": "path/to/published"
}
}
}
Replace path/to/published
with the actual path to your published directory.
Usage
- Restart Claude Desktop after updating the configuration
- Ask weather questions in Claude Desktop:
- "What's the weather in New York?"
- "Give me a 5-day forecast for London"
- "Compare weather between Seattle and Miami"
- "Convert 75 degrees Fahrenheit to Celsius"
- "Calculate heat index for 90°F and 70% humidity"
š ļø Development
Running in Development Mode
For local development with full HTTP API access:
cd WeatherMCPWebAPI
dotnet run
This provides:
- Swagger UI at
https://localhost:7042/swagger
- Health check at
https://localhost:7042/health
- Direct weather endpoints:
GET /weather/current/{city}
GET /weather/forecast/{city}?days=3
- Tools debug endpoint at
https://localhost:7042/mcp/tools
Project Structure
WeatherMCPWebAPI/
āāā WeatherMCPWebAPI.Domain/
ā āāā Entities/
ā ā āāā Weather.cs
ā ā āāā WeatherForecast.cs
ā ā āāā WeatherAlert.cs
ā āāā ValueObjects/
ā āāā Temperature.cs
ā āāā Location.cs
āāā WeatherMCPWebAPI.Application/
ā āāā Interfaces/
ā ā āāā IWeatherService.cs
ā ā āāā IWeatherApiClient.cs
ā āāā Services/
ā ā āāā WeatherService.cs
ā āāā Models/
ā āāā WeatherApiModels.cs
āāā WeatherMCPWebAPI.Infrastructure/
ā āāā External/
ā āāā NationalWeatherServiceClient.cs
āāā WeatherMCPWebAPI/
āāā Tools/
ā āāā WeatherTools.cs
āāā Program.cs
Key Dependencies
- ModelContextProtocol (preview) - MCP server implementation
- Microsoft.Extensions.Hosting - Hosting and DI
- Microsoft.Extensions.Http - HTTP client factory
š Weather Data Sources
Primary Source: National Weather Service
- API: https://api.weather.gov
- Coverage: United States
- Features: Real-time weather, forecasts, alerts
- Rate Limiting: Respectful API usage with proper headers
Fallback Data
When the National Weather Service API is unavailable:
- Simulated Weather Data - Realistic weather patterns
- City Coordinates - Built-in lookup for major US cities
- Graceful Degradation - No service interruption
š API Documentation
MCP Tools
Tool Name | Description | Parameters |
---|---|---|
get_current_weather | Current weather conditions | city: string |
get_weather_forecast | Weather forecast | city: string , days: number (1-5) |
get_weather_alerts | Active weather alerts | region: string |
compare_weather | Compare two cities | city1: string , city2: string |
get_weather_history | Historical weather data | city: string , startDate: string , endDate: string |
convert_temperature | Temperature unit conversion | value: number , fromUnit: string , toUnit: string |
calculate_heat_index | Heat index calculation | temperatureF: number , humidity: number |
get_sunrise_sunset | Sunrise/sunset times | city: string |
Example Responses
Current Weather
š¤ļø Current Weather for London, UK
Temperature: 22°C (72°F)
Conditions: Partly Cloudy
Humidity: 65%
Pressure: 1013 hPa
Wind: 15 km/h NW
Last Updated: 2024-01-15 14:30:00 UTC
Weather Comparison
š Weather Comparison
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š New York, US vs London, UK
š”ļø Temperature:
⢠New York: 25.0°C (77.0°F)
⢠London: 18.0°C (64.4°F)
⢠Difference: 7.0°C
š§ Humidity:
⢠New York: 68%
⢠London: 72%
š§ Configuration
Environment Variables
- MCP_MODE: Set to disable console logging for MCP usage
- ASPNETCORE_ENVIRONMENT: Set to
Development
for full HTTP API
Logging
The application automatically detects MCP mode and suppresses console logging to ensure clean JSON-RPC communication with Claude Desktop.
š¤ Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
š License
This project is licensed under the MIT License - see the file for details.
š Acknowledgments
- National Weather Service for providing free weather data API
- Anthropic for the Claude Desktop and MCP protocol
- Microsoft for the excellent .NET ecosystem and MCP SDK
š Troubleshooting
Common Issues
Claude Desktop shows "Server disconnected"
- Ensure the path in
claude_desktop_config.json
is correct - Check that .NET 8 runtime is installed
- Verify the published DLL exists at the specified path
JSON parsing errors in Claude Desktop logs
- Make sure you're using the published DLL, not
dotnet run
- Restart Claude Desktop after configuration changes
Weather data unavailable
- The server gracefully falls back to simulated data
- Check internet connectivity for real weather.gov data
- Rate limiting may cause temporary fallback to simulated data
Getting Help
- Check the Issues page
- Review Claude Desktop MCP documentation
- Ensure your .NET 8 installation is up to date
Built with ā¤ļø using .NET 8 and Clean Architecture