MCP Weather Server Be368edc

MCP地图位置

提供方 ramonbnuezjr

地图位置 stdio · 本地进程 API Key 社区 / 第三方 VS Code
查看接入方式

一个基于MCP协议的天气数据服务器,提供标准化的天气信息查询接口,适用于AI代理或客户端应用获取天气数据。

一句话选型结论

按资料字段整理

MCP Weather Server Be368edc 属于地图位置类 MCP 服务器,stdio · 本地进程,API Key,可直接接入 VS Code,有可直接复制的远程端点配置。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类地图位置 传输方式stdio · 本地进程 鉴权API Key 部署方式支持远程部署
GitHub 星标 0 仓库热度,无公开仓库时显示未标注
工具数 1 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

地图位置
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量1暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

支持客户端

适用场景

天气服务Python本地部署数据抽象API集成标准化协议异步处理

安装与配置

stdio · 本地进程 API Key
客户端在本机拉起子进程,数据不出本机
python3 -m venv venv

这条命令只是入口,具体启动参数请按官方文档补齐,不要直接照搬到别的服务器。

  1. 1
    准备运行环境

    确认你的客户端支持远程端点,并拿到服务地址。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后客户端会列出约 1 个工具,随便调一个只读工具确认能返回结果。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
地址与路线

查地址、算路线、找附近地点。

位置检索

按区域筛门店、站点与设施。

地理数据

拉取经纬度、行政区等地理信息。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 资料标注 1 个工具,职责相对集中,接入后不容易误操作。
  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已适配 VS Code,换客户端不用重新研究配置。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 使用前要准备好API Key对应的凭据,并按最小权限配置。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在地图位置场景里让模型直接调用外部能力的人。
  • 已经在用 VS Code 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 不方便管理密钥或第三方授权的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
MCP Weather Server Be368edc当前 1 stdio · 本地进程 支持远程部署 有 2026-05-17
MCP Server C2f246e3 20 stdio · 本地进程 本地部署 有 2026-05-17
OpenStreetMap MCP Server 12 stdio · 本地进程 本地部署 有 2026-05-18
Baidu Maps 10 stdio · 本地进程 本地部署 有 2026-05-17
Google Maps (google-maps-aa2563d3) 7 未标注 未标注 无 2026-05-17
generative-ai 未标注 stdio · 本地进程 本地部署 有 2026-04-17

服务器档案

地图位置
字段来自项目仓库与公开索引,中文说明由本站标注
提供方ramonbnuezjr上游标注的维护方 ramonbnuezjr
分类地图位置本站按上游分类展示
连接方式stdio · 本地进程客户端在本机拉起子进程,数据不出本机
鉴权方式API Key远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · Python本地安装时用到的包标识与运行时
部署类型支持远程部署上游给出的部署形态
最近核验2026-05-17上游最后核验时间

详细介绍

10.3 KB
来自项目仓库与上游目录的原文,未做删改

MCP Weather Server

Project Overview

This project implements a Model Context Protocol (MCP) server designed to provide current weather information for a given location. It acts as a standardized interface, enabling AI agents or other client applications to fetch weather data without needing to interact directly with various external weather APIs. The core idea is to abstract the complexities of external services, offering a consistent protocol for data retrieval and error handling.

The server is built using Python with the FastAPI framework and currently retrieves weather data from the OpenWeatherMap API. While this project focuses on a weather tool, the MCP architecture is designed to be extensible, serving as a standardized gateway for an AI agent to access various tools and APIs (both internal and external) through a consistent protocol.

Key Features:

  • Standardized MCP Interface: Adheres to a defined request/response structure (using Pydantic models) for easy integration.
  • Weather Data Retrieval: Fetches current temperature, conditions, humidity, wind speed, and pressure.
  • Abstraction of External API: Shields the client from the specifics of the OpenWeatherMap API.
  • Error Handling: Provides clear, standardized MCP error messages for issues like invalid locations or API key problems.
  • Asynchronous Operations: Uses httpx for non-blocking calls to the external weather API.
  • Data Validation: Leverages Pydantic for request and response data validation.
  • Configuration Management: Loads sensitive configurations (like API keys) from a .env file.
  • Comprehensive Testing: Includes a client simulation script and a pytest suite for unit and integration tests.
  • Simple Agent CLI: A command-line interface (weather_agent_cli.py) demonstrates how an agent can interact with this MCP server.

Architecture

