DEV Community

Cover image for Amazon Q Chat with MCP Agents
Hashan Perera
Hashan Perera

Posted on

2

Amazon Q Chat with MCP Agents

The AI revolution is transforming nearly every aspect of the software development lifecycle, making developers' lives easier day by day.

Among these innovations, Anthropic's MCP agent stands out as a particularly promising tool. As a DevOps engineer, I see tremendous potential for improving efficiency throughout the DevOps lifecycle.

In this article, I'll demonstrate how to use Amazon Q Chat with various MCP agents, focusing on the Cost Analysis MCP Server as an example that has helped me monitor our AWS account usage effectively.

Amazon Q Chat

Amazon Q Chat functions like having a cloud-savvy teammate you can communicate with naturally. It's designed to help you manage your AWS environment through simple, conversational interactions. Whether you're requesting resource details, troubleshooting issues, or performing tasks, Q understands the context and executes commands—without requiring you to navigate the console or write scripts.

For more details about Amazon Q, please refer to the official documentation:

MCP Agent

The MCP Agent serves as a bridge between Amazon Q Chat and your AWS setup. Built on the open Model Context Protocol (MCP) standard—think of it as the USB-C of AI tools—it enables Q to seamlessly understand and interact with your cloud environment. Rather than requiring detailed instructions, Q can gather context, take actions, and provide intelligent responses automatically. Through MCP, your conversational interactions with Q become a natural way to manage your infrastructure, eliminating unnecessary back-and-forth.

For more details about MCP, please refer to their Documentation: https://modelcontextprotocol.io/introduction

Installation

To get started with Amazon Q, follow the installation instructions at: https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html

After installing, you can log in to Amazon Q with the q login command. Depending on your account, you'll need to provide the necessary authentication details. Once login is successful, you can access your AWS account through the terminal. Amazon Q will use the default profile and credentials available in your .aws directory. If you're using SSO, you can specify which AWS profile to use when working with Amazon Q.

How to Enable MCP Agents

Enabling MCP agents is straightforward—you simply need to add a mcp.json file to the ~/.aws/amazonq/ directory.

Let's use the AWS Core MCP Server as an example: https://awslabs.github.io/mcp/servers/core-mcp-server/

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

You can add multiple MCP agents to this file. Here are some popular MCP agents available:

Once you've created the mcp.json file with your required agents, you can start Amazon Q Chat with the q chat command and verify your setup:

> can you access mcp servers i setup on mcp.json?
I'd be happy to check if there are any MCP servers set up in your mcp.json file. Let me look for that file in your current directory or in a
standard location.

🛠️  Using tool: fs_read (trusted)
 ⋮
 ● Reading file: /Users/hperera/.aws/amazonq/mcp.json, all lines
 ⋮
 ● Completed in 0.0s

Yes, I can see that you have three MCP servers set up in your mcp.json file:

1. awslabs.core-mcp-server - This provides core functionality extensions
2. awslabs.cdk-mcp-server - This provides CDK-specific capabilities
3. awslabs.cost-analysis-mcp-server - This provides cost analysis capabilities

All three servers are enabled (not disabled) and are configured to run using the uvx command. The cost analysis server is specifically
configured to use your default AWS profile.

These MCP servers extend my capabilities, allowing me to help you with additional tasks related to AWS CDK, cost analysis, and other core
functionalities. Is there something specific you'd like to do with these MCP servers?
Enter fullscreen mode Exit fullscreen mode

When you next open Amazon Q Chat, you can view all your available MCP agents.

Open Amazon Q

I have enabled 5 AWS MCPs; you can see them on the chat initialization page.

How to Use an MCP Agent

Let me demonstrate this using the awslabs.cost-analysis-mcp-server (though you can always ask Amazon Q Chat and other AI tools for examples too 😄).

This MCP agent is a server that extends Amazon Q's capabilities to analyze AWS costs.

Let's say we want to do a quick analysis of our AWS account's Reserved Instance (RI) coverage.

The manual way would be to navigate the AWS account UI or run CLI commands to list available instances and RI purchases, then cross-reference them to analyze coverage.

However, with Amazon Q and MCP, we can simply ask the AI to perform this analysis and generate human-readable documents and tables for us, along with recommendations to optimize our cost savings and spending efficiency.

When using the cost analysis MCP server, you can specify:

  • Time periods (e.g., "last month", "last 3 months", "year to date")
  • Specific regions or "all regions"
  • Specific instance types or families
  • Output formats (summary vs detailed)

Here is my prompt:

Analyze my Amazon RDS Reserved Instance (RI) coverage in the us-east-1 region using the default AWS profile.
Specifically:
List the number of active RDS instances I currently have, grouped by instance class (e.g., db.t3.medium, db.m5.large).
For each instance class, show how many Reserved Instances I currently own and their respective durations (1-year or 3-year terms).
Calculate the coverage percentage: how many of the running instances are covered by RIs, per instance class.
Export the full results to a CSV file.
Enter fullscreen mode Exit fullscreen mode

Once you give the command, Amazon Q will start its work

I'll help you analyze your Amazon RDS Reserved Instance coverage in the us-east-1 region using the shop-np AWS profile. Let me break this down
into steps:

1. First, I'll get your active RDS instances
2. Then I'll check your Reserved Instances
3. Calculate the coverage percentage
4. Export the results to a CSV file

Let's start:

🛠️  Using tool: use_aws (trusted)
 ⋮
 ● Running aws cli command:

Service name: rds
Operation name: describe-db-instances
Parameters:
Profile name: default
Region: us-east-1
Label: Getting active RDS instances
 ⋮
 ● Completed in 4.91s

⠋ Thinking...
Enter fullscreen mode Exit fullscreen mode

Here’s the generated CSV file. Along with it, I received several helpful tips and recommendations. You can always adjust your prompt to get more tailored results.

CSV Results

This is just one example — there are many other powerful MCPs available. Explore them and see how AI can help automate the routine tasks around you.

Just a quick note: AI responses aren’t always 100% accurate, so it’s a good idea to double-check the data the first time, especially before using it in reports.

AWS Q Developer image

What is MCP? No, Really!

See MCP in action and explore how MCP decouples agents from servers, allowing for seamless integration with cloud-based resources and remote functionality.

Watch the demo

Top comments (0)

Runner H image

Automate Your Workflow in Slack, Gmail, Notion & more

Runner H connects to your favorite tools and handles repetitive tasks for you. Save hours daily. Try it free while it’s in beta.

Try for Free

👋 Kindness is contagious

Dive into this thoughtful piece, beloved in the supportive DEV Community. Coders of every background are invited to share and elevate our collective know-how.

A sincere "thank you" can brighten someone's day—leave your appreciation below!

On DEV, sharing knowledge smooths our journey and tightens our community bonds. Enjoyed this? A quick thank you to the author is hugely appreciated.

Okay