AQICN MCP サーバー
これは、世界大気質指標(AQICN)プロジェクトの大気質データツールを提供するモデルコンテキストプロトコル(MCP)サーバーです。これにより、LLMは世界中の都市と座標のリアルタイム大気質データを取得できます。
インストール
Smithery経由でインストール
Smithery経由で Claude Desktop 用の AQICN MCP Server を自動的にインストールするには:
npx -y @smithery/cli install @mattmarcin/aqicn-mcp --client claude推奨UV(手動)によるインストール
Python 環境を管理するには、 uvを使用することをお勧めします。
# Install the package and dependencies
uv pip install -e .Related MCP server: Weather MCP Tool
環境設定
プロジェクト ルートに.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 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 ライセンスに基づいてライセンスされています。