Skip to main content
Glama

export_architecture

Export an architecture specification to Terraform, CloudFormation, Mermaid, D2, or other formats. Get ready-to-write IaC code, diagrams, or audit artifacts from your ArchSpec.

Instructions

Export an architecture spec to Terraform, CloudFormation, Mermaid, D2, or other formats.

Returns {'format': str, 'content': str} where content is the ready-to-write payload. Terraform/CFN outputs use variables for sensitive values (no hardcoded credentials), include provider blocks with region configuration, and generate data sources for VPC/subnet discovery.

When to use: You have a finalized ArchSpec and need IaC code, a diagram, or an audit artifact. For multi-format export, call once per format.

Behavior: Pure computation — no LLM, no network. Does not write files or deploy; the caller is responsible for persisting or applying the returned content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
spec_jsonYesArchSpec to export. Components are translated to provider-native resources; connections become security-group / firewall / IAM rules.
formatNoTarget output format. Values: 'terraform' (HCL with provider blocks, 24 AWS / 11 GCP / 10 Azure resource types), 'cloudformation' (YAML template with Parameters/Outputs), 'mermaid' (tier-grouped flowchart), 'd2' (D2 diagram), 'sbom' (CycloneDX 1.5 service bill of materials), 'aibom' (OWASP AI bill of materials), 'compliance' (audit-ready markdown report).terraform

Implementation Reference

  • The main handler function 'export_architecture' that accepts an ArchSpec dict and format string, validates the spec, calls export_spec(), and returns the result.
    @mcp.tool()
    def export_architecture(
        spec_json: Annotated[
            dict,
            Field(
                description=(
                    "ArchSpec to export. Components are translated to provider-native "
                    "resources; connections become security-group / firewall / IAM rules."
                ),
            ),
        ],
        format: Annotated[
            str,
            Field(
                description=(
                    "Target output format. "
                    "Values: 'terraform' (HCL with provider blocks, 24 AWS / 11 GCP / 10 "
                    "Azure resource types), 'cloudformation' (YAML template with "
                    "Parameters/Outputs), 'mermaid' (tier-grouped flowchart), "
                    "'d2' (D2 diagram), 'sbom' (CycloneDX 1.5 service bill of materials), "
                    "'aibom' (OWASP AI bill of materials), 'compliance' (audit-ready "
                    "markdown report)."
                ),
                examples=["terraform", "cloudformation", "mermaid", "d2", "sbom"],
            ),
        ] = "terraform",
    ) -> dict:
        """Export an architecture spec to Terraform, CloudFormation, Mermaid, D2, or other formats.
    
        Returns `{'format': str, 'content': str}` where `content` is the
        ready-to-write payload. Terraform/CFN outputs use variables for sensitive
        values (no hardcoded credentials), include provider blocks with region
        configuration, and generate data sources for VPC/subnet discovery.
    
        When to use: You have a finalized ArchSpec and need IaC code, a diagram,
        or an audit artifact. For multi-format export, call once per `format`.
    
        Behavior: Pure computation — no LLM, no network. Does not write files or
        deploy; the caller is responsible for persisting or applying the returned
        content.
        """
        from cloudwright.exporter import export_spec
        from cloudwright.spec import ArchSpec
    
        spec = ArchSpec.model_validate(spec_json)
        content = export_spec(spec, fmt=format)
        return {"format": format, "content": content}
  • Pydantic input schema for 'export_architecture': spec_json (dict) and format (str with default 'terraform' and examples).
    def export_architecture(
        spec_json: Annotated[
            dict,
            Field(
                description=(
                    "ArchSpec to export. Components are translated to provider-native "
                    "resources; connections become security-group / firewall / IAM rules."
                ),
            ),
        ],
        format: Annotated[
            str,
            Field(
                description=(
                    "Target output format. "
                    "Values: 'terraform' (HCL with provider blocks, 24 AWS / 11 GCP / 10 "
                    "Azure resource types), 'cloudformation' (YAML template with "
                    "Parameters/Outputs), 'mermaid' (tier-grouped flowchart), "
                    "'d2' (D2 diagram), 'sbom' (CycloneDX 1.5 service bill of materials), "
                    "'aibom' (OWASP AI bill of materials), 'compliance' (audit-ready "
                    "markdown report)."
                ),
                examples=["terraform", "cloudformation", "mermaid", "d2", "sbom"],
            ),
        ] = "terraform",
    ) -> dict:
  • Registration: the 'export' module is mapped in _GROUPS dict and registered via module.register(mcp) in create_server.
    _GROUPS = {
        "design": design,
        "cost": cost,
        "validate": validate,
        "analyze": analyze,
        "export": export,
        "session": session,
    }
  • Helper imports: ArchSpec.model_validate() for validation and export_spec() for the core export logic, imported from cloudwright.spec and cloudwright.exporter respectively.
    from cloudwright.exporter import export_spec
    from cloudwright.spec import ArchSpec
    
    spec = ArchSpec.model_validate(spec_json)
    content = export_spec(spec, fmt=format)
    return {"format": format, "content": content}
Behavior5/5

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

No annotations provided; description fully discloses behavior: pure computation, no LLM/network, does not write files or deploy, and details about sensitive value handling. No contradictions.

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

Conciseness5/5

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

Well-structured with purpose, return value details, behavioral notes, and usage guideline. Each sentence adds value; no unnecessary information.

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

Completeness5/5

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

Given two well-documented parameters, no output schema but description covers return structure, usage, and behavior. Complete enough for agent to select and invoke correctly.

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

Parameters4/5

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

Schema coverage is 100% with detailed parameter descriptions. Description adds context about return format ('Returns {'format': str, 'content': str}') and guarantees (no hardcoded credentials), providing value beyond schema.

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?

Clearly states the tool exports an architecture spec to multiple formats (Terraform, CloudFormation, Mermaid, etc.). Distinguishes from sibling tools like design_architecture and modify_architecture.

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?

Explicitly provides when-to-use guidance: 'You have a finalized ArchSpec and need IaC code, a diagram, or an audit artifact.' Also advises calling once per format for multi-format export.

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/xmpuspus/cloudwright'

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