天气查询服务

一个轻量级的天气查询服务,通过NOAA Weather API提供实时天气数据和警报信息,专为Claude Desktop设计。

  • by KTsaneff
  • C#
  • 本地部署
  • 更新于
在 GitHub 查看 KTsaneff/WeatherMcpServer

使用说明

🌦️ 气象MCP服务器

轻量级 模型上下文协议(MCP) 服务器构建于 .NET 8 用于 克劳德桌面.
该服务器公开了允许Claude从官方网站查询实时天气数据的工具 NOAA天气API.


🧠 概述

这 气象MCP服务器 演示如何整合本地。NET MCP服务与克劳德桌面。
连接后,Claude可以使用 get_forecast 和 get_alerts 通过自定义MCP界面直接检索实时天气状况和警报的工具。


🚀 特性

  • ✅ 完全兼容Claude Desktop的MCP
  • 🌎 美国国家气象局(NOAA)的实时数据
  • 🧰 两种可用工具:
    • get_forecast --返回特定纬度和经度的天气预报
    • get_alerts --返回美国某个州的活跃天气警报
  • 🧩 使用最小的。NET 8托管模型
  • ⚙️ 易于与Claude的MCP配置集成

🏗️ 项目结构

WeatherMcpServer/ │ ├── 型号/#(数据可选型号) ├── 工具/ │ └── WeatherTools.cs#包含get_forecast和get_alerts方法 ├── Program.cs#应用程序入口点 --WeatherMcpServer.csproj


🧩 MCP工具

🔹 get_forecast

检索给定位置的当前和即将到来的天气预报。

请求示例:

{
  "latitude": 38.5816,
  "longitude": -121.4944
}

**Example response:**
Tonight
Temperature: 58°F
Wind: 5 mph NW
Forecast: Clear skies expected overnight.

### 🔹 `get_alerts`
Fetches all active weather alerts for a specific U.S. state.

**Example request:**

{
  "state": "CA"
}


**Example response:**

Event: Heat Advisory
Area: Los Angeles County
Severity: Moderate
Description: Temperatures up to 102°F expected.
Instructions: Stay hydrated and avoid outdoor activities.

🧰 Setup Instructions
✅ Requirements

.NET 8 SDK

Claude Desktop (latest version)

▶️ Run the Server

Open PowerShell or a terminal and run:

dotnet run --project "D:\REPOS\Weather-MCP\WeatherMcpServer\WeatherMcpServer.csproj" --no-build


If successful, you’ll see:

Weather MCP Server is running (waiting for MCP requests...)...

⚙️ Configure Claude Desktop

Open the Claude Desktop configuration file:

C:\Users\<YourName>\AppData\Roaming\Claude\claude_desktop_config.json


Add the following MCP server entry:

{
  "mcpServers": {
    "weather": {
      "command": "dotnet",
      "args": [
        "run",
        "--project",
        "D:\\REPOS\\Weather-MCP\\WeatherMcpServer\\WeatherMcpServer.csproj",
        "--no-build"
      ]
    }
  }
}


Save the file and restart Claude Desktop.

Click the slider icon ⚙️ in Claude’s chat bar. You should see:

get_forecast

get_alerts

🧠 How It Works

The project runs as a local MCP-compliant .NET app.

Communication with Claude happens through STDIO.

Tools are defined using [McpServerTool] attributes.

Each method sends and receives structured JSON messages to/from Claude.

📦 Example of Integration Flow

Claude sends:

{
  "tool": "weather:get_forecast",
  "arguments": { "latitude": 38.5816, "longitude": -121.4944 }
}


The server queries the NOAA API

and returns a human-readable forecast response.

🧾 License

This project is licensed under the MIT License.
You are free to use, modify, and distribute it for educational or commercial purposes.

💬 Author

Krassy Tsaneff
🎓 Built as an experimental project for learning the Model Context Protocol (MCP)
🌐 GitHub Profile

📍 Sofia, Bulgaria

🏷️ Technologies Used

.NET 8

C#

Model Context Protocol (MCP)

Claude Desktop

NOAA Weather API

⭐ If you found this useful, consider starring the repo!