Skip to main content
Glama

GCP Diagram MCP Server

Model Context Protocol (MCP) server for GCP Diagrams

This MCP server that seamlessly creates diagrams using the Python diagrams package DSL. This server allows you to generate GCP diagrams, sequence diagrams, flow diagrams, and class diagrams using Python code.

Tests

Prerequisites

  1. Install uv from Astral or the GitHub README

  2. Install Python using uv python install 3.10

  3. Install GraphViz https://www.graphviz.org/

Related MCP server: arch7

Installation

Cursor

VS Code

Install MCP Server

Install on VS Code

Configure the MCP server in your MCP client configuration (e.g., for Google AI Studio CLI, edit your MCP client config):

{
  "mcpServers": {
    "mclabs.gcp-diagram-mcp-server": {
      "command": "uvx",
      "args": ["mclabs.gcp-diagram-mcp-server"],
      "env": {
        "FASTMCP_LOG_LEVEL": "ERROR"
      },
      "autoApprove": [],
      "disabled": false
    }
  }
}

or docker after a successful docker build -t mclabs/gcp-diagram-mcp-server .:

  {
    "mcpServers": {
      "mclabs.gcp-diagram-mcp-server": {
        "command": "docker",
        "args": [
          "run",
          "--rm",
          "--interactive",
          "--env",
          "FASTMCP_LOG_LEVEL=ERROR",
          "mclabs/gcp-diagram-mcp-server:latest"
        ],
        "env": {},
        "disabled": false,
        "autoApprove": []
      }
    }
  }

从本地源代码安装

如果你想从本地源代码安装和开发此 MCP 服务器,请按照以下步骤操作:

1. 克隆仓库

git clone <repository-url>
cd gcp-diagram-mcp-server

2. 安装依赖

# 安装 uv(如果尚未安装)
curl -LsSf https://astral.sh/uv/install.sh | sh

# 安装 Python 和依赖
uv python install 3.10
uv sync

3. 本地开发安装

# 以可编辑模式安装
uv pip install -e .

# 或者安装开发依赖
uv pip install -e ".[dev]"

4. 配置 MCP 客户端

在你的 MCP 客户端配置中,使用本地安装的路径而不是 uvx:

{
  "mcpServers": {
    "gcp-diagram-mcp-server-local": {
      "command": "uv",
      "args": ["run", "--project", "/path/to/gcp-diagram-mcp-server", "mclabs.gcp_diagram_mcp_server"],
      "env": {
        "FASTMCP_LOG_LEVEL": "ERROR"
      },
      "autoApprove": [],
      "disabled": false
    }
  }
}

或者,如果你已经将项目路径添加到 Python 路径中:

{
  "mcpServers": {
    "gcp-diagram-mcp-server-local": {
      "command": "python",
      "args": ["-m", "mclabs.gcp_diagram_mcp_server"],
      "env": {
        "FASTMCP_LOG_LEVEL": "ERROR",
        "PYTHONPATH": "/path/to/gcp-diagram-mcp-server"
      },
      "autoApprove": [],
      "disabled": false
    }
  }
}

5. 验证安装

运行测试以确保一切正常工作:

# 运行所有测试
./run_tests.sh

# 或者直接使用 pytest
uv run pytest -xvs tests/

6. 热重载开发

在开发过程中,你可以使用以下命令直接运行服务器:

# 直接运行服务器
uv run python -m mclabs.gcp_diagram_mcp_server

# 或者使用调试模式
uv run python -m mclabs.gcp_diagram_mcp_server --debug

Features

The Diagrams MCP Server provides the following capabilities:

  1. Generate Diagrams: Create professional diagrams using Python code

  2. Multiple Diagram Types: Support for GCP architecture, sequence diagrams, flow charts, class diagrams, and more

  3. Enhanced GCP Icons: Access to 22+ additional GCP service icons not available in the standard diagrams package

  4. Customization: Customize diagram appearance, layout, and styling

  5. Security: Code scanning to ensure secure diagram generation

Enhanced GCP Icons

This server now includes a curated collection of enhanced GCP service icons that are automatically available when generating diagrams. These icons are implemented as Custom classes and provide access to the latest GCP services:

