云原生架构MCP服务器
MCP(模型上下文协议)服务器,提供为云原生基础设施生成架构图的工具:
- Kubernetes 集群图
- 亚马逊云服务 基础设施图
- 谷歌云平台 基础设施图
使用 图表 库以编程方式创建专业的可视化架构图。
特性
- 三种专用工具 适用于不同的云平台
- 可视化图表生成 使用适当的云提供商图标
- 集群/VPC分组 支持组织组件
- 连接映射 组件之间
- 以图像形式返回图表 直接在MCP响应中
安装
来自PyPI(推荐)```bash
pip install cloud-native-architecture-mcp
或与 `uvx` 对于按需执行:```bash
uvx cloud-native-architecture-mcp
来源```bash
git clone https://github.com/yourusername/cloud-native-architecture-mcp-server
cd cloud-native-architecture-mcp-server
pip install -e .
## 先决条件
此程序包需要 **Graphviz** 要安装在您的系统上:
**macOS:**```bash
brew install graphviz
Ubuntu/Debian:```bash
sudo apt-get install graphviz
**窗户:**
下载自 graphviz.org
## 与MCP客户端一起使用
### 克劳德桌面
添加到您的 `claude_desktop_config.json`:```json
{
"mcpServers": {
"cloud-architecture": {
"command": "uvx",
"args": ["cloud-native-architecture-mcp"]
}
}
}
代理网关
添加到AgentGateway配置中:```yaml
mcp_servers:
- name: cloud-architecture
stdio:
cmd: uvx
args: ["cloud-native-architecture-mcp"]
## 可用工具
### 1.构建kubernetes图
构建Kubernetes架构图,支持:
- 部署、状态集、守护集、作业、Pod
- 服务,入口
- PVC、PV、存储类
- 配置地图,秘密
- HPA(水平吊舱自动缩放器)
- 命名空间群集
**输入示例:**```json
{
"name": "microservices-app",
"components": [
{"type": "deployment", "name": "api-server", "replicas": 3},
{"type": "service", "name": "api-svc"},
{"type": "ingress", "name": "main-ingress"},
{"type": "deployment", "name": "worker", "replicas": 2},
{"type": "pvc", "name": "shared-storage"}
],
"clusters": [
{
"name": "Production Namespace",
"components": ["api-server", "api-svc", "worker"]
}
],
"connections": [
{"from": "main-ingress", "to": "api-svc", "label": "HTTPS"},
{"from": "api-svc", "to": "api-server"},
{"from": "api-server", "to": "shared-storage"}
]
}
2.构建aws图
构建AWS基础架构图,支持:
- 计算:EC2、ECS、EKS、Lambda
- 数据库:RDS、DynamoDB、ElastiCache、Redshift
- 存储:S3、EBS、EFS
- 网络:ALB、NLB、ELB、CloudFront、Route53、VPC
- 集成:SQS、SNS、EventBridge
- VPC分组
输入示例:```json
{
"name": "webapp-infrastructure",
"components": [
{"type": "route53", "name": "dns"},
{"type": "alb", "name": "load-balancer"},
{"type": "ec2", "name": "web-server"},
{"type": "rds", "name": "postgres-db"},
{"type": "s3", "name": "assets-bucket"},
{"type": "elasticache", "name": "redis-cache"}
],
"vpcs": [
{
"name": "Production VPC",
"components": ["web-server", "postgres-db", "redis-cache", "load-balancer"]
}
],
"connections": [
{"from": "dns", "to": "load-balancer"},
{"from": "load-balancer", "to": "web-server"},
{"from": "web-server", "to": "postgres-db"},
{"from": "web-server", "to": "redis-cache"},
{"from": "web-server", "to": "assets-bucket"}
]
}
### 3.构建gcp图
构建GCP基础设施图,支持:
- 计算:GCE、GKE、云函数
- 数据库:云SQL、Firestore、BigTable、Spanner
- 存储:GCS,持久磁盘
- 网络:负载均衡、云DNS、VPC
- 分析:BigQuery、数据流、发布/订阅
- VPC/网络分组
**输入示例:**```json
{
"name": "data-processing-pipeline",
"components": [
{"type": "gcs", "name": "input-bucket"},
{"type": "functions", "name": "process-files"},
{"type": "pubsub", "name": "events"},
{"type": "dataflow", "name": "etl-pipeline"},
{"type": "bigquery", "name": "data-warehouse"}
],
"connections": [
{"from": "input-bucket", "to": "process-files", "label": "trigger"},
{"from": "process-files", "to": "events"},
{"from": "events", "to": "etl-pipeline"},
{"from": "etl-pipeline", "to": "data-warehouse"}
]
}
发展
设置开发环境```bash
Clone the repository
git clone https://github.com/yourusername/cloud-native-architecture-mcp-server
cd cloud-native-architecture-mcp-server
Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install in development mode with dev dependencies
pip install -e ".[dev]"
### 本地测试
您可以直接测试MCP服务器:```bash
# Run the server
python -m cloud_native_architecture_mcp.server
或者与MCP Inspector等MCP客户端一起使用:```bash
npx @modelcontextprotocol/inspector uvx cloud-native-architecture-mcp
## 发布到PyPI
### 先决条件
1. 在以下位置创建帐户:
- PyPI (生产)
- TestPyPI (测试)
1. 安装构建工具:```bash
pip install build twine
构建和发布
- 构建包:```bash
python -m build
2. **首先在TestPyPI上进行测试:**```bash
twine upload --repository testpypi dist/*
- 从TestPyPI安装以验证:```bash
pip install --index-url https://test.pypi.org/simple/ cloud-native-architecture-mcp
4. **发布到PyPI:**```bash
twine upload dist/*
- 验证安装:```bash
pip install cloud-native-architecture-mcp
## 建筑```
cloud-native-architecture-mcp-server/
├── src/
│ └── cloud_native_architecture_mcp/
│ ├── __init__.py
│ └── server.py # Main MCP server implementation
├── pyproject.toml # Package configuration
├── README.md
└── LICENSE
运作原理
- MCP客户端 (Claude Desktop、AgentGateway等)调用三个工具之一
- MCP服务器 接收组件配置(JSON)
- 图表库 使用Graphviz生成架构图
- 服务器返回 图为base64编码的PNG图像
- 客户端显示 用户的可视化图表
贡献
欢迎投稿!请随时提交拉取请求。
许可证
MIT许可证-请参阅 许可证 详细信息文件
教育
资源
- MCP文件
- 图表文档
- PyPI出版指南
支持
有关问题、疑问或贡献,请访问 GitHub存储库.
为什么有这么多JSON?
MCP通过JSON-RPC协议进行通信。MCP服务器中的所有工具、参数和响应都以JSON格式传输。如果JSON不存在,MCP客户端将不知道要发送什么参数以及工具实际做什么。JSON-RPC是MCP通信协议
