内容
# mpc-weather-server
基于模型上下文协议(Model Context Protocol)的天气服务器。以下过程将创建两个工具:
* get-alerts
获取某个州的天气警报
来自服务器:weather
* get-forecast
获取某个地点的天气预报
来自服务器:weather
Claude可以使用天气服务器提供的工具,这些工具是基于模型上下文协议(Model Context Protocol)构建的。
# 如何运行
```dotnet run /path/to/weather```
# 创建新服务器
## 创建新项目
```dotnet new console```
## 导入依赖
```dotnet add package ModelContextProtocol --prerelease```
```dotnet add package Microsoft.Extensions.Hosting```
## 使用MPC SDK和Microsoft库添加代码
.\Program.cs 和 .\WeatherTools.cs
## 编译并运行
```dotnet run```
## 使用Claude for Desktop进行测试
code $env:AppData\Claude\claude_desktop_config.json
```
{
"mcpServers": {
"weather": {
"command": "dotnet",
"args": [
"run",
"--project",
"C:\\ABSOLUTE\\PATH\\TO\\PROJECT",
"--no-build"
]
}
}
}
```