Bilal Ahmad

~Engineers solve problems, I solve engineer's problems 🤘

How Amazon Q CLI and MCP Servers Supercharged My Productivity

A deep dive into Amazon Q CLI and Model Context Protocol (MCP) servers, exploring how these tools have revolutionized my development workflow and productivity.

What is Amazon Q CLI?

Amazon Q CLI is a command-line interface that brings AI-powered assistance directly to your terminal. It integrates with AWS services and provides intelligent code suggestions, documentation lookup, and automated task execution.

Understanding MCP Servers

Model Context Protocol (MCP) servers are standardized interfaces that allow AI models to interact with external tools and data sources. They provide a consistent way for AI assistants to access databases, APIs, file systems, and other resources.

My Productivity Transformation

Before Amazon Q CLI

After Amazon Q CLI + MCP

Amazon Q CLI Setup and Configuration

Installation

# Install Amazon Q CLI
curl -fsSL https://aws.amazon.com/q/cli/install.sh | bash

# Verify installation
q --version

# Configure AWS credentials
aws configure
q configure

Basic Configuration

# Initialize Q CLI
q init

# Set default region
q config set region us-east-1

# Configure output format
q config set output json

# Enable auto-suggestions
q config set suggestions true

Core Amazon Q CLI Features

1. Intelligent Command Generation

# Instead of remembering complex AWS CLI syntax
q "create an S3 bucket with versioning enabled"

# Q CLI generates:
aws s3api create-bucket --bucket my-bucket --region us-east-1
aws s3api put-bucket-versioning --bucket my-bucket --versioning-configuration Status=Enabled

2. Context-Aware Suggestions

# Q CLI understands your current context
q "show me the security groups for this EC2 instance"

# Automatically detects current instance and shows relevant security groups
aws ec2 describe-security-groups --group-ids $(aws ec2 describe-instances --instance-ids i-1234567890abcdef0 --query 'Reservations[0].Instances[0].SecurityGroups[].GroupId' --output text)

3. Error Resolution

# When AWS CLI commands fail, Q CLI provides solutions
aws s3 cp file.txt s3://non-existent-bucket/

# Q CLI suggests:
q "fix this S3 error: The specified bucket does not exist"

# Provides solution:
aws s3 mb s3://my-bucket
aws s3 cp file.txt s3://my-bucket/

MCP Server Integration

Setting Up MCP Servers

# Install MCP server for AWS
npm install -g @aws/mcp-server

# Configure MCP server
q mcp install aws-server

# List available MCP servers
q mcp list

Custom MCP Server Configuration

{
  "mcpServers": {
    "aws-tools": {
      "command": "node",
      "args": ["/path/to/aws-mcp-server"],
      "env": {
        "AWS_REGION": "us-east-1",
        "AWS_PROFILE": "default"
      }
    },
    "terraform-tools": {
      "command": "python",
      "args": ["/path/to/terraform-mcp-server.py"],
      "env": {
        "TF_VAR_environment": "production"
      }
    },
    "jira-tools": {
      "command": "python",
      "args": ["/path/to/jira-mcp-server.py"],
      "env": {
        "JIRA_URL": "https://your-domain.atlassian.net",
        "JIRA_USERNAME": "your-email@company.com",
        "JIRA_API_TOKEN": "your-api-token"
      }
    },
    "confluence-tools": {
      "command": "python",
      "args": ["/path/to/confluence-mcp-server.py"],
      "env": {
        "CONFLUENCE_URL": "https://your-domain.atlassian.net",
        "CONFLUENCE_USERNAME": "your-email@company.com",
        "CONFLUENCE_API_TOKEN": "your-api-token"
      }
    },
    "aws-billing-tools": {
      "command": "python",
      "args": ["/path/to/aws-billing-mcp-server.py"],
      "env": {
        "AWS_REGION": "us-east-1",
        "AWS_PROFILE": "billing-readonly"
      }
    }
  }
}

Atlassian Integration Setup

Creating Atlassian API Tokens

