Skip to main content
Glama
lukeburciu

AWS Diagram MCP Server

by lukeburciu

get_diagram_examples

Retrieve example code for AWS architecture, sequence, flow, class, Kubernetes, on-premises, and custom diagrams to understand syntax and structure before creating custom visualizations.

Instructions

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:

  • aws: AWS cloud architecture diagrams (basic services, grouped workers, clustered web services, Bedrock)

  • 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: aws, sequence, flow, class, k8s, onprem, custom, all

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
diagram_typeNoType of diagram example to return. Options: aws, sequence, flow, class, k8s, onprem, custom, allall

Implementation Reference

  • MCP tool handler function for 'get_diagram_examples'. Registered with @mcp.tool decorator. Receives diagram_type parameter and delegates to the core get_diagram_examples function, returning its model_dump().
    @mcp.tool(name='get_diagram_examples')
    async def mcp_get_diagram_examples(
        diagram_type: DiagramType = Field(
            default=DiagramType.ALL,
            description='Type of diagram example to return. Options: aws, sequence, flow, class, k8s, onprem, custom, all',
        ),
    ):
        """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:
        - aws: AWS cloud architecture diagrams (basic services, grouped workers, clustered web services, Bedrock)
        - 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: aws, sequence, flow, class, k8s, onprem, custom, all
    
        Returns:
            Dictionary with example code for the requested diagram type(s), organized by example name
        """
        result = get_diagram_examples(diagram_type)
        return result.model_dump()
  • Core helper function implementing the logic to generate and return example diagram code snippets based on the requested diagram_type. Constructs a dictionary of examples and wraps in DiagramExampleResponse.
    def get_diagram_examples(diagram_type: DiagramType = DiagramType.ALL) -> DiagramExampleResponse:
        """Get example code for different types of diagrams.
    
        Args:
            diagram_type: Type of diagram example to return.
    
        Returns:
            DiagramExampleResponse: Dictionary with example code for the requested diagram type(s)
        """
        examples = {}
    
        # Basic examples
        if diagram_type in [DiagramType.AWS, DiagramType.ALL]:
            examples['aws_basic'] = """with Diagram("Web Service Architecture", show=False):
        ELB("lb") >> EC2("web") >> RDS("userdb")
    """
    
        if diagram_type in [DiagramType.SEQUENCE, DiagramType.ALL]:
            examples['sequence'] = """with Diagram("User Authentication Flow", show=False):
        user = User("User")
        login = InputOutput("Login Form")
        auth = Decision("Authenticated?")
        success = Action("Access Granted")
        failure = Action("Access Denied")
    
        user >> login >> auth
        auth >> success
        auth >> failure
    """
    
        if diagram_type in [DiagramType.FLOW, DiagramType.ALL]:
            examples['flow'] = """with Diagram("Order Processing Flow", show=False):
        start = Predefined("Start")
        order = InputOutput("Order Received")
        check = Decision("In Stock?")
        process = Action("Process Order")
        wait = Delay("Backorder")
        ship = Action("Ship Order")
        end = Predefined("End")
    
        start >> order >> check
        check >> process >> ship >> end
        check >> wait >> process
    """
    
        if diagram_type in [DiagramType.CLASS, DiagramType.ALL]:
            examples['class'] = """with Diagram("Simple Class Diagram", show=False):
        base = Python("BaseClass")
        child1 = Python("ChildClass1")
        child2 = Python("ChildClass2")
    
        base >> child1
        base >> child2
    """
    
        # Advanced examples from the documentation
        if diagram_type in [DiagramType.AWS, DiagramType.ALL]:
            examples[
                'aws_grouped_workers'
            ] = """with Diagram("Grouped Workers", show=False, direction="TB"):
        ELB("lb") >> [EC2("worker1"),
                      EC2("worker2"),
                      EC2("worker3"),
                      EC2("worker4"),
                      EC2("worker5")] >> RDS("events")
    """
    
            examples[
                'aws_clustered_web_services'
            ] = """with Diagram("Clustered Web Services", show=False):
        dns = Route53("dns")
        lb = ELB("lb")
    
        with Cluster("Services"):
            svc_group = [ECS("web1"),
                         ECS("web2"),
                         ECS("web3")]
    
        with Cluster("DB Cluster"):
            db_primary = RDS("userdb")
            db_primary - [RDS("userdb ro")]
    
        memcached = ElastiCache("memcached")
    
        dns >> lb >> svc_group
        svc_group >> db_primary
        svc_group >> memcached
    """
    
            examples['aws_event_processing'] = """with Diagram("Event Processing", show=False):
        source = EKS("k8s source")
    
        with Cluster("Event Flows"):
            with Cluster("Event Workers"):
                workers = [ECS("worker1"),
                           ECS("worker2"),
                           ECS("worker3")]
    
            queue = SQS("event queue")
    
            with Cluster("Processing"):
                handlers = [Lambda("proc1"),
                            Lambda("proc2"),
                            Lambda("proc3")]
    
        store = S3("events store")
        dw = Redshift("analytics")
    
        source >> workers >> queue >> handlers
        handlers >> store
        handlers >> dw
    """
    
            examples[
                'aws_bedrock'
            ] = """with Diagram("S3 Image Processing with Bedrock", show=False, direction="LR"):
        user = User("User")
    
        with Cluster("Amazon S3 Bucket"):
            input_folder = S3("Input Folder")
            output_folder = S3("Output Folder")
    
        lambda_function = Lambda("Image Processor Function")
        bedrock = Bedrock("Claude Sonnet 3.7")
    
        user >> Edge(label="Upload Image") >> input_folder
        input_folder >> Edge(label="Trigger") >> lambda_function
        lambda_function >> Edge(label="Process Image") >> bedrock
        bedrock >> Edge(label="Return Bounding Box") >> lambda_function
        lambda_function >> Edge(label="Upload Processed Image") >> output_folder
        output_folder >> Edge(label="Download Result") >> user
    """
    
        if diagram_type in [DiagramType.K8S, DiagramType.ALL]:
            examples['k8s_exposed_pod'] = """with Diagram("Exposed Pod with 3 Replicas", show=False):
        net = Ingress("domain.com") >> Service("svc")
        net >> [Pod("pod1"),
                Pod("pod2"),
                Pod("pod3")] << ReplicaSet("rs") << Deployment("dp") << HPA("hpa")
    """
    
            examples['k8s_stateful'] = """with Diagram("Stateful Architecture", show=False):
        with Cluster("Apps"):
            svc = Service("svc")
            sts = StatefulSet("sts")
    
            apps = []
            for _ in range(3):
                pod = Pod("pod")
                pvc = PVC("pvc")
                pod - sts - pvc
                apps.append(svc >> pod >> pvc)
    
        apps << PV("pv") << StorageClass("sc")
    """
    
        if diagram_type in [DiagramType.ONPREM, DiagramType.ALL]:
            examples[
                'onprem_web_service'
            ] = """with Diagram("Advanced Web Service with On-Premises", show=False):
        ingress = Nginx("ingress")
    
        metrics = Prometheus("metric")
        metrics << Grafana("monitoring")
    
        with Cluster("Service Cluster"):
            grpcsvc = [
                Server("grpc1"),
                Server("grpc2"),
                Server("grpc3")]
    
        with Cluster("Sessions HA"):
            primary = Redis("session")
            primary - Redis("replica") << metrics
            grpcsvc >> primary
    
        with Cluster("Database HA"):
            primary = PostgreSQL("users")
            primary - PostgreSQL("replica") << metrics
            grpcsvc >> primary
    
        aggregator = Fluentd("logging")
        aggregator >> Kafka("stream") >> Spark("analytics")
    
        ingress >> grpcsvc >> aggregator
    """
    
            examples[
                'onprem_web_service_colored'
            ] = """with Diagram(name="Advanced Web Service with On-Premise (colored)", show=False):
        ingress = Nginx("ingress")
    
        metrics = Prometheus("metric")
        metrics << Edge(color="firebrick", style="dashed") << Grafana("monitoring")
    
        with Cluster("Service Cluster"):
            grpcsvc = [
                Server("grpc1"),
                Server("grpc2"),
                Server("grpc3")]
    
        with Cluster("Sessions HA"):
            primary = Redis("session")
            primary - Edge(color="brown", style="dashed") - Redis("replica") << Edge(label="collect") << metrics
            grpcsvc >> Edge(color="brown") >> primary
    
        with Cluster("Database HA"):
            primary = PostgreSQL("users")
            primary - Edge(color="brown", style="dotted") - PostgreSQL("replica") << Edge(label="collect") << metrics
            grpcsvc >> Edge(color="black") >> primary
    
        aggregator = Fluentd("logging")
        aggregator >> Edge(label="parse") >> Kafka("stream") >> Edge(color="black", style="bold") >> Spark("analytics")
    
        ingress >> Edge(color="darkgreen") << grpcsvc >> Edge(color="darkorange") >> aggregator
    """
    
        if diagram_type in [DiagramType.CUSTOM, DiagramType.ALL]:
            examples['custom_rabbitmq'] = """# Download an image to be used into a Custom Node class
    rabbitmq_url = "https://jpadilla.github.io/rabbitmqapp/assets/img/icon.png"
    rabbitmq_icon = "rabbitmq.png"
    urlretrieve(rabbitmq_url, rabbitmq_icon)
    
    with Diagram("Broker Consumers", show=False):
        with Cluster("Consumers"):
            consumers = [
                Pod("worker"),
                Pod("worker"),
                Pod("worker")]
    
        queue = Custom("Message queue", rabbitmq_icon)
    
        queue >> consumers >> Aurora("Database")
    """
    
        return DiagramExampleResponse(examples=examples)
  • Pydantic Enum defining the possible diagram_type input values for the get_diagram_examples tool.
    class DiagramType(str, Enum):
        """Enum for supported diagram types."""
    
        AWS = 'aws'
        SEQUENCE = 'sequence'
        FLOW = 'flow'
        CLASS = 'class'
        K8S = 'k8s'
        ONPREM = 'onprem'
        CUSTOM = 'custom'
        ALL = 'all'
  • Pydantic model defining the response structure for get_diagram_examples, containing a dictionary of example names to code snippets.
    class DiagramExampleResponse(BaseModel):
        """Response model for diagram examples."""
    
        examples: Dict[str, str]
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes what the tool returns ('ready-to-use example code,' 'Dictionary with example code... organized by example name') and its educational purpose. However, it doesn't mention potential limitations like rate limits, authentication needs, or error conditions. The description adds value but lacks comprehensive behavioral context for a tool with no annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (purpose, usage instructions, example categories, features, parameters, returns) and front-loaded key information. However, it includes some redundancy (e.g., repeating parameter details) and could be more concise by eliminating the bulleted list of features, which adds length without critical information. Most sentences earn their place, but there's minor room for trimming.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is mostly complete. It explains the purpose, usage, parameter options, and return format. The main gap is the lack of output schema, but the description compensates by specifying the return type ('Dictionary with example code...'). It could improve by detailing error cases or example structure, but it's sufficient for this simple tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single parameter (diagram_type) with its options and default. The description repeats this information in the 'Parameters' section and adds context about what each category demonstrates (e.g., 'aws: AWS cloud architecture diagrams'), but doesn't provide significant additional semantics beyond what's in the schema. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get example code for different types of diagrams.' It specifies the verb ('Get') and resource ('example code for different types of diagrams'), and distinguishes it from sibling tools like generate_diagram (which creates diagrams) and list_icons (which lists icons). The description explicitly mentions using these examples before creating custom diagrams with generate_diagram.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage instructions, including when to use this tool ('to understand the syntax and capabilities... before creating your own custom diagrams') and when to use an alternative ('When ready... use generate_diagram'). It also lists example categories and explains how to use the examples as templates, offering clear guidance on tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lukeburciu/aws-diagrams-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server