Skip to main content
Glama
akaramanapp

Weather MCP Server

by akaramanapp

天气 MCP 服务器

一个模型上下文协议 (MCP) 服务器,使用国家气象局 (NWS) API 提供美国各地的天气信息和警报。该服务器旨在供 AI 代理通过模型上下文协议使用。

特征

  • 获取美国任何州天气警报的工具

  • 使用坐标获取美国任何地点详细天气预报的工具

  • 支持温度、风力状况和简短预报描述

  • 来自国家气象局的实时数据

Related MCP server: MCP Weather Server

先决条件

  • Node.js(v16 或更高版本)

  • npm 或 yarn 包管理器

安装

  1. 克隆存储库:

git clone https://github.com/akaramanapp/weather-mcp-server.git
cd weather-mcp-server
  1. 安装依赖项:

npm install
  1. 构建应用程序:

npm run build

MCP 工具

服务器提供了两个可供AI代理使用的MCP工具:

获取警报

获取特定美国州的天气警报。

参数:

  • state :两个字母的州代码(例如 CA、NY)

响应示例:

{
  "content": [
    {
      "type": "text",
      "text": "Active alerts for CA: ..."
    }
  ]
}

获取预测

使用坐标获取特定位置的天气预报。

参数:

  • latitude :位置的纬度(-90 到 90)

  • longitude :位置经度(-180 至 180)

响应示例:

{
  "content": [
    {
      "type": "text",
      "text": "Morning: Temperature: 72°F, Wind: 5mph NW, Partly cloudy..."
    }
  ]
}

项目结构

weather/
├── src/
│   └── index.ts    # Main server code with MCP tool implementations
├── build/          # Compiled JavaScript files
├── package.json    # Project dependencies and scripts
└── tsconfig.json   # TypeScript configuration

技术细节

  • 使用 TypeScript 构建

  • 实现模型上下文协议(MCP)服务器

  • 使用@modelcontextprotocol/sdk 实现 MCP 服务器

  • 与国家气象局 (NWS) API 接口

  • ES2022 目标与 Node16 模块解析

发展

要修改或扩展服务器:

  1. src/index.ts文件中进行更改

  2. 重建应用程序:

npm run build

依赖项

  • @modelcontextprotocol/sdk:MCP服务器实现框架

  • zod:工具参数的运行时类型检查和验证

  • TypeScript:类型安全的开发依赖关系

执照

国际学习中心

笔记

  • 该服务器仅适用于美国地区,因为它使用国家气象局 API

  • API 请求有速率限制,并且需要 User-Agent 标头

  • 所有坐标均应采用十进制度格式

  • 这不是一个独立的 CLI 应用程序,而是一个通过模型上下文协议为 AI 代理提供工具的服务器

Install Server
A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

Resources

Looking for Admin?

Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/akaramanapp/weather-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server