DEV Community

Jens Båvenmark for AWS Community Builders

Posted on • Originally published at Medium

Create AWS Diagrams with Kiro

Create AWS Diagrams with Kiro

A short while ago, I wrote a blog post about Creating AWS Diagrams with Python and Amazon Q Developer in the CLI. After posting that blog, I got a question about whether I had tried to do the same with Kiro (Kiro is an AI‑powered IDE from AWS) with AWS MCP for diagrams ( https://awslabs.github.io/mcp/servers/aws-diagram-mcp-server).

I had not, but when I heard about the MCP for Diagrams (which I will refer to as the MCP moving forward), I had to test it and decided to write this blog with the results. The MCP is, as the name states, using the same Python library, Diagrams, as we used in the previous blog to create the diagrams.

Set up the environment

First of all, I want to make it clear that I am a beginner with Kiro, and this was my first “project” with the IDE. So there might be better ways to set this up, but this is how I did it.

We will need to install Kiro. Go to https://kiro.dev/ and follow the instructions to download and install it for your OS.

At the time of writing this blog there is a waitlist to be able to download Kiro.

We then need to install the dependencies of Diagrams, which are Graphviz and Python (I will assume you have Python installed, otherwise, there are many guides on how to install it).

brew install graphviz # For Mac 
Enter fullscreen mode Exit fullscreen mode

If you are not using a Mac, follow the Graphviz instructions on how to install it.

We are then ready to configure Kiro to use the MCP and begin building diagrams.

Getting the MCP configuration

Before we can configure Kiro, we will need the MCPs configuration. For the AWS Diagram MCP Server, it can be found here.

The configuration we are looking for is:

{ "mcpServers": { "awslabs.aws-diagram-mcp-server": { "command": "uvx", "args": ["awslabs.aws-diagram-mcp-server"], "env": { "FASTMCP_LOG_LEVEL": "ERROR" }, "autoApprove": [], "disabled": false } } } 
Enter fullscreen mode Exit fullscreen mode

Configuring Kiro

To use the MCP, we will need to configure Kiro to use it. You can configure MCP on a User level or on a Workspace level. We will configure it on a Workspace level in this blog.

Open Kiro and select the Project we are going to use. For me, it was the Terraform module that I wanted to create the diagram for.

Click on the Kiro logo in the left menubar.

Logo of Kiro in menubar

You will then gain access to additional Kiro configuration. At the bottom of that list, you will see MCP Servers. Select to edit this.

MCP Server list

In the JSON document that opens, select Workspace Config.

Update it with the config we got from the MCP.

JSON added to MCP config

After you have saved it, you will see that it appears in the MCP Servers list.

MCP server appears in list

If you click on one of the tools, for example, generate_diagram, a prompt will be automatically added to the session to ask Kiro to test the MCP tool: Help me test the MCP tool generate_diagram from the awslabs.aws-diagram-mcp-server server. Now Kiro will test the tool and “learn” from it:

> I'll help you test the generate_diagram tool from the awslabs.aws-diagram-mcp-server server. > Let me start by getting some example code to understand the syntax, then generate a test diagram. ... > Called MCP tool ... > get_diagram_examples > Now let me test the tool by generating a simple AWS architecture diagram: ... > Called MCP tool ... > generate_diagram > Great! Now let me test with a more complex diagram using custom styling: ... 
Enter fullscreen mode Exit fullscreen mode

This is technically not needed. I tested adding the MCP without testing the tools, and it worked just as well. It might have taken some more time, though.

You are now ready to use the MCP to create diagrams with Kiro.

Building the Diagram

I give Kiro the simple prompt: Can you now create me an AWS Diagram from the Terraform Module we are currently in.

It then starts to create the diagram. It didn’t run into the same issues we had when not using the MCP with import errors, so the diagram were made a lot quicker. The only problem was that it was not in the workspace.

When I asked Kiro where it was, it informed me that it was in the /tmp/ folder. And when I informed Kiro I wanted it in the current folder, it copied it there, but ran into some issue and got stuck. This happened multiple times when copying files, so it's probably something that will get fixed in a future version.

But the diagram was created and looked good. Not perfect, but a great start and probably good enough for most.

The Diagram

Here is the finished diagram.

AWS Diagram for S3 backend

The Code

Here is the code Kiro generated with the help of the MCP. As you will see, the code is not runnable by itself in its current form. It is missing imports, and according to Kiro, this is by design. The guide from the MCP instructs it to ignore imports and focus solely on the code. But if we want to get functional code from it, we only need to ask Kiro to fix this, so it’s not a big thing.

with Diagram("Terraform S3 Backend - Service Architecture", show=False, direction="TB"): # Entry Point terraform_cli = General("Terraform CLI") with Cluster("AWS Services"): # Primary Services with Cluster("Storage Services"): s3 = S3("Amazon S3") s3_bucket = S3("Backend Bucket") with Cluster("Database Services"): dynamodb = Dynamodb("Amazon DynamoDB") lock_table = DynamodbTable("terraform_state") with Cluster("Resource Configuration"): # S3 Features with Cluster("S3 Configuration"): versioning = S3("Versioning: Enabled") # DynamoDB Features with Cluster("DynamoDB Configuration"): hash_key = DynamodbAttribute("LockID (String)") capacity = Dynamodb("Lock") # Service Relationships terraform_cli >> Edge(label="stores state", color="green", style="bold") >> s3 ( terraform_cli >> Edge(label="manages locks", color="orange", style="bold") >> dynamodb ) # Service to Resource Mapping s3 >> Edge(label="contains", color="green") >> s3_bucket dynamodb >> Edge(label="contains", color="orange") >> lock_table # Configuration Relationships (s3_bucket >> Edge(label="configured with", color="blue") >> [versioning]) lock_table >> Edge(label="configured with", color="blue") >> [hash_key, capacity] 
Enter fullscreen mode Exit fullscreen mode

Using the MCP with Amazon Q Developer

When reading the instructions for setting up the MCP I saw that we can use it with Amazon Q Developer as well. So I configured Q to use the MCP as well and asked it to create the same diagram. And it was just as easy as with Kiro.

Configure Q to use the MCP

To configure Q to use MCP we need to update a configuration file with the MCP configuration. Add the same MCP configuration as we added to Kiro to ~/.aws/amazonq/mcp.json for a User configuration or to . amazonq/mcp.json in your workspace folder for Workspace configuration.

To test that the configuration works, we can check the loaded MCP in q and should see awslabs.aws-diagram-mcp-server.

> qchat mcp listbash > workspace: /Users/USERNAME/WORKSPACE/.amazonq/mcp.json (empty) 🌍 global: /Users/USERNAME/.aws/amazonq/mcp.json • awslabs.aws-diagram-mcp-server uvx 
Enter fullscreen mode Exit fullscreen mode

Then we can ask Q to create the diagram just as we did before. And it did without any issues.

The Diagram

Here is the Diagram from Q Developer using the MCP.

AWS Diagram for S3 Backend

Final Thoughts

Using the MCP with either Kiro or Amazon Q works really well and makes it easier to create the diagrams.

I tested both with more advanced Terraform modules, and it works just as well, almost better in fact. It can become a little weird sometimes, but I would suggest asking the AI to create multiple diagrams at different detail levels for you to choose from.

Some of the issues I ran into with Kiro, such as the diagrams in the wrong folder, the code not created in the workspace, or not runnable manually, can all be handled with better prompting, my prompting was really basic.

So if you are looking into building Diagrams with Code and using AI, I would suggest configuring it to use the AWS MCP for diagrams.

But as always, when using AI to build something, don’t forget to learn the code it uses so you can modify it and address any issues with it.

Top comments (0)