空气质量数据服务

通过AQICN API提供印度城市的实时空气质量数据,包括AQI、主要污染物和短期预测。

  • by muthumags
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 muthumags/mcp_katas

使用说明

空气质量MCP服务器

这个项目是 FastMCP服务器 它使用 API检验检疫中心。它为您的MCP客户端提供了多种工具:

  • get_air_quality(city) → 当前空气质量指数,主要污染物,空气质量指数类别
  • get_pollutants(city) → 污染物分解(PM2.5、PM10、O₃, NO₂,CO,所以₂,等等)
  • get_forecast(city) → 短期空气质量指数预测(每日最低/平均/最高)

⚡ 需求

  • Python 3.10+
  • 紫外线 包管理器
  • AQICN API代币(在此注册:https://aqicn.org/data-platform/token/)

💾 安装说明

1.️⃣ 克隆/导航到项目文件夹


cd mcp_katas
add .env file and add AQICN_API_TOKEN along with the token 
uv sync
6️⃣ Run the MCP server

uv run main.py
Server will start and expose all tools for MCP clients.

or 
npx @modelcontextprotocol/inspector uv run main.py
MCP Inspector will start


🔧 Example MCP Tool Calls
Get current air quality
json
Copy code
{
  "tool": "get_air_quality",
  "input": { "city": "Chennai" }
}
Get pollutant details
json
Copy code
{
  "tool": "get_pollutants",
  "input": { "city": "Chennai" }
}
Get forecast
json
Copy code
{
  "tool": "get_forecast",
  "input": { "city": "Chennai" }
}
✅ Notes
Free AQICN tokens have request limits — consider caching results if needed.

Use .env and .gitignore to keep your token safe.

Forecast availability depends on city and AQICN coverage.

📚 References
AQICN API Documentation

FastMCP Documentation

uv Package Manager```