# Step 1: Create API token in Atlassian
# Go to: https://id.atlassian.com/manage-profile/security/api-tokens
# Click "Create API token"
# Copy the generated token

# Step 2: Configure environment variables
export JIRA_URL="https://your-domain.atlassian.net"
export JIRA_USERNAME="your-email@company.com"
export JIRA_API_TOKEN="your-api-token"
export CONFLUENCE_URL="https://your-domain.atlassian.net"
export CONFLUENCE_USERNAME="your-email@company.com"
export CONFLUENCE_API_TOKEN="your-api-token"

# Step 3: Test API access
curl -u "$JIRA_USERNAME:$JIRA_API_TOKEN" "$JIRA_URL/rest/api/3/myself"
curl -u "$CONFLUENCE_USERNAME:$CONFLUENCE_API_TOKEN" "$CONFLUENCE_URL/wiki/rest/api/user/current"

Available MCP Servers

There are several open-source MCP servers available that can be easily integrated with Amazon Q CLI:

Popular Open-Source MCP Servers:

AWS Official MCP Servers: AWS provides official MCP servers for their services:

Configuration Example:

{
  "mcpServers": {
    "jira-tools": {
      "command": "npx",
      "args": ["@company/jira-mcp-server"],
      "env": {
        "JIRA_URL": "https://your-domain.atlassian.net",
        "JIRA_USERNAME": "your-email@company.com",
        "JIRA_API_TOKEN": "your-api-token"
      }
    },
    "aws-billing": {
      "command": "npx",
      "args": ["@aws/billing-mcp-server"],
      "env": {
        "AWS_REGION": "us-east-1",
        "AWS_PROFILE": "billing-readonly"
      }
    }
  }
}

Custom MCP Server Development

While there are many open-source MCP servers available, it’s also straightforward to create your own custom MCP servers for specific use cases:

Key Benefits of Custom MCP Servers:

MCP Server Structure:

{
  "tools": [
    {
      "name": "tool_name",
      "description": "Tool description",
      "inputSchema": {
        "type": "object",
        "properties": {
          "parameter": {"type": "string"}
        }
      }
    }
  ]
}

Easy Integration:

MCP Server Installation and Usage

Installing MCP Servers:

# Install open-source MCP servers
npm install @company/jira-mcp-server
npm install @company/confluence-mcp-server
npm install @aws/billing-mcp-server

# Install AWS official MCP servers
npm install @aws/cli-mcp-server
npm install @aws/cost-explorer-mcp-server

Configuration in mcp.json:

{
  "mcpServers": {
    "jira-tools": {
      "command": "npx",
      "args": ["@company/jira-mcp-server"],
      "env": {
        "JIRA_URL": "https://your-domain.atlassian.net",
        "JIRA_USERNAME": "your-email@company.com",
        "JIRA_API_TOKEN": "your-api-token"
      }
    },
    "confluence-tools": {
      "command": "npx",
      "args": ["@company/confluence-mcp-server"],
      "env": {
        "CONFLUENCE_URL": "https://your-domain.atlassian.net",
        "CONFLUENCE_USERNAME": "your-email@company.com",
        "CONFLUENCE_API_TOKEN": "your-api-token"
      }
    },
    "aws-billing": {
      "command": "npx",
      "args": ["@aws/billing-mcp-server"],
      "env": {
        "AWS_REGION": "us-east-1",
        "AWS_PROFILE": "billing-readonly"
      }
    }
  }
}

AWS Documentation and Architecture Assistance

Q CLI Documentation Integration

# Q CLI can access AWS documentation directly
q "show me the AWS Lambda pricing model"

# Q CLI provides:
# - Current pricing information
# - Regional variations
# - Free tier details
# - Cost optimization tips

# Architecture diagram generation
q "create an architecture diagram for a serverless web application"

# Q CLI generates Mermaid diagram:
graph TB
    A[User] --> B[CloudFront]
    B --> C[API Gateway]
    C --> D[Lambda Functions]
    D --> E[DynamoDB]
    D --> F[S3 Bucket]
    G[Route 53] --> B
    H[Cognito] --> C

Architecture Diagram Generation

Q CLI can generate professional architecture diagrams using Mermaid syntax:

Available Diagram Types:

Diagram Features:

Real-World Productivity Examples

1. Infrastructure Deployment

# Traditional approach
aws cloudformation create-stack --stack-name my-stack --template-body file://template.yaml --parameters ParameterKey=Environment,ParameterValue=prod

# With Q CLI
q "deploy a CloudFormation stack named my-stack with production environment"

# Q CLI generates optimized command with error handling
aws cloudformation create-stack \
  --stack-name my-stack \
  --template-body file://template.yaml \
  --parameters ParameterKey=Environment,ParameterValue=prod \
  --capabilities CAPABILITY_IAM \
  --on-failure ROLLBACK

2. Kubernetes Cluster Management

# Complex EKS operations simplified
q "create an EKS cluster with 3 nodes and enable logging"

# Q CLI generates:
eksctl create cluster \
  --name my-cluster \
  --region us-east-1 \
  --nodegroup-name workers \
  --node-type t3.medium \
  --nodes 3 \
  --nodes-min 1 \
  --nodes-max 5 \
  --enable-iam \
  --enable-cloudwatch-logs

3. Database Operations

# RDS operations made simple
q "create an RDS PostgreSQL instance with backup enabled"

# Q CLI generates:
aws rds create-db-instance \
  --db-instance-identifier my-postgres-db \
  --db-instance-class db.t3.micro \
  --engine postgres \
  --engine-version 13.7 \
  --master-username admin \
  --master-user-password MyPassword123 \
  --allocated-storage 20 \
  --backup-retention-period 7 \
  --preferred-backup-window "03:00-04:00" \
  --preferred-maintenance-window "sun:04:00-sun:05:00"

4. JIRA Ticket Creation with Templates

# Create a user story with acceptance criteria and definition of done
q "create a JIRA user story for implementing user authentication with 5 story points"

# Q CLI uses JIRA MCP server to create:
# - Title: "Implement User Authentication"
# - Description: Detailed user story description
# - Acceptance Criteria: Given/When/Then format
# - Definition of Done: Code review, tests, documentation
# - Story Points: 5
# - Epic Link: Authentication Epic

5. Confluence Documentation

# Create architecture documentation
q "create a Confluence page for our microservices architecture"

# Q CLI uses Confluence MCP server to create:
# - Architecture overview
# - Component descriptions
# - Data flow diagrams
# - Security considerations
# - Deployment notes

6. AWS Cost Analysis

# Analyze cost anomalies
q "analyze AWS cost anomalies for the last 30 days"

# Q CLI uses AWS billing MCP server to:
# - Get daily cost data
# - Identify services with >20% cost changes
# - Generate anomaly report
# - Suggest cost optimization opportunities

7. Documentation Lookup

# Get AWS service documentation
q "show me the AWS Lambda cold start optimization best practices"

# Q CLI provides:
# - Current AWS documentation
# - Best practices for cold start reduction
# - Code examples
# - Performance tuning tips

8. Architecture Diagram Generation

# Generate architecture diagrams
q "create a microservices architecture diagram with API Gateway, Lambda, and DynamoDB"

# Q CLI generates Mermaid diagram:
graph TB
    A[Client] --> B[API Gateway]
    B --> C[Auth Lambda]
    B --> D[User Lambda]
    B --> E[Order Lambda]
    C --> F[Cognito]
    D --> G[DynamoDB Users]
    E --> H[DynamoDB Orders]
    I[CloudWatch] --> C
    I --> D
    I --> E

Advanced MCP Server Use Cases

1. Terraform Integration

# Terraform MCP server enables infrastructure management
q "plan terraform changes for production environment"

# Q CLI uses Terraform MCP server to:
# - Run terraform plan with proper parameters
# - Show resource changes and costs
# - Validate configuration
# - Suggest optimizations