The server facilitates communication as follows:

  1. Client (AI Agent/Test Script) sends an MCP-formatted JSON request to the /mcp/weather endpoint.
  2. MCP Weather Server (this application) parses the request and extracts necessary parameters (e.g., location).
  3. The MCP server's "weather tool" handler calls the OpenWeatherMap API with the location and its configured API key.
  4. OpenWeatherMap returns the raw weather data.
  5. The MCP server transforms this raw data into the standardized MCP response format.
  6. The MCP server sends the MCP-formatted JSON response back to the client.```
    sequenceDiagram
    participant Client as AI Agent / Test Script
    participant MCPServer as MCP Weather Server (FastAPI)
    participant ExtWeatherAPI as OpenWeatherMap API

    Client->>+MCPServer: 1. Request Weather (MCP Format via HTTP POST)
    MCPServer->>+ExtWeatherAPI: 2. Fetch Weather Data (HTTP GET with API Key)
    ExtWeatherAPI-->>-MCPServer: 3. Weather Data Response (JSON)
    MCPServer-->>-Client: 4. Weather Information (MCP Format via HTTP Response)


## Prerequisites

- Python 3.8+ (Python 3.13 used during development)
- An API key from OpenWeatherMap (for the "Current Weather Data" API).

## Setup and Installation

1. **Clone the repository (if applicable):**```
    git clone <your-repository-url>
    cd mcp-weather-server

    ```

2. **Create and activate a virtual environment:**```
    python3 -m venv venv
    source venv/bin/activate  # On macOS/Linux
    # For Windows (Command Prompt): venv\Scripts\activate.bat
    # For Windows (PowerShell): venv\Scripts\Activate.ps1

    ```

3. **Install dependencies:**
Ensure you have a `requirements.txt` file (see "Project Structure" below for typical contents). Then run:```
    pip install -r requirements.txt

    ```

4. **Configure API Key:**
    - Create a `.env` file in the root of the project directory (e.g., `mcp-weather-server/.env`).
    - Add your OpenWeatherMap API key to it:```
        # .env
        OPENWEATHERMAP_API_KEY="YOUR_ACTUAL_API_KEY_HERE"

        ```

    - **Important:** Ensure `.env` is listed in your `.gitignore` file to prevent committing your API key to version control.

## Running the MCP Server

1. Ensure your virtual environment is activated.
2. Navigate to the project root directory (`mcp-weather-server`).
3. Start the server using Uvicorn:```
    uvicorn app.main:app --reload --port 8000

    ```

    - `app.main:app`: Points to the `app` FastAPI instance in `app/main.py`.
    - `-reload`: Enables auto-reloading during development. The server will restart if code changes are detected.
    - `-port 8000`: Specifies the port on which the server will listen.

The server will be accessible at `http://localhost:8000`.

## API Documentation (Auto-Generated)

FastAPI automatically generates interactive API documentation:

- **Swagger UI:** http://localhost:8000/docs
- **ReDoc:** http://localhost:8000/redoc

These interfaces allow you to view detailed endpoint information, schemas, and try out the API directly from your browser.

## API Endpoint

### Get Current Weather

- **URL:** `/mcp/weather`
- **Method:** `POST`
- **Request Body (JSON - MCP Format):**```
    {
      "protocol_version": "1.0",
      "tool_id": "weather_tool",
      "method": "get_current_weather",
      "parameters": {
        "location": "CityName,CountryCode" // e.g., "London,UK" or "Paris"
      }
    }

    ```

- **Success Response (HTTP 200 OK - MCP Format):**```
    {
      "protocol_version": "1.0",
      "tool_id": "weather_tool",
      "status": "success",
      "data": {
        "location": "London",
        "temperature_celsius": 15.5,
        "temperature_fahrenheit": 59.9,
        "condition": "Clouds",
        "description": "Broken clouds",
        "humidity_percent": 75.0,
        "wind_kph": 10.8,
        "pressure_hpa": 1012.0
      },
      "error_message": null
    }

    ```

- **Application Error Response (HTTP 200 OK with error status - MCP Format):**
(The MCP server returns HTTP 200 even for application-level errors, with the error details in the payload)```
    {
      "protocol_version": "1.0",
      "tool_id": "weather_tool",
      "status": "error",
      "data": null,
      "error_message": "Weather data not found for location: InvalidCity."
    }

    ```

## Testing

This project includes multiple ways to test the application:

### 1. Manual Testing with `curl` or API Clients

