Token导航 LogoToken导航TokenDH.com
Weather MCP Openapi Server logo
地图位置stdio官方级别未说明来源级核验

Weather MCP Openapi Server

MCP Server

一个轻量级的Node.js应用,代理wttr.in天气服务并实现OpenAPI规范,同时包含MCP服务器用于AI助手集成。

工具数

1

提示词数

0

GitHub Stars

0

资源数

0
位置天气API代理JavaScriptAPI集成Docker

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

karpikpl

提供方

karpikpl

最后核验

2026/5/17 20:20

运行时

Docker

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

docker run -p 3000:3000 -p 3001:3001 wttr-proxy

详细介绍

天气代理服务

一个轻量级的Node.js应用程序,代理对wttr.in的调用,并实现用于天气数据检索的OpenAPI规范。还包括用于AI助手集成的MCP(模型上下文协议)服务器。

特性

  • ✅ 实现OpenAPI 3.1.0规范
  • 🌤️ 向wttr.in天气服务代理请求
  • 📚 带有Swagger UI的交互式API文档
  • 🤖 用于AI助手集成的MCP服务器
  • 🐳 Docker容器化,易于部署
  • 🔒 安全最佳实践(非root用户、输入验证)
  • 📊 健康检查端点
  • ⚡ 重量轻,速度快

快速开始

使用Docker Compose(推荐)

docker-compose up --build

这将启动两个服务:

  • HTTP API: http://localhost:3000
  • MCP服务器: http://localhost:3001

使用Docker

# Build the image
docker build -t wttr-proxy .

# Run the container (exposes both ports)
docker run -p 3000:3000 -p 3001:3001 wttr-proxy

地方发展

# Install dependencies
npm install

# Start both HTTP API and MCP server
npm start

# Or start them individually:
npm run start:api  # HTTP API only
npm run start:mcp  # MCP server only

# Development mode (HTTP API only)
npm run dev

MCP服务器使用情况

MCP(模型上下文协议)服务器与主要的API一起作为HTTP服务运行,使其可以通过网络进行人工智能辅助集成。

网络接入

  • MCP端点: http://localhost:3001/mcp
  • 运输:POST上的HTTP JSON-RPC 2.0
  • 健康检查: http://localhost:3001/health

集成步骤:

  1. 启动服务:
   npm start  # Starts both API and MCP server
  1. 配置您的AI助手 要连接到 http://localhost:3001/mcp 使用HTTP POST和JSON-RPC 2.0协议。使用提供的 mcp-config.json 作为参考:
   {
     "mcpServers": {
       "weather": {
         "url": "http://localhost:3001/mcp",
         "transport": "http",
         "method": "POST"
       }
     }
   }
  1. 测试连接:
   npm run test-mcp

MCP API示例:

列出工具:

curl -X POST http://localhost:3001/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'

获取天气:

curl -X POST http://localhost:3001/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"get_weather","arguments":{"location":"London"}}}'

可用的MCP工具:

  • get_weather(location):获取任何地点的全面天气信息

MCP服务器提供格式化的天气数据,包括当前状况、预报和天文信息,可通过HTTP访问,用于基于网络的AI助手集成。

用法

运行后,服务将在以下位置可用:

  • HTTP API: http://localhost:3000

- API文件:http://localhost:3000/docs - 健康检查:http://localhost:3000/health - 天气端点:http://localhost:3000/{位置}?格式=j1

  • MCP服务器: http://localhost:3001

- MCP端点:http://localhost:3001/mcp - 健康检查:http://localhost:3001/health - 服务器信息:http://localhost:3001/info

API调用示例

# Get weather for London
curl "http://localhost:3000/London?format=j1"

# Get weather for New York
curl "http://localhost:3000/New%20York?format=j1"

# Health check
curl "http://localhost:3000/health"

API规范

该服务实现了中定义的OpenAPI规范 weather.json:

  • 端点: GET /{location}
  • 所需参数:

- location (路径):城市或地点名称 - format (query):JSON格式必须为“j1”

  • 响应:

- 200:JSON格式的天气数据 - 404:未找到位置 - 400:无效参数 - 500:服务器错误

环境变量

  • API_PORT:HTTP API服务器端口(默认值:3000)
  • MCP_PORT:MCP服务器端口(默认值:3001)
  • NODE_ENV:环境模式(开发/生产)

安全功能

  • Docker容器中的非root用户
  • 输入验证和净化
  • 请求超时保护
  • 错误处理和日志
  • CORS就绪(如果需要)

健康监测

该应用程序包括:

  • 健康检查端点(/health)
  • Docker健康检查
  • 优雅的停机处理
  • 请求日志记录

发展

该应用程序由以下组件构建:

  • Express.js:Web框架
  • 阿西奥斯:API调用的HTTP客户端
  • Swagger UI Express:API文件
  • MCP-SDK:模型上下文协议服务器实现
  • Node.js 18 Alpine:轻质容器底座

MCP服务器配置

对于支持MCP的AI助手,您可以使用提供的配置天气服务器 mcp-config.json:

{
  "mcpServers": {
    "weather": {
      "command": "node",
      "args": ["mcp-server.js"],
      "env": {
        "NODE_ENV": "production"
      }
    }
  }
}

使用快速代理MCP客户端进行测试

uv tool run fast-agent-mcp go --servers weather

贡献

  1. 分叉存储库
  2. 创建功能分支
  3. 进行更改
  4. 彻底测试
  5. 提交拉取请求

许可证

MIT许可证

目录标签

目录标签

位置天气API代理JavaScriptAPI集成Docker天气服务本地部署OpenAPIAI集成Node.js

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Docker

工具数量(toolCount,工具数)

1

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP