nlimpid
MCP Servernlimpidpublic

mcp weather

使用 MCP 和 Server-Sent Events 实现实时天气数据流的 Python 应用。

Repository Info

0
Stars
0
Forks
0
Watchers
0
Issues
Python
Language
-
License

About This Server

使用 MCP 和 Server-Sent Events 实现实时天气数据流的 Python 应用。

Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.

Documentation

MCP Weather API - Server-Sent Events Demo

A modern Python application demonstrating the use of Message Passing Channel (MCP) with Server-Sent Events for real-time weather data from the Seniverse Weather API.

Features

  • Real-time weather data streaming via Server-Sent Events (SSE)
  • Integration with Seniverse Weather API (心知天气)
  • MCP server implementation with Starlette
  • Modern Python project structure with clean separation of concerns
  • Chinese UI interface for displaying weather data

Project Structure

mcp-weather/
├── server/                   # Server components
│   └── weather.py            # Seniverse Weather API client
├── templates/                # HTML templates
│   └── index.html            # Main UI for weather display
├── static/                   # Static assets (if needed)
├── .env                      # Environment variables
├── main.py                   # Application entry point
├── pyproject.toml            # Project dependencies
└── README.md                 # Project documentation

Requirements

  • Python 3.12 or higher
  • Dependencies:
    • mcp[cli]
    • starlette
    • uvicorn
    • python-dotenv
    • httpx
    • pydantic

Setup

  1. Clone the repository:

    git clone <repository-url>
    cd mcp-weather
    
  2. Create a virtual environment and install dependencies:

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    pip install -e .
    
  3. Get an API key from Seniverse (心知天气):

    • Register at https://seniverse.com/
    • Create a new application to get an API key
  4. Configure your environment variables in the .env file:

    # Replace with your actual API key from Seniverse
    SENIVERSE_API_KEY=your_api_key
    

Running the Application

Start the server:

python main.py

The server will start on http://localhost:8000 by default.

API Endpoints

  • /sse: Connect to the Server-Sent Events stream
  • /messages: POST endpoint for sending messages to the server
  • /: Main web interface for the weather app

MCP Methods

  • weather.current: Get current weather data for a location

    • Parameters:
      • location: City name (e.g., "beijing", "shanghai")
      • language: Response language (optional, default: "zh-Hans")
      • unit: Temperature unit (optional, default: "c")
  • weather.subscribe: Subscribe to weather updates

Seniverse Weather API

This application uses the Seniverse Weather API (心知天气) to retrieve real-time weather data. The API provides:

  • Current weather conditions
  • Temperature, humidity, and wind data
  • Weather forecasts

For more information about the API, visit: https://seniverse.com/api

Example Client Usage

The application includes a web interface accessible at http://localhost:8000/ that demonstrates:

  1. Fetching current weather data for a specified location
  2. Subscribing to weather updates
  3. Displaying weather data in a user-friendly interface

License

MIT License

Quick Start

1

Clone the repository

git clone https://github.com/nlimpid/mcp-weather
2

Install dependencies

cd mcp-weather
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownernlimpid
Repomcp-weather
LanguagePython
License-
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation