MCP Weather Server

MCP Weather Server

Provides hourly weather forecasts using the AccuWeather API, including current conditions and 12-hour forecast with precipitation details.

Category
访问服务器

README

MCP Weather Server

A simple MCP server that provides hourly weather forecasts using the AccuWeather API.

Setup

  1. Install dependencies using uv:
uv venv
uv sync
  1. Create a .env file with your AccuWeather API key:
ACCUWEATHER_API_KEY=your_api_key_here

You can get an API key by registering at AccuWeather API.

Running the Server

STDIO Mode (Default)

For local MCP client connections via stdio:

{
    "mcpServers": {
        "weather": {
            "command": "uvx",
            "args": ["--from", "git+https://github.com/adhikasp/mcp-weather.git", "mcp-weather"],
            "env": {
                "ACCUWEATHER_API_KEY": "your_api_key_here"
            }
        }
    }
}

HTTP Streaming Mode

To run the server as a streamable HTTP server:

Option 1: Using the command line

python -m mcp_weather.weather --http

Option 2: Using the entry point

mcp-weather-http

Option 3: Using environment variables

export MCP_HOST=0.0.0.0
export MCP_PORT=8000
python -m mcp_weather.weather --http

The server will start on http://0.0.0.0:8000 (or your specified host/port) and expose the MCP endpoint at /mcp. The streamable-http transport supports:

  • JSON responses for standard requests
  • Server-Sent Events (SSE) for streaming long-running operations
  • Remote access via HTTP endpoints
  • Horizontal scaling with load balancing

Connecting to HTTP Server:

For MCP clients that support HTTP transport, configure the connection URL:

http://localhost:8000/mcp

Agent UI Configuration:

When configuring your MCP server in the Agent UI (e.g., Cursor, Claude Desktop, etc.):

  • URL: Provide the full endpoint URL (e.g., http://localhost:8000/mcp or https://your-ngrok-url.ngrok.io/mcp)
  • Authentication: Not required by default - No API keys, tokens, or scopes need to be configured in the Agent UI
  • Headers: No custom headers needed for basic operation

The MCP protocol handles communication automatically. Your AccuWeather API key is stored server-side and never needs to be shared with the client.

Note: If you implement custom authentication (API keys, tokens) at the HTTP layer for production use, you would configure those in your server code, not in the Agent UI. The Agent UI would then need to include those credentials in HTTP requests, but this is not needed for basic operation.

Production Deployment:

For production, you can use environment variables or configure a reverse proxy:

# Set custom host and port
export MCP_HOST=0.0.0.0
export MCP_PORT=8080
mcp-weather-http

Exposing via Public URL (Tunneling)

To make your local server accessible via a public URL, use a tunneling service:

Option 1: ngrok (Recommended)

  1. Install ngrok on Windows:

    Option A: Using winget (Windows 10/11 - Recommended)

    winget install ngrok.ngrok
    

    Option B: Using Chocolatey (if you have Chocolatey installed)

    choco install ngrok
    

    Option C: Manual Download

    • Go to ngrok.com/download
    • Download the Windows ZIP file
    • Extract ngrok.exe to a folder (e.g., C:\ngrok)
    • Add that folder to your PATH, or run ngrok from that folder
    • Or simply run: .\ngrok.exe http 8000 from the extracted folder

    Option D: Using Scoop (if you have Scoop installed)

    scoop install ngrok
    

    After installation, verify it works:

    ngrok version
    
  2. Start your MCP server:

    python -m mcp_weather.weather --http
    
  3. Create a tunnel (in a separate terminal):

    ngrok http 8000
    
  4. Use the public URL: ngrok will provide a public URL like https://abc123.ngrok-free.dev.

    Important: The MCP endpoint is at /mcp, not the root URL. Use:

    https://abc123.ngrok-free.dev/mcp
    

    Note about ngrok warning page: Free ngrok accounts show a warning page when visiting the root URL. This is normal and expected. The /mcp endpoint will work correctly for MCP clients. To remove the warning page, you can:

    • Upgrade to a paid ngrok account
    • Set the ngrok-skip-browser-warning header in your MCP client (if supported)
    • Use a custom domain with a paid account

    For a custom domain (requires paid ngrok account):

    ngrok http 8000 --domain=your-custom-domain.ngrok.io
    

Option 2: Cloudflare Tunnel (cloudflared)

  1. Install cloudflared: Download from developers.cloudflare.com

  2. Start your MCP server:

    python -m mcp_weather.weather --http
    
  3. Create a tunnel (in a separate terminal):

    cloudflared tunnel --url http://localhost:8000
    
  4. Use the public URL: Cloudflare will provide a public URL like https://random-subdomain.trycloudflare.com. Your MCP endpoint will be:

    https://random-subdomain.trycloudflare.com/mcp
    

Option 3: localtunnel

  1. Install localtunnel:

    npm install -g localtunnel
    
  2. Start your MCP server:

    python -m mcp_weather.weather --http
    
  3. Create a tunnel (in a separate terminal):

    lt --port 8000
    
  4. Use the public URL: localtunnel will provide a public URL like https://random-name.loca.lt. Your MCP endpoint will be:

    https://random-name.loca.lt/mcp
    

Security Note: When exposing your server publicly, consider:

  • Adding authentication/API keys if your MCP server handles sensitive data
  • Using HTTPS (all tunneling services above provide HTTPS)
  • Limiting access to specific IPs if possible
  • Monitoring usage and rate limiting

API Usage

Get Hourly Weather Forecast

Response:

{
    "location": "Jakarta",
    "location_key": "208971",
    "country": "Indonesia",
    "current_conditions": {
        "temperature": {
            "value": 32.2,
            "unit": "C"
        },
        "weather_text": "Partly sunny",
        "relative_humidity": 75,
        "precipitation": false,
        "observation_time": "2024-01-01T12:00:00+07:00"
    },
    "hourly_forecast": [
        {
            "relative_time": "+1 hour",
            "temperature": {
                "value": 32.2,
                "unit": "C"
            },
            "weather_text": "Partly sunny",
            "precipitation_probability": 40,
            "precipitation_type": "Rain",
            "precipitation_intensity": "Light"
        }
    ]
}

The API provides:

  • Current weather conditions including temperature, weather description, humidity, and precipitation status
  • 12-hour forecast with hourly data including:
    • Relative time from current time
    • Temperature in Celsius
    • Weather description
    • Precipitation probability, type, and intensity

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选