You can send POST requests to the `/mcp/weather` endpoint using `curl` or tools like Postman or Insomnia.
**Example `curl` command:**```
curl -X POST "http://localhost:8000/mcp/weather" \
-H "Content-Type: application/json" \
-d '{
      "protocol_version": "1.0",
      "tool_id": "weather_tool",
      "method": "get_current_weather",
      "parameters": {
        "location": "Berlin,DE"
      }
    }'

2. End-to-End Client Simulation (test_mcp_client.py)

A Python script (test_mcp_client.py) located in the project root simulates a client making various requests to the running MCP server. This is useful for quick end-to-end checks.

  • To Run:
    1. Ensure your MCP server is running (see "Running the MCP Server").
    2. Activate your virtual environment.
    3. In a separate terminal, from the project root, run:```
      python3 test_mcp_client.py

      ```

3. Automated Tests with pytest

The project uses pytest for unit and integration tests of the server's components. These tests are located in the tests/ directory and cover API endpoints (with mocked services) and service layer logic (with mocked external HTTP calls).

  • Setup:pytest and pytest-asyncio should be listed in your requirements.txt and installed during the initial setup.
  • To Run:
    1. Activate your virtual environment.
    2. From the project root, run:```
      pytest

      ```

      Or for more verbose output:```
      pytest -v

      ```

Simple AI Agent CLI (weather_agent_cli.py)

A command-line interface (CLI) agent (weather_agent_cli.py) is provided in the project root to demonstrate how an agent can interact with the MCP Weather Server. It takes simple text commands to fetch and display weather information.

  • To Run:

    1. Ensure your MCP server is running (see "Running the MCP Server").
    2. Activate your virtual environment.
    3. In a separate terminal, from the project root, run:```
      python3 weather_agent_cli.py

      ```

    4. Follow the prompts. Example commands: weather in London, weather Tokyo, quit.

Project Structure```

mcp-weather-server/
├── .vscode/ # VS Code specific settings (optional)
│ └── settings.json
├── app/ # Main application source code
│ ├── init.py
│ ├── main.py # FastAPI app instance, MCP endpoint(s)
│ ├── models.py # Pydantic models for MCP & data structures
│ ├── services.py # Business logic (e.g., calling weather API)
│ └── core/
│ ├── init.py
│ └── config.py # Configuration management (e.g., API keys)
├── tests/ # Automated pytest tests
│ ├── init.py
│ ├── test_main.py # Tests for API endpoints (app.main)
│ └── test_services.py # Unit tests for service logic (app.services)
├── .env # Local environment variables (API_KEY) - NOT COMMITTED
├── .gitignore # Specifies intentionally untracked files by Git
├── CHANGELOG.md # Log of notable project changes
├── requirements.txt # Python dependencies for the project
├── README.md # This file (main project documentation)
├── weather_agent_cli.py # Simple CLI agent for demonstration
├── test_mcp_client.py # End-to-end client simulation script
└── venv/ # Python virtual environment directory

```

Future Enhancements (Potential Ideas)

  • Support for more weather data points (e.g., multi-day forecasts, UV index).
  • Add more tools to the MCP server (e.g., news, calculator, calendar).
  • Implement more sophisticated error handling and detailed logging.
  • Dockerize the application for easier deployment and portability.
  • Develop a more advanced AI agent with better NLP capabilities.
  • Add authentication/authorization to the MCP server if it were to be exposed.

License

(Specify a license for your project here, e.g., MIT License. If unsure, you can add "To be determined" or research common open-source licenses.)

常见问题

8 问
答案由本站依据条目字段整理,不引用上游原文
MCP Weather Server Be368edc 怎么安装?

在客户端按下面的安装命令接入:python3 -m venv venv。装完在客户端配置里引用同一个包或端点。

MCP Weather Server Be368edc 怎么在 VS Code 里配置?

它的传输方式是stdio · 本地进程,在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,配置才会生效。

MCP Weather Server Be368edc 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

MCP Weather Server Be368edc 需要 API Key 吗?

资料标注需要API Key认证,使用前准备好对应凭据,并按最小权限配置。

MCP Weather Server Be368edc 支持哪些客户端?

资料标注支持 VS Code;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

MCP Weather Server Be368edc 能提供哪些能力?

资料显示约 1 个工具;能力标签包括 位置天气、标准化协议、Python、VS Code。具体工具清单以官方文档为准。

MCP Weather Server Be368edc 需要什么运行环境?

运行时为 Python;属于本地进程,需要在本机装好运行环境。

MCP Weather Server Be368edc 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为stdio · 本地进程。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 2026-05-17。