WeatherMcpServer

oblist7/WeatherMcpServer

3.1

If you are the rightful owner of WeatherMcpServer 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.

The Real Weather MCP Server is a functional Model Context Protocol server that provides real-time weather data using AI assistants like Claude, built with C# and the .NET MCP SDK.

Tools
3
Resources
0
Prompts
0

Real Weather MCP Server

A functional MCP (Model Context Protocol) server that provides real weather data through AI assistants like Claude, built with C# and the .NET MCP SDK.

🌟 Features

  • Real Weather Data: Integrates with OpenWeatherMap API for accurate, current weather information
  • Current Weather: Get current weather conditions for any city worldwide
  • Weather Forecasts: Provide weather forecasts up to 5 days ahead
  • Weather Alerts: Basic weather alert system with safety recommendations
  • Global Coverage: Support for cities worldwide with optional country codes
  • Error Handling: Comprehensive error handling for invalid locations, API failures, etc.
  • Rich Formatting: Beautiful, emoji-rich responses that are easy to read

🚀 Quick Start

Prerequisites

1. Get API Key

  1. Sign up at OpenWeatherMap
  2. Get your free API key from the dashboard
  3. Set environment variable:
    export OPENWEATHER_API_KEY=your_api_key_here
    

2. Run Locally

# Clone and build
dotnet build

# Run the server
dotnet run --project WeatherMcpServer

3. Configure in Kiro

Create .kiro/settings/mcp.json:

{
  "mcpServers": {
    "real-weather": {
      "command": "dotnet",
      "args": [
        "run",
        "--project",
        "path/to/WeatherMcpServer"
      ],
      "env": {
        "OPENWEATHER_API_KEY": "your_api_key_here"
      },
      "disabled": false,
      "autoApprove": ["GetCurrentWeather", "GetWeatherForecast", "GetWeatherAlerts"]
    }
  }
}

🛠️ Available Tools

GetCurrentWeather

Gets current weather conditions for any city.

Parameters:

  • city (required): City name (e.g., "London", "New York")
  • countryCode (optional): ISO country code (e.g., "US", "UK")

Example: "What's the current weather in Tokyo?"

GetWeatherForecast

Gets weather forecast for the next 1-5 days.

Parameters:

  • city (required): City name
  • countryCode (optional): ISO country code
  • days (optional): Number of days (1-5, default: 3)

Example: "Get a 5-day forecast for Paris, FR"

GetWeatherAlerts

Gets weather alerts and safety recommendations.

Parameters:

  • city (required): City name
  • countryCode (optional): ISO country code

Example: "Are there any weather alerts for Miami?"

📋 Example Output

🌤️ **Current Weather in London, GB**

🌡️ **Temperature:** 15.2°C (feels like 14.8°C)
☁️ **Conditions:** Partly cloudy
💧 **Humidity:** 72%
🔽 **Pressure:** 1013 hPa
💨 **Wind:** 12.5 km/h SW
👁️ **Visibility:** 10.0 km
🌅 **Sunrise:** 07:42 | 🌇 **Sunset:** 16:28

📚 Documentation

  • - Detailed setup and configuration instructions
  • - Example conversations and use cases
  • API Documentation - OpenWeatherMap API reference

🏗️ Project Structure

WeatherMcpServer/
├── Models/
│   └── WeatherModels.cs      # Data models for API responses
├── Services/
│   └── WeatherService.cs     # Weather API integration
├── Tools/
│   ├── WeatherTools.cs       # Real weather MCP tools
│   └── RandomNumberTools.cs  # Demo tools (can be removed)
├── .mcp/
│   └── server.json          # MCP server configuration
├── Program.cs               # Application entry point
├── WeatherMcpServer.csproj  # Project configuration
├── README.md               # This file
├── SETUP.md               # Setup instructions
└── EXAMPLES.md            # Usage examples

🧪 Testing

Test the server by asking natural language questions:

  • "What's the weather like in Berlin?"
  • "Will it rain in Seattle tomorrow?"
  • "Get a 3-day forecast for Sydney, AU"
  • "Are there any weather alerts for London?"

📦 Publishing

Build Package

dotnet pack -c Release

Publish to NuGet

dotnet nuget push bin/Release/*.nupkg --api-key <your-api-key> --source https://api.nuget.org/v3/index.json

Use Published Package

{
  "servers": {
    "RealWeatherMcpServer": {
      "type": "stdio",
      "command": "dnx",
      "args": [
        "RealWeatherMcpServer",
        "--version",
        "1.0.0",
        "--yes"
      ],
      "env": {
        "OPENWEATHER_API_KEY": "your_api_key_here"
      }
    }
  }
}

🔧 Technical Details

  • Framework: .NET 8.0
  • MCP SDK: ModelContextProtocol 0.3.0-preview.3
  • Weather API: OpenWeatherMap API v2.5
  • Transport: stdio (Standard Input/Output)
  • Data Format: JSON with rich text formatting

🚨 Error Handling

The server provides helpful error messages for common issues:

  • Invalid city names
  • Missing or invalid API keys
  • Network connectivity issues
  • API rate limit exceeded
  • Invalid parameter values

📊 API Limits

OpenWeatherMap free tier includes:

  • 1,000 API calls per day
  • 60 calls per minute
  • Current weather and 5-day forecast data

🤝 Contributing

This project was created as a test assignment for FastMCP.me. Feel free to use it as a reference for building your own MCP servers.

📄 License

This project is provided as-is for educational and demonstration purposes.

🔗 Resources