EW

ezh0v/weather-mcp-server

部署与 DevOps

本页由 AI 翻译,技术细节请以原文为准。 查看原文

246 stars 22 forks 质量 73 趋势 18MIT

ezh0v/weather-mcp-server 是从 https://github.com/ezh0v/weather-mcp-server. 导入的 MCP 服务器候选

概览

ezh0v/weather-mcp-server 是从 https://github.com/ezh0v/weather-mcp-server. 导入的 MCP 服务器候选

概述(AI 翻译)

天气API MCP服务器

报告错误 |请求功能

一个轻量级的模型上下文协议(MCP)服务器,使像Claude这样的AI助手能够检索并解读实时天气数据。

在Claude桌面上安装

要将你的MCP服务器与Claude Desktop一起使用,请将其添加到你的Claude配置中:

1.本地模式

你可以从个人账户在WeatherAPI上获取API密钥。

2.远程模式

从源头构建

你可以用 go 在 cmd/github-mcp-server 目录中构建二进制文件。

使用 MCP 搭配 Docker 容器

1.构建 Docker 镜像:

2.运行 Docker 容器:

将your-api-key替换为你实际的WeatherAPI API密钥。

工具

  • current_weather - 获取城市当前天气

  • city:城市名称(字符串,必需)

项目结构

该项目分为几个主要目录:

测试

如果你要添加新功能,请务必包含相应的测试。

1.安装模拟生成器工具:

请参见 go.uber.org/mock 安装指南。

2.请使用以下命令生成模拟文件:

3.要运行单元测试:

贡献

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

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:

1. Local mode

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

You can get an API key from your personal account on WeatherAPI.

2. Remote mode

{
  "mcpServers": {
    "weather-mcp-server": {
      "url": "http://host:port/sse"
    }
  }
}

Build from source

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

Using MCP with Docker Containers

1. Build the Docker Image:

docker build -t weather-mcp-server .

2. Run the Docker Container:

docker run -e WEATHER_API_KEY=your-api-key -d --name weather-mcp-server -p 8000:8000 weather-mcp-server

Replace your-api-key with your actual WeatherAPI API key.

Tools

  • current_weather - Gets the current weather for a city

    • city: The name of the city (string, required)

Project Structure

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

Testing

在 GitHub 查看完整 README

安装

docker run -e WEATHER_API_KEY=your-api-key -d --name weather-mcp-server -p 8000:8000 weather-mcp-server
新手?先看 mcpskill.org 教程 →

配置

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