AI/ML Services:

  • Vertex AI, Vertex AI Agent Builder, Vertex AI Search

  • Dataplex, Analytics Hub, Data QnA

  • Looker, Looker Studio

Database & Integration:

  • Datastream, Database Migration Service

  • Cloud SQL (2nd Gen)

DevOps & CI/CD:

  • Cloud Deploy, Artifact Registry, Batch

  • Migrate to Containers, Infrastructure Manager

Network & CDN:

  • Cloud CDN (new shield), Network Topology

Security & Identity:

  • BeyondCorp Enterprise

Management & Operations:

  • Cost Management, Cloud Monitoring (new)

Maps & Geospatial:

  • Google Maps Platform

These enhanced icons are automatically loaded and can be used just like standard diagram icons:

with Diagram("AI/ML Pipeline", show=False):
    # Enhanced icons - no import needed
    vertex_ai = VertexAI("Vertex AI")
    analytics_hub = AnalyticsHub("Analytics Hub")
    dataplex = Dataplex("Data Lake")
    
    # Standard icons
    from diagrams.gcp.storage import Storage
    storage = Storage("Data Source")
    
    storage >> dataplex >> analytics_hub >> vertex_ai

Quick Example

from diagrams import Diagram
from diagrams.gcp.compute import Functions
from diagrams.gcp.database import Firestore
from diagrams.gcp.network import LoadBalancing

with Diagram("Serverless Application", show=False):
    lb = LoadBalancing("Load Balancer")
    function = Functions("Cloud Function")
    database = Firestore("Firestore")

    lb >> function >> database

Development

Testing

The project includes a comprehensive test suite to ensure the functionality of the MCP server. The tests are organized by module and cover all aspects of the server's functionality.

To run the tests, use the provided script:

./run_tests.sh

This script will automatically install pytest and its dependencies if they're not already installed.

Or run pytest directly (if you have pytest installed):

pytest -xvs tests/

To run with coverage:

pytest --cov=mclabs.gcp_diagram_mcp_server --cov-report=term-missing tests/

For more information about the tests, see the tests README.

Development Dependencies

To set up the development environment, install the development dependencies:

uv pip install -e ".[dev]"

This will install the required dependencies for development, including pytest, pytest-asyncio, and pytest-cov.

Acknowledgments

This project is based on the excellent work from the AWS Labs MCP project. We are grateful to the AWS Labs team for creating the original AWS Diagram MCP Server, which served as the foundation for this GCP version.

Original Project

  • Original Repository: awslabs/mcp

  • Original Package: awslabs.aws-diagram-mcp-server

  • License: Apache License 2.0

Special thanks to the AWS Labs team and all contributors to the original project for their innovative work in creating MCP servers for cloud architecture diagrams.

Available Tools

3 tools
generate_diagramA

Generate a diagram from Python code using the diagrams package.

This tool accepts Python code as a string that uses the diagrams package DSL and generates a PNG diagram without displaying it. The code is executed with show=False to prevent automatic display.

