Node.js MCP Weather Server

Node.js MCP Weather Server

An MCP server that provides weather information like forecasts and alerts for US locations using the National Weather Service API.

Category
访问服务器

README

Node.js MCP Weather Server with Azure Deployment

A Model Context Protocol (MCP) server built with Express.js and Node.js that provides weather information using the National Weather Service API. Ready for deployment to Azure App Service with Azure Developer CLI (azd).

🌟 Features

  • Express.js Framework: Fast, unopinionated web framework for Node.js
  • MCP Protocol Compliance: Full support for JSON-RPC 2.0 MCP protocol
  • HTTP Transport: HTTP-based communication for web connectivity
  • Weather Tools:
    • get_alerts: Get weather alerts for any US state
    • get_forecast: Get detailed weather forecast for any location
  • Azure Ready: Pre-configured for Azure App Service deployment
  • Web Test Interface: Built-in HTML interface for testing
  • National Weather Service API: Real-time weather data from official US government source

🚀 Quick Deploy to Azure

Prerequisites

Deploy in 3 Commands

# 1. Login to Azure
azd auth login

# 2. Initialize the project
azd init

# 3. Deploy to Azure
azd up

After deployment, your MCP server will be available at:

  • Health Check: https://<your-app>.azurewebsites.net/health
  • MCP Capabilities: https://<your-app>.azurewebsites.net/mcp/capabilities
  • Test Interface: https://<your-app>.azurewebsites.net/test

🧪 Test the Live Server

Once deployed, test the weather tools:

# Get weather alerts for California
curl -X POST "https://<your-app>.azurewebsites.net/mcp" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "get_alerts", "arguments": {"state": "CA"}}}'

# Get weather forecast for San Francisco
curl -X POST "https://<your-app>.azurewebsites.net/mcp" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "get_forecast", "arguments": {"latitude": 37.7749, "longitude": -122.4194}}}'

💻 Local Development

Prerequisites

  • Node.js 22+ (or Node.js 18+)
  • npm (Node Package Manager)

Setup & Run

  1. Clone and install dependencies:

    git clone <your-repo-url>
    cd remote-mcp-webapp-node
    npm install
    
  2. Start the development server:

    npm run dev
    
  3. Access the server:

    • Server: http://localhost:8000
    • Health Check: http://localhost:8000/health
    • Test Interface: http://localhost:8000/test

🏗️ Architecture

  • server.js: Main Express application with MCP protocol implementation
  • infra/: Azure Bicep templates for infrastructure as code
  • azure.yaml: Azure Developer CLI configuration
  • public/: Static assets for the web test interface

⚙️ Configuration

The server uses these environment variables:

  • PORT: Server port (default: 8000)
  • NODE_ENV: Environment mode (default: development)

Azure App Service automatically configures:

  • Node.js 22 runtime
  • Premium v3 (P0V3) App Service Plan
  • Health check monitoring

🔌 MCP Integration

Connect to MCP Inspector

Use this configuration to connect to your deployed server:

{
  "mcpServers": {
    "weather-server": {
      "transport": {
        "type": "http",
        "url": "https://<your-app>.azurewebsites.net/mcp"
      },
      "name": "Weather MCP Server",
      "description": "Weather forecast and alerts tools"
    }
  }
}

For local development, use http://localhost:8000/mcp.

🛠️ API Endpoints

  • GET /health - Server health check
  • GET /mcp/capabilities - MCP server capabilities
  • POST /mcp - Main MCP JSON-RPC endpoint
  • GET /test - Web test interface

📖 Available Tools

get_alerts

Get weather alerts for any US state.

Parameters:

  • state (string): Two-letter state code (e.g., "CA", "NY")

get_forecast

Get detailed weather forecast for any location.

Parameters:

  • latitude (number): Latitude coordinate
  • longitude (number): Longitude coordinate

🧪 Testing

Web Interface

Visit /test endpoint for an interactive testing interface.

Command Line

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

# Get weather forecast
curl -X POST "http://localhost:8000/mcp" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "get_forecast", "arguments": {"latitude": 37.7749, "longitude": -122.4194}}, "id": 2}'

🌦️ Data Source

This server uses the National Weather Service (NWS) API:

  • Real-time weather alerts and warnings
  • Detailed weather forecasts
  • Official US government weather data
  • No API key required
  • High reliability and accuracy

� Development Scripts

npm run dev         # Start development server with auto-reload
npm start          # Start production server
npm test           # Run test client against local server

📂 Project Structure

remote-mcp-webapp-node/
├── server.js              # Main Express.js server with MCP implementation
├── test-client.js         # MCP protocol test client
├── package.json           # Dependencies and scripts
├── azure.yaml             # Azure Developer CLI configuration
├── infra/                 # Azure Bicep infrastructure templates
├── public/                # Static web assets
└── README.md              # This documentation

🤝 Contributing

This is a sample project demonstrating MCP server implementation with Azure deployment. Feel free to:

  • Fork and customize for your needs
  • Add new MCP tools
  • Improve the Azure deployment template
  • Submit issues and suggestions

Ready to deploy? Run azd up and have your MCP weather server live on Azure in minutes! 🚀

� License

MIT License - feel free to use this project for your own applications.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选