AQICN MCP Server

by mattmarcin
MIT License
  • Linux
  • Apple

AQICN MCP 服务器

这是一个模型上下文协议 (MCP) 服务器,提供来自世界空气质量指数 (AQICN) 项目的空气质量数据工具。它允许 LLM 获取全球城市和坐标的实时空气质量数据。

安装

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 AQICN MCP 服务器:

npx -y @smithery/cli install @mattmarcin/aqicn-mcp --client claude

通过推荐的 uv 安装(手动)

我们建议使用uv来管理您的 Python 环境:

# Install the package and dependencies uv pip install -e .

环境设置

在项目根目录中创建一个.env文件(您可以从.env.example复制):

# .env AQICN_API_KEY=your_api_key_here

或者,您可以直接设置环境变量:

# Linux/macOS export AQICN_API_KEY=your_api_key_here # Windows set AQICN_API_KEY=your_api_key_here

运行服务器

开发模式

测试和调试服务器的最快方法是使用 MCP Inspector:

mcp dev aqicn_server.py

Claude 桌面集成

服务器准备就绪后,请在 Claude Desktop 中安装它:

mcp install aqicn_server.py

直接执行

对于测试或自定义部署:

python aqicn_server.py

可用工具

1. 城市阿奇

获取特定城市的空气质量数据。

@mcp.tool() def city_aqi(city: str) -> AQIData: """Get air quality data for a specific city."""

输入:

  • city :获取空气质量数据的城市名称

输出: AQIData包含:

  • aqi :空气质量指数值
  • station :车站名称
  • dominant_pollutant :主要污染物(如果有)
  • time :测量的时间戳
  • coordinates :车站的经纬度

2. geo_aqi

使用坐标获取特定位置的空气质量数据。

@mcp.tool() def geo_aqi(latitude: float, longitude: float) -> AQIData: """Get air quality data for a specific location using coordinates."""

输入:

  • latitude :位置的纬度
  • longitude :位置的经度

**输出:**city_aqi相同

3. 搜索站

通过关键词搜索空气质量监测站。

@mcp.tool() def search_station(keyword: str) -> list[StationInfo]: """Search for air quality monitoring stations by keyword."""

输入:

  • keyword :搜索车站的关键字(城市名称、车站名称等)

输出: StationInfo列表,其中包含:

  • name :车站名称
  • station_id :唯一车站标识符
  • coordinates :车站的经纬度

示例用法

使用 MCP Python 客户端:

from mcp import Client async with Client() as client: # Get air quality data for Beijing beijing_data = await client.city_aqi(city="beijing") print(f"Beijing AQI: {beijing_data.aqi}") # Get air quality data by coordinates (Tokyo) geo_data = await client.geo_aqi(latitude=35.6762, longitude=139.6503) print(f"Tokyo AQI: {geo_data.aqi}") # Search for stations stations = await client.search_station(keyword="london") for station in stations: print(f"Station: {station.name} ({station.coordinates})")

贡献

欢迎随时提交问题和拉取请求。请确保您的更改包含适当的测试和文档。

执照

该项目已获得 MIT 许可。

-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

实现与世界空气质量指数的交互,以获取城市的实时空气质量数据并通过模型上下文协议 (MCP) 协调全球。

  1. Installation
    1. Installing via Smithery
    2. Installing via recommended uv (manual)
  2. Environment Setup
    1. Running the Server
      1. Development Mode
      2. Claude Desktop Integration
      3. Direct Execution
    2. Available Tools
      1. 1. city_aqi
      2. 2. geo_aqi
      3. 3. search_station
    3. Example Usage
      1. Contributing
        1. License

          Related MCP Servers

          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol server that retrieves current weather information for specified cities using the Open-Meteo API, requiring no API key.
            Last updated -
            Python
            Apache 2.0
            • Linux
            • Apple
          • -
            security
            F
            license
            -
            quality
            Provides current weather and air quality data for any city using WeatherAPI, easily integrating with MCP clients like n8n and Claude Desktop App.
            Last updated -
            214
            JavaScript
          • -
            security
            -
            license
            -
            quality
            Provides a Model Context Protocol server that enables large language models to query and retrieve real-time weather forecasts for cities and regions across China.
            Last updated -
            Python
          • A
            security
            A
            license
            A
            quality
            Model Context Protocol (MCP) server that provides weather forecast, warnings, water level associated with flood, and earthquake reports from Malaysia Government's Open API.
            Last updated -
            4
            Python
            MIT License

          View all related MCP servers

          ID: pi3py17y7w