GCP计算MCP服务器
用于AI代理测试的假冒GCP计算引擎MCP服务器。提供一个包含项目、虚拟机、性能指标和事件日志的完全合成环境。
数据概述
- 5个项目 每个有3-4个区域
- 111个虚拟机 (每个项目12-32个)分布在不同区域
- 24小时性能数据 (CPU、内存、磁盘)间隔5分钟
- 7天的事件日志 (启动、停止、重启、错误事件)
- 所有数据都是确定性的 (种子=42)-每次重启时相同
快速开始```bash
Install dependencies
pip install -r requirements.txt
Run the server
python server.py
服务器运行时间: `http://localhost:8048/mcp`
## 使用MCP检查员进行测试```bash
npx @modelcontextprotocol/inspector http://localhost:8048/mcp
连接到AI代理
添加到MCP服务器配置中:```json
{
"name": "gcp-compute",
"url": "http://localhost:8048/mcp",
"transport": "streamable-http"
}
## 可用工具(13)
### 项目工具
- `tool_list_projects` -列出所有项目及其摘要信息
- `tool_get_project` -获取项目详细信息(支持部分ID匹配)
- `tool_list_users` -列出项目的IAM用户
### 区域工具
- `tool_list_zones` -列出具有VM计数的区域
- `tool_get_zone_summary` -使用VM列表获取区域详细信息
### VM工具
- `tool_list_vms` -列出具有可选筛选器的虚拟机
- `tool_get_vm` -获取完整的VM详细信息
- `tool_search_vms` -跨虚拟机的免费文本搜索
### 性能工具
- `tool_get_vm_performance` -获取性能时间序列(准备好图表)
### 日志工具
- `tool_get_vm_logs` -获取VM事件日志
- `tool_get_recent_events` -跨VM事件查询
### 聚合工具
- `tool_get_project_health` -项目运行状况仪表板
- `tool_get_high_utilization_vms` -查找高利用率虚拟机
## 资源(3)
- `gcp://projects` -所有项目列表
- `gcp://regions` -区域/地区映射
- `gcp://machine-types` -机器类型目录
## 提示(2)
- `vm_fleet_status` -格式化车队状态报告
- `vm_health_report` -带有阈值的健康报告
## 项目结构```
gcp-mcp/
├── server.py # FastMCP app entry point
├── data_generator.py # Fake data generation (seed=42)
├── data_store.py # Singleton in-memory store
├── tools/
│ ├── __init__.py
│ ├── projects.py # Project tools
│ ├── zones.py # Zone tools
│ ├── vms.py # VM tools
│ ├── performance.py # Performance metrics
│ ├── logs.py # Event logs
│ └── aggregates.py # Health/aggregate tools
├── resources.py # MCP resources
├── prompts.py # MCP prompts
├── requirements.txt
└── README.md
查询示例```
"List all projects"
"Show me the health status of project alpha"
"Find VMs with high CPU usage in proj-gamma-5r8t"
"What errors happened in the last 24 hours?"
"Show performance data for vm-abc123"
"Search for VMs tagged with 'http-server'"
```
