Show HN:Go语言编写的极简MCP服务器,展示项目架构
Show HN: Minimal MCP server in Go showcasing project architecture

原始链接: https://github.com/TuanKiri/weather-mcp-server

这份文档概述了一个轻量级的模型上下文协议 (MCP) 服务器,旨在为像 Claude 这样的 AI 助手提供实时的天气数据。该服务器使用 Go 编写,允许 Claude 查询和解读当前的天气状况。 为了将该服务器与 Claude 桌面版集成,您需要使用服务器的命令路径、参数(通常为空)和环境变量配置 Claude,其中包括从 weatherapi.com 获取的 `WEATHER_API_KEY`。 构建服务器需要使用 Go 编译器创建一个名为 `weather-mcp-server` 的可执行二进制文件,该文件位于 `cmd/weather-mcp-server` 目录中。项目结构被组织成用于命令行入口、内部服务器逻辑(处理程序、服务、工具、视图)和可重用包的目录。内部服务器逻辑目录包含 MCP 处理程序、业务逻辑、MCP 工具和模板。欢迎根据贡献指南提交贡献和错误报告。该项目采用 MIT 许可证授权。

Hacker News 最新 | 往期 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Show HN:Go语言编写的极简MCP服务器,展示项目架构 (github.com/tuankiri) 5 分,作者 TuanKiri,3 小时前 | 隐藏 | 往期 | 收藏 | 讨论 我刚开始学习 Go 语言不久,最近对 MCP 服务器的工作原理很感兴趣。我开始思考这样一个项目的架构可能是什么样的,并决定构建一个极简版本作为实验。我基于过去编写常规 REST API 服务器的经验,认为它可能对其他人也有用或有趣。 加入我们 6 月 16-17 日在旧金山举办的 AI 初创公司学校! 指导原则 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系我们 搜索:

原文

A lightweight Model Context Protocol (MCP) server that enables AI assistants like Claude to retrieve and interpret real-time weather data.

Installing on Claude Desktop

To use your MCP server with Claude Desktop, add it to your Claude configuration:

{
  "mcpServers": {
    "weather-mcp-server": {
      "command": "/path/to/weather-mcp-server",
      "args": [],
      "env": {
        "WEATHER_API_KEY": "your-api-key"
      }
    }
  }
}

You can get your API key in your personal account at weatherapi.

You can use go to build the binary in the cmd/github-mcp-server directory.

go build -o weather-mcp-server ./cmd/weather-mcp-server

The project is organized into several key directories:

├── 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

Feel free to open tickets or send pull requests with improvements. Thanks in advance for your help!

Please follow the contribution guidelines.

This MCP server is licensed under the MIT License.

联系我们 contact @ memedata.com