全球人工智能MCP-空气质量服务
一种模型上下文协议(MCP)服务器,为地球上任何位置提供空气质量数据。
项目结构
.
├── src/
│ ├── index.ts # Main MCP server entry point
│ └── service/
│ └── aqi.service.ts # Air quality data service
├── build/ # Compiled JavaScript output
├── package.json # Project dependencies
├── tsconfig.json # TypeScript configuration
└── .vscode/
└── mcp.json # MCP server configuration (local only)设置
先决条件
- Node.js 16+
- npm或纱线
安装
- 安装依赖项:
npm install- 构建项目:
npm run buildMCP配置
MCP服务器配置在 .vscode/mcp.json 并且是 未在git中跟踪 (添加到 .gitignore).
配置mcp.json
要在VS Code中使用此MCP服务器,您需要创建/更新 .vscode/mcp.json 具有以下结构:
{
"servers": {
"air-quality": {
"type": "stdio",
"command": "node",
"args": ["/build/index.js"]
}
},
"inputs": []
}配置步骤
- 导航到您的
.vscode项目根目录中的文件夹 - 创建或编辑
mcp.json - 替换 `` 带有项目目录的绝对路径
示例(Windows):
{
"servers": {
"air-quality": {
"type": "stdio",
"command": "node",
"args": ["C:\\Users\\YourUsername\\Desktop\\global-ai\\global-ai-mcp\\build\\index.js"]
}
},
"inputs": []
}示例(macOS/Linux):
{
"servers": {
"air-quality": {
"type": "stdio",
"command": "node",
"args": ["/home/username/projects/global-ai/global-ai-mcp/build/index.js"]
}
},
"inputs": []
}可用工具
获得空气质量
使用纬度和经度检索特定位置的空气质量数据。
参数:
latitude(数字):-90至90longitude(数字):-180至180
例子:
Get air quality for Accra, Ghana (5.6037°N, -0.187°W)退货: PM2.5、PM10、CO、NO2、O3和粉尘水平
发展
构建
npm run build观看模式
npm run build -- --watch重要说明
⚠️ 不要承诺 .vscode/mcp.json -每个开发人员都需要自己的配置和本地绝对路径。此文件已在 .gitignore.
故障排除
MCP服务器未连接
- 验证中的绝对路径
.vscode/mcp.json是正确的 - 确保项目已建成:
npm run build - 检查
build/index.js存在
路径问题
- 始终使用绝对路径
mcp.json - 在Windows上,使用双反斜杠(
\\)在路上 - 在macOS/Linux上,使用正斜杠(
/)