2. Docker Integration

# Docker MCP server commands
q "build and run a Docker container with my app"

# Q CLI uses Docker MCP server to:
docker build -t my-app:latest .
docker run -d -p 8080:8080 --name my-app-container my-app:latest

3. Git Operations

# Git MCP server integration
q "create a new branch and push my changes"

# Q CLI generates:
git checkout -b feature/new-feature
git add .
git commit -m "Add new feature"
git push origin feature/new-feature

Productivity Metrics

Time Savings

Quality Improvements

Custom MCP Server Development

Creating custom MCP servers is straightforward and allows you to build domain-specific tools:

Development Process:

  1. Define Tools: Specify the tools and their parameters
  2. Implement Logic: Add business logic for each tool
  3. Package: Create npm package for distribution
  4. Configure: Add to mcp.json configuration
  5. Test: Validate with Q CLI integration

Key Components:

Benefits:

Integration with Development Workflows

VS Code Integration

{
  "mcp.servers": {
    "aws-q-cli": {
      "command": "q",
      "args": ["mcp", "serve"],
      "env": {
        "AWS_PROFILE": "default"
      }
    }
  }
}

CI/CD Pipeline Integration

# .github/workflows/deploy.yml
name: Deploy with Q CLI
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Setup AWS CLI
        uses: aws-actions/configure-aws-credentials@v2
        with:
          aws-access-key-id: $
          aws-secret-access-key: $
          aws-region: us-east-1
      
      - name: Install Q CLI
        run: |
          curl -fsSL https://aws.amazon.com/q/cli/install.sh | bash
      
      - name: Deploy with Q CLI
        run: |
          q "deploy the application to production environment"

Best Practices and Tips

1. Effective Prompting

# Good: Specific and contextual
q "create an S3 bucket for storing application logs with lifecycle policy"

# Bad: Too vague
q "create something"

2. MCP Server Organization

# Organize MCP servers by domain
q mcp install aws-tools
q mcp install terraform-tools
q mcp install monitoring-tools

3. Error Handling

# Q CLI provides intelligent error resolution
q "fix this error: Access Denied"

# Suggests:
# 1. Check IAM permissions
# 2. Verify AWS credentials
# 3. Check resource policies

Troubleshooting Common Issues

1. MCP Server Connection Issues

# Check MCP server status
q mcp status

# Restart MCP server
q mcp restart aws-tools

# Check logs
q mcp logs aws-tools

2. AWS Credential Issues

# Verify AWS credentials
aws sts get-caller-identity

# Reconfigure Q CLI
q configure --reset

3. Performance Optimization

# Enable caching
q config set cache true

# Set cache size
q config set cache_size 1000

# Clear cache when needed
q cache clear

Future Enhancements

Planned Features

Custom Integrations

Lessons Learned

1. Start Small

2. Invest in Custom MCP Servers

3. Monitor Usage

Conclusion

Amazon Q CLI and MCP servers have fundamentally transformed my development workflow. The combination of intelligent command generation, context-aware suggestions, and seamless tool integration has resulted in:

The integration of JIRA and Confluence MCP servers has revolutionized my project management workflow, ensuring consistent ticket quality with proper acceptance criteria and definition of done. The AWS billing MCP server provides proactive cost monitoring and optimization insights that would take hours to gather manually.

The key to success is starting with basic operations and gradually building custom MCP servers for your specific use cases. The investment in learning these tools pays dividends in productivity, code quality, and project management efficiency.

Most Impactful Features:

  1. JIRA Templates: Automated user story creation with acceptance criteria
  2. Confluence Integration: Architecture documentation with professional templates
  3. AWS Billing Analysis: Proactive cost anomaly detection and optimization
  4. Documentation Access: Instant AWS service documentation and best practices
  5. Architecture Diagrams: Professional Mermaid diagrams generated on demand

These tools have not just improved my productivity—they’ve fundamentally changed how I approach development, documentation, and project management.

back