USAGE INSTRUCTIONS: Never import. Start writing code immediately with with Diagram( and use the icons you found with list_icons.

  1. First use get_diagram_examples to understand the syntax and capabilities

  2. Then use list_icons to discover all available icons. These are the only icons you can work with.

  3. You MUST use icon names exactly as they are in the list_icons response, case-sensitive.

  4. Write your diagram code following python diagrams examples. Do not import any additional icons or packages, the runtime already imports everything needed.

  5. Submit your code to this tool to generate the diagram

  6. The tool returns the path to the generated PNG file

  7. For complex diagrams, consider using Clusters to organize components

  8. Diagrams should start with a user or end device on the left, with data flowing to the right.

CODE REQUIREMENTS:

  • Must include a Diagram() definition with appropriate parameters

  • Can use any of the supported diagram components (GCP, K8s, etc.)

  • Can include custom styling with Edge attributes (color, style)

  • Can use Cluster to group related components

  • Can use custom icons with the Custom class

COMMON PATTERNS:

  • Basic: provider.service("label")

  • Connections: service1 >> service2 >> service3

  • Grouping: with Cluster("name"): [components]

  • Styling: service1 >> Edge(color="red", style="dashed") >> service2

IMPORTANT FOR CLINE: Always send the current workspace directory when calling this tool! The workspace_dir parameter should be set to the directory where the user is currently working so that diagrams are saved to a location accessible to the user.

Supported diagram types:

  • GCP architecture diagrams

  • Sequence diagrams

  • Flow diagrams

  • Class diagrams

  • Kubernetes diagrams

  • On-premises diagrams

  • Custom diagrams with custom nodes

Returns: Dictionary with the path to the generated diagram and status information

Inputs: code (required), timeout, filename, workspace_dir.

get_diagram_examplesA

Get example code for different types of diagrams.

This tool provides ready-to-use example code for various diagram types. Use these examples to understand the syntax and capabilities of the diagrams package before creating your own custom diagrams.

USAGE INSTRUCTIONS:

  1. Select the diagram type you're interested in (or 'all' to see all examples)

  2. Study the returned examples to understand the structure and syntax

  3. Use these examples as templates for your own diagrams

  4. When ready, modify an example or write your own code and use generate_diagram

EXAMPLE CATEGORIES:

  • gcp: GCP cloud architecture diagrams (basic services, grouped workers, clustered web services, AI Platform)

  • sequence: Process and interaction flow diagrams

  • flow: Decision trees and workflow diagrams

  • class: Object relationship and inheritance diagrams

  • k8s: Kubernetes architecture diagrams

  • onprem: On-premises infrastructure diagrams

  • custom: Custom diagrams with custom icons

  • all: All available examples across categories

Each example demonstrates different features of the diagrams package:

  • Basic connections between components

  • Grouping with Clusters

  • Advanced styling with Edge attributes

  • Different layout directions

  • Multiple component instances

  • Custom icons and nodes

      Parameters:
    

    diagram_type (str): Type of diagram example to return. Options: gcp, sequence, flow, class, k8s, onprem, custom, all

Returns: Dictionary with example code for the requested diagram type(s), organized by example name

Inputs: diagram_type.

list_iconsA

List available icons from the diagrams package, with optional filtering.

This tool dynamically inspects the diagrams package to find available providers, services, and icons that can be used in diagrams.

USAGE INSTRUCTIONS:

  1. Call without filters to get a list of available providers

  2. Call with provider_filter to get all services and icons for that provider

  3. Call with both provider_filter and service_filter to get icons for a specific service

Example workflow:

  • First call: list_icons() → Returns all available providers

  • Second call: list_icons(provider_filter="gcp") → Returns all GCP services and icons

  • Third call: list_icons(provider_filter="gcp", service_filter="compute") → Returns GCP compute icons

This approach is more efficient than loading all icons at once, especially when you only need icons from specific providers or services.

Returns: Dictionary with available providers, services, and icons organized hierarchically

Inputs: service_filter, provider_filter.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.8/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: listing icons, providing examples, and generating diagrams. No overlap in functionality, making it easy for an agent to select the right tool.

    Naming Consistency5/5

    All tool names follow the verb_noun pattern in snake_case (generate_diagram, get_diagram_examples, list_icons), which is consistent and predictable.

    Tool Count5/5

    With only 3 tools, the server is tightly scoped to its core mission: icon discovery, example learning, and diagram generation. This minimal set avoids unnecessary complexity.

    Completeness5/5

    The tool set covers the full workflow: discover icons, learn syntax via examples, and generate diagrams. There are no missing operations for the stated purpose of creating diagrams.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables users to generate professional AWS architecture diagrams, sequence diagrams, flow charts, and class diagrams using Python code through the diagrams package. Supports customizable styling and secure diagram generation for cloud infrastructure visualization.
      3
      Apache 2.0
    • A
      license
      A
      quality
      D
      maintenance
      Generates Excalidraw architecture diagrams with support for 60+ components including GCP, Kafka, and AI/Agentic shapes. Provides MCP tools for creating, modifying, and converting diagrams from structured input or Mermaid syntax.
      4
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      MCP server for generating diagrams, charts, and visualizations using Gemini image generation on Vertex AI. Supports auto-detection of diagram types, multiple style modes, and iterative refinement.
      3
      58 npm
      1
      MIT