Show HN: 使用 Go 语言实现的最小化 MCP 服务器,展示项目架构
该项目是一个使用 Go 语言实现的轻量级 Model Context Protocol (MCP) 服务器,旨在让 AI 助手(例如 Claude)获取和解析实时天气数据。它提供了 `current_weather` 工具,用于获取指定城市的天气信息。文章介绍了如何在 Claude Desktop 中配置和使用该服务器,并提供了从源代码构建的说明。项目结构清晰,包含 `cmd`、`internal` 和 `pkg` 等目录。欢迎贡献代码,项目采用 MIT 许可证。
TuanKiri/weather-mcp-server
一个轻量级的 Model Context Protocol (MCP) 服务器,使 AI 助手(如 Claude)能够检索和解释实时天气数据。
License
Weather API MCP Server
一个轻量级的 Model Context Protocol (MCP) 服务器,使 AI 助手(如 Claude)能够检索和解释实时天气数据。
Installing on Claude Desktop
要将你的 MCP 服务器与 Claude Desktop 结合使用,请将其添加到你的 Claude 配置中:
{
"mcpServers": {
"weather-mcp-server": {
"command": "/path/to/weather-mcp-server",
"args": [],
"env": {
"WEATHER_API_KEY": "your-api-key"
}
}
}
}
你可以从 weatherapi 的个人帐户中获取你的 API 密钥。
Build from source
你可以使用 go
在 cmd/github-mcp-server
目录中构建二进制文件。
go build -o weather-mcp-server ./cmd/weather-mcp-server
Tools
- current_weather - 获取城市的当前天气
city
: 城市名称 (string, 必需)
Project Structure
该项目被组织成几个关键目录:
├── cmd
│ └── weather-mcp-server
├── internal
│ └── server
│ ├── handlers # MCP handlers
│ ├── services # Business logic layer
│ │ ├── core # Core application logic
│ │ └── mock # Mock services for testing
│ ├── tools # MCP tools
│ └── view # Templates for displaying messages
└── pkg
Contributing
欢迎提交 issue 或 pull request 来改进项目。 提前感谢您的帮助! 请遵循 contribution guidelines。
License
此 MCP 服务器在 MIT 许可下获得许可。
About
一个轻量级的 Model Context Protocol (MCP) 服务器,使 AI 助手(如 Claude)能够检索和解释实时天气数据。