DEV Community

Cover image for Using AWS MCP Servers with the Amazon Q Developer CLI

Using AWS MCP Servers with the Amazon Q Developer CLI

What is MCP?

The Model Context Protocol (MCP) is an open standard which allows AI models to communicate seamlessly with external tools. If you haven’t already tried using MCP servers with your favourite LLM, this is a really easy way to get started.

In the context of the Amazon Q Developer CLI, MCP enables you to extend Q's capabilities by connecting it to a range of pre-built and custom tools!

I wrote previously about the Ten ways I use the Amazon Q Developer CLI to save time, but the addition of MCP servers can seriously take your productivity to a whole new level and you can get started in just a few minutes with a few easy commands.

What can MCP Servers actually do?

Here are a few examples of interesting MCP servers that can be added to Amazon Q Developer, to extend its functionality:

  • AWS Pricing MCP Server creates cost analysis reports based on current pricing

  • AWS Terraform MCP Server lets you run Terraform commands, get best practice advice, run security scans on code

  • Amazon EKS MCP Server allows you to create EKS clusters, deploy apps, troubleshoot

  • AWS Documentation MCP Server allows you to read and search the AWS documentation

  • AWS Diagram MCP Server generates diagrams using the diagrams Python package

I needed to create a few diagrams this week, so I decided to see how the AWS Diagram MCP Server performs, however you can check out the GitHub repo for AWS MCP Servers to see what else is available.

Adding the AWS Diagram MCP Server to the Amazon Q Developer CLI Agent

Pre-requisites

Before you start adding MCP Servers to Q Developer, there are a few pre-req's to configure. You'll need to be running Python ≥ 3.10, uv (used for package management), and for my example below I also needed to install Graphviz (for graph visualizations) and diagrams (a Python module for creating and displaying diagrams).

If like me, you're working on macOS here's how to add these pre-requisites (otherwise check the instructions for your OS):

pip install uv

uv python install 3.10

brew install graphviz

pip install diagrams
Enter fullscreen mode Exit fullscreen mode

Adding the MCP Server

First I added the AWS Diagram MCP Server using this command:

qchat mcp add --name aws-diagram --command uvx --args awslabs.aws-diagram-mcp-server
Enter fullscreen mode Exit fullscreen mode

I also added the AWS Documentation MCP Server using the following command:

qchat mcp add --name aws-docs --command uvx --args awslabs.aws-documentation-mcp-server@latest
Enter fullscreen mode Exit fullscreen mode

Using the MCP Server with the Q Developer CLI Agent

To invoke the MCP server, start a chat session with Amazon Q Developer:

q chat
Enter fullscreen mode Exit fullscreen mode

When you start the Q CLI, it will load any MCP servers that you have added, and you can check that any MCP servers have successfully loaded using the following command:

/tools
Enter fullscreen mode Exit fullscreen mode

You should see output similar to this:
Screenshot showing that the MCP servers that have been added to my locally installed Amazon Q Developer CLI Agent

After that you can start interacting with the MCP server, here are some examples to try.

1. Creating a diagram needed for a lab I'm working on

Create a diagram that shows a DynamoDB table named orders, 
data being populated from a JSON file, 
2 x Global secondary indexes (one named OrderDateIndex, 
and one named OrderStatusIndex) as well as a query and scan 
operation being submitted to the dynamodb table. 
please save the diagram to the current folder.
Enter fullscreen mode Exit fullscreen mode

The initial diagram Q created made some assumptions about how I was running commands, and added Lambda and S3 which I am not using, so I give it some more information to try and get closer to what I need:

The scan and query operations are run from the AWS CLI 
using the AWS CloudShell and so is the batch_write_items 
command that is used to populate the table. Please update 
the diagram to remove the Lambda and S3 references, 
also the sort key for this table is user_id.
Enter fullscreen mode Exit fullscreen mode

Here's the final diagram, pretty good!
A diagram showing the scan and query operations being run from the AWS CLI using the AWS CloudShell.

2. Convert CloudFormation or Terraform code into a diagram

This is great for visualizing complex IaC templates and showing resource dependencies.

Create a diagram that shows everything being created 
by the CloudFormation template named library-bot.yml, 
the diagram should show all resource dependencies 
and relationships. please save the diagram to the current folder.
Enter fullscreen mode Exit fullscreen mode

Here's the result, enabling me to check that I've included everything I need in this template:

Diagram visualizing a CloudFormation template to build an Amazon Lex chatbot

Other use-cases

I can see how this MCP server could be really useful for reviewing architectures, explaining concepts in meetings, quickly creating diagrams to illustrate different options for comparison and discussion, and to help with on-boarding team members enabling them to visualize existing architectures. I'm looking forward to trying some of the other capabilities!

Have you started using any of the MCP servers with the Amazon Q Developer CLI Agent yet?

Top comments (1)

Collapse
 
luca_vk_d3176a99b76567 profile image
Luca

pipx installs Python apps in their own isolated virtual environments. Do not install globally with pip.