CloudGenie MCP服务器
CloudGenie内部开发平台(IDP)Go中的模型上下文协议(MCP)服务器实现。该服务器为AI助手提供了对CloudGenie基础设施管理API的直接访问。
概述
该MCP服务器充当人工智能助手(如Claude)和CloudGenie后端API之间的桥梁,为基础设施供应、资源管理和蓝图操作实现自然语言交互。
特性
- ✅ 完全支持MCP协议(2024-11-05版)
- ✅ 基于stdio传输的JSON-RPC 2.0
- ✅ 完成CloudGenie API集成
- ✅ 蓝图发现和管理
- ✅ 资源CRUD操作
- ✅ 健康监测
- ✅ 基础设施配置工作流
建筑
┌─────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ │ MCP │ │ HTTP │ │
│ AI Assistant│◄───────►│ MCP Server (Go) │◄────────│ CloudGenie API │
│ (Claude) │ stdio │ │ │ Backend │
└─────────────┘ └──────────────────┘ └─────────────────┘安装
先决条件
- 达到1.21或更高
- CloudGenie后端API正在运行(或访问托管实例)
从源代码构建
# Clone the repository
git clone https://github.com/deepakvbansode/idp-cloudgenie-mcp-server.git
cd idp-cloudgenie-mcp-server
# Download dependencies
go mod download
# Build the server
go build -o cloudgenie-mcp-server .配置
环境变量
CLOUDGENIE_BACKEND_URL:CloudGenie后端API的URL(默认值:http://localhost:8080)
例子:
export CLOUDGENIE_BACKEND_URL="https://api.cloudgenie.example.com"
./cloudgenie-mcp-server用法
运行服务器
服务器在stdio模式下运行,通过标准输入/输出进行通信:
./cloudgenie-mcp-serverMCP客户端配置
克劳德桌面
添加到配置文件(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):
{
"mcpServers": {
"cloudgenie": {
"command": "/path/to/cloudgenie-mcp-server",
"env": {
"CLOUDGENIE_BACKEND_URL": "http://localhost:8080"
}
}
}
}其他MCP客户端
对于基于stdio的MCP服务器,请遵循客户的特定配置格式。
可用工具
适用于克劳德桌面 (~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):
{
"mcpServers": {
"cloudgenie": {
"command": "/path/to/cloudgenie-mcp-server"
}
}
}对于其他MCP客户端,遵循其特定的配置格式。
1. cloudgenie_health_check
检查CloudGenie后端API的运行状况。
参数: 无
例子:
{
"name": "cloudgenie_health_check",
"arguments": {}
}2. cloudgenie_get_blueprints
从CloudGenie检索所有可用的蓝图。
参数: 无
退货: 所有蓝图及其详细信息(ID、名称、描述、版本、类别、标签)的列表
例子:
{
"name": "cloudgenie_get_blueprints",
"arguments": {}
}3. cloudgenie_get_blueprint
检索特定蓝图的详细信息。
参数:
id(string,必填):蓝图的唯一标识符
例子:
{
"name": "cloudgenie_get_blueprint",
"arguments": {
"id": "blueprint-123"
}
}4. cloudgenie_get_resources
从CloudGenie检索所有资源。
参数: 无
退货: 所有资源及其详细信息(ID、名称、类型、状态、蓝图ID、时间戳)的列表
例子:
{
"name": "cloudgenie_get_resources",
"arguments": {}
}5. cloudgenie_get_resource
检索特定资源的详细信息。
参数:
id(string,必填):资源的唯一标识符
例子:
{
"name": "cloudgenie_get_resource",
"arguments": {
"id": "resource-456"
}
}6. cloudgenie_create_resource
在CloudGenie中创建新资源。
参数:
name(string,必填):资源的名称type(string,必填):资源的类型(例如,“vm”、“数据库”、“存储”)blueprint_id(string,必填):要使用的蓝图的IDproperties(object,可选):资源的其他属性
例子:
{
"name": "cloudgenie_create_resource",
"arguments": {
"name": "my-database",
"type": "database",
"blueprint_id": "blueprint-123",
"properties": {
"size": "large",
"region": "us-east-1"
}
}
}7. cloudgenie_delete_resource
从CloudGenie中删除资源。
参数:
id(string,必填):要删除的资源的唯一标识符
例子:
{
"name": "cloudgenie_delete_resource",
"arguments": {
"id": "resource-456"
}
}8. cloudgenie_update_resource_status
更新资源的状态。
参数:
id(string,必填):资源的唯一标识符status(字符串,必填):新状态(例如,“正在运行”、“已停止”、“错误”)
例子:
{
"name": "cloudgenie_update_resource_status",
"arguments": {
"id": "resource-456",
"status": "running"
}
}CloudGenie API端点
MCP服务器与以下CloudGenie后端端点集成:
| 端点 | 方法 | 描述 |
|---|---|---|
/v1/healthcheck | GET | 健康检查端点 |
/v1/blueprints | GET | 列出所有蓝图 |
/v1/blueprints/{id} | GET | 按ID获取蓝图 |
/v1/resources | GET | 列出所有资源 |
/v1/resources | POST | 创建新资源 |
/v1/resources/{id} | GET | 按ID获取资源 |
/v1/resources/{id} | DELETE | 删除资源 |
/v1/resources/{id}/status | PATCH | 更新资源状态 |
可用资源
服务器公开以下资源:
cloudgenie://server/info-服务器信息cloudgenie://server/capabilities-服务器功能cloudgenie://docs/api-API文件
服务器提供以下提示模板:
- select_blueprint -帮助用户为其基础设施需求选择合适的蓝图
- 配置资源 -引导用户完成资源配置
- 故障排除_来源 -帮助解决资源问题
- 设计_基础设施 -使用CloudGenie帮助设计基础架构
用例
示例:使用AI创建基础设施
User: "I need to create a PostgreSQL database for my production environment"
AI Assistant (using MCP tools):
1. Calls cloudgenie_get_blueprints() to find database blueprints
2. Identifies the PostgreSQL blueprint
3. Calls cloudgenie_create_resource() with appropriate parameters
4. Returns the created resource details to the user示例:监控资源状态
User: "Show me the status of all my resources"
AI Assistant (using MCP tools):
1. Calls cloudgenie_get_resources() to fetch all resources
2. Formats and presents the resource list with their statuses
3. Can drill down into specific resources using cloudgenie_get_resource()发展
项目结构
idp-cloudgenie-mcp-server/
├── main.go # Main entry point with tool registration
├── go.mod # Go module dependencies
├── cloudgenie/
│ └── client.go # CloudGenie API client
├── mcp/
│ ├── server.go # MCP server implementation
│ └── types.go # MCP protocol type definitions
├── test.sh # Test script
└── README.md # This file建筑
go build -o cloudgenie-mcp-server .测试
使用附带的测试脚本:
./test.sh或者使用JSON-RPC消息手动测试:
# Start the server
./cloudgenie-mcp-server
# Send test requests
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0.0"}}}' | ./cloudgenie-mcp-server测试
JSON-RPC手动测试
您可以通过stdin发送JSON-RPC消息来手动测试服务器:
# Start the server
./cloudgenie-mcp-server
# Send initialization request
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test-client","version":"1.0.0"}}}
# List available tools
{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}
# Call a tool
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"echo","arguments":{"text":"Hello!"}}}协议参考
此服务器实现了模型上下文协议(MCP)规范。支持的主要方法:
initialize-初始化连接tools/list-列出可用工具tools/call-执行工具resources/list-列出可用资源resources/read-阅读资源prompts/list-列出可用提示prompts/get-获取提示模板ping-健康检查
许可证
MIT许可证-有关详细信息,请参阅许可证文件
贡献
欢迎投稿!请随时提交拉取请求。
支持
有关问题和疑问,请在GitHub上打开问题。
