Complete guide for using the AWS Knowledge Query CLI tool.
The CLI tool (ask_aws.py) provides a fast, scriptable way to query AWS documentation from the command line. Perfect for:
- Quick documentation lookups
- Shell scripts and automation
- CI/CD pipelines
- Terminal-based workflows
venv/bin/python cli/ask_aws.py "<question>" [topic] [limit]| Argument | Required | Default | Description |
|---|---|---|---|
question |
Yes | - | Your question (use quotes) |
topic |
No | general |
Topic category |
limit |
No | 5 |
Number of results (max 10) |
# Simple question (uses default 'general' topic)
venv/bin/python cli/ask_aws.py "How to create a Lambda function"
# Get help
venv/bin/python cli/ask_aws.py --help# API documentation
venv/bin/python cli/ask_aws.py "boto3 S3 upload_file" reference_documentation
# Troubleshooting
venv/bin/python cli/ask_aws.py "Lambda timeout error" troubleshooting
# CDK examples
venv/bin/python cli/ask_aws.py "Lambda function CDK Python" cdk_constructs
# CloudFormation
venv/bin/python cli/ask_aws.py "DynamoDB table template" cloudformation# Get only 3 results
venv/bin/python cli/ask_aws.py "S3 security" general 3
# Get maximum 10 results
venv/bin/python cli/ask_aws.py "Lambda best practices" general 10Best practices, architecture patterns, and tutorials.
Use for:
- Architecture questions
- Best practices
- Service comparisons
- Getting started guides
Examples:
venv/bin/python cli/ask_aws.py "Lambda best practices"
venv/bin/python cli/ask_aws.py "S3 security patterns"
venv/bin/python cli/ask_aws.py "DynamoDB vs RDS"
venv/bin/python cli/ask_aws.py "Serverless architecture"API, SDK, and CLI documentation.
Use for:
- boto3 (Python SDK) documentation
- AWS CLI commands
- API references
- SDK method signatures
Examples:
venv/bin/python cli/ask_aws.py "boto3 S3 upload_file" reference_documentation
venv/bin/python cli/ask_aws.py "aws lambda invoke CLI" reference_documentation
venv/bin/python cli/ask_aws.py "Lambda InvokeFunction API" reference_documentation
venv/bin/python cli/ask_aws.py "DynamoDB PutItem boto3" reference_documentationError messages and debugging guides.
Use for:
- Error messages
- Debugging issues
- Common problems
- Resolution steps
Examples:
venv/bin/python cli/ask_aws.py "Lambda timeout error" troubleshooting
venv/bin/python cli/ask_aws.py "S3 access denied" troubleshooting
venv/bin/python cli/ask_aws.py "DynamoDB throttling" troubleshooting
venv/bin/python cli/ask_aws.py "API Gateway 403" troubleshootingAWS CDK concepts and API reference.
Use for:
- CDK getting started
- CDK concepts
- CDK API reference
- CDK best practices
Examples:
venv/bin/python cli/ask_aws.py "CDK stack construct" cdk_docs
venv/bin/python cli/ask_aws.py "CDK best practices" cdk_docs
venv/bin/python cli/ask_aws.py "CDK deployment" cdk_docsCDK code examples and patterns.
Use for:
- Working code examples
- CDK patterns
- Infrastructure as code
- Multi-language examples
Examples:
venv/bin/python cli/ask_aws.py "Lambda function CDK Python" cdk_constructs
venv/bin/python cli/ask_aws.py "API Gateway Lambda CDK" cdk_constructs
venv/bin/python cli/ask_aws.py "DynamoDB table CDK TypeScript" cdk_constructs
venv/bin/python cli/ask_aws.py "S3 bucket CDK" cdk_constructsCloudFormation templates and examples.
Use for:
- CloudFormation templates
- SAM templates
- Resource definitions
- Template examples
Examples:
venv/bin/python cli/ask_aws.py "Lambda CloudFormation template" cloudformation
venv/bin/python cli/ask_aws.py "DynamoDB CloudFormation" cloudformation
venv/bin/python cli/ask_aws.py "SAM template API Gateway" cloudformation
venv/bin/python cli/ask_aws.py "EventBridge rule CloudFormation" cloudformationNew features and announcements.
Use for:
- Latest features
- What's new
- Service updates
- New capabilities
Examples:
venv/bin/python cli/ask_aws.py "Lambda new features 2024" current_awareness
venv/bin/python cli/ask_aws.py "what's new in S3" current_awareness
venv/bin/python cli/ask_aws.py "ECS latest updates" current_awareness
venv/bin/python cli/ask_aws.py "RDS new capabilities" current_awarenessAmplify framework documentation.
Use for:
- Amplify web/mobile apps
- Amplify authentication
- Amplify APIs
- Framework-specific guides
Examples:
venv/bin/python cli/ask_aws.py "Amplify Auth React" amplify_docs
venv/bin/python cli/ask_aws.py "Amplify GraphQL API" amplify_docs
venv/bin/python cli/ask_aws.py "Amplify Storage Flutter" amplify_docsβ Bad: venv/bin/python cli/ask_aws.py "error"
β
Good: venv/bin/python cli/ask_aws.py "Lambda timeout error" troubleshooting
β Bad: venv/bin/python cli/ask_aws.py "upload file"
β
Good: venv/bin/python cli/ask_aws.py "boto3 S3 upload_file" reference_documentation
β Bad: venv/bin/python cli/ask_aws.py "access problem"
β
Good: venv/bin/python cli/ask_aws.py "AccessDenied S3" troubleshooting
β Bad: venv/bin/python cli/ask_aws.py "boto3 S3" general
β
Good: venv/bin/python cli/ask_aws.py "boto3 S3" reference_documentation
β Bad: venv/bin/python cli/ask_aws.py "Lambda CDK" cdk_constructs
β
Good: venv/bin/python cli/ask_aws.py "Lambda CDK Python" cdk_constructs
Add to your .bashrc or .zshrc:
alias askaws='~/path/to/venv/bin/python ~/path/to/cli/ask_aws.py'Then use:
askaws "Lambda best practices"
askaws "boto3 S3" reference_documentation#!/bin/bash
# Query AWS docs in a script
VENV_PYTHON="/path/to/venv/bin/python"
CLI_SCRIPT="/path/to/cli/ask_aws.py"
# Get Lambda best practices
$VENV_PYTHON $CLI_SCRIPT "Lambda best practices" general 3
# Get boto3 documentation
$VENV_PYTHON $CLI_SCRIPT "boto3 S3 upload" reference_documentation 5The CLI outputs formatted text. To parse programmatically, consider using the Python API instead (see API Reference).
# Save to file
venv/bin/python cli/ask_aws.py "Lambda best practices" > lambda_docs.txt
# Search in output
venv/bin/python cli/ask_aws.py "S3 security" | grep -i "encryption"
# Count results
venv/bin/python cli/ask_aws.py "Lambda" | grep -c "^[0-9]\\."Problem: python: command not found
Solution:
# Try python3
python3 cli/ask_aws.py "your question"
# Or use full path
/usr/bin/python3 cli/ask_aws.py "your question"Problem: ModuleNotFoundError: No module named 'mcp'
Solution:
# Activate virtual environment
source venv/bin/activate
# Install dependencies
pip install mcp httpx
# Run again
python cli/ask_aws.py "your question"Problem: β Invalid topic: xyz
Solution: Use one of the valid topics:
generalreference_documentationtroubleshootingcdk_docscdk_constructscloudformationcurrent_awarenessamplify_docs
Problem: Search returns no results
Solutions:
- Try a different topic
- Rephrase your question
- Be more specific
- Use service names explicitly
Problem: Cannot connect to MCP server
Solutions:
- Check internet connection
- Verify endpoint is accessible:
curl https://knowledge-mcp.global.api.aws
- Try again later
The CLI outputs results in this format:
π Searching AWS Knowledge Base...
Question: Your question
Topic: general
Max Results: 5
================================================================================
π RESULTS
================================================================================
1. Document Title
π https://docs.aws.amazon.com/...
π Context snippet from the document...
2. Another Document
π https://docs.aws.amazon.com/...
π More context...
================================================================================
β
Search completed!
================================================================================
Start with general queries:
venv/bin/python cli/ask_aws.py "What is Lambda"
venv/bin/python cli/ask_aws.py "S3 getting started"
venv/bin/python cli/ask_aws.py "DynamoDB basics"Explore specific topics:
venv/bin/python cli/ask_aws.py "Lambda best practices" general
venv/bin/python cli/ask_aws.py "boto3 S3 examples" reference_documentation
venv/bin/python cli/ask_aws.py "Lambda CDK Python" cdk_constructsDeep dive into specific areas:
venv/bin/python cli/ask_aws.py "Lambda performance optimization" general
venv/bin/python cli/ask_aws.py "S3 encryption options" general
venv/bin/python cli/ask_aws.py "DynamoDB GSI design" general- Interactive Mode Guide - Chat-style interface
- Web UI Guide - Web interface
- API Reference - Use in Python code
- Troubleshooting - Common issues
Happy querying! π