Using the CloudTrail MCP Server for Security, Audit, and Operations
Introduction
The CloudTrail Model Context Protocol (MCP) server enables agents like Kiro to query and analyze AWS CloudTrail events directly through natural language. By connecting your agents to CloudTrail events in either CloudWatch Logs or CloudTrail Lake, you can investigate security incidents, audit account activity, troubleshoot operational issues, and generate compliance reports—all through conversational prompts instead of writing complex SQL queries or manually parsing JSON logs.
Why This Matters
Security, compliance, and operations teams spend significant time analyzing CloudTrail logs to understand AWS account activity:
- Security teams need to quickly investigate suspicious activity, trace unauthorized access attempts, and identify the scope of potential security incidents across multiple accounts
- Compliance teams must generate audit reports showing who accessed what resources, when changes were made, and whether activities comply with organizational policies
- Operations teams troubleshoot service disruptions by tracing API calls, identifying configuration changes, and understanding the sequence of events leading to issues
- All teams struggle with CloudWatch Logs Insights query syntax, JSON parsing, and correlating events across time periods and accounts
Without the CloudTrail MCP server, teams resort to writing complex queries, manually parsing JSON logs, or building custom dashboards—adding time, complexity, and potential for human error to critical security and operational workflows.
How It Works
The CloudTrail MCP server translates natural language questions into queries against your CloudTrail data, executes them, and returns human-readable results with context and insights.
Supported Data Sources:
- CloudWatch Logs: Uses CloudWatch Logs Insights query syntax - MCP server automatically discovers available log groups
- CloudTrail Lake: Uses SQL queries - MCP server automatically discovers available event data stores for CloudTrail Lake
Key Capabilities:
- Natural language queries instead of writing query syntax
- Multi-account support
- Time-based analysis and event correlation
- Security investigation, compliance reporting, and operational troubleshooting
Setup Requirements
To use the CloudTrail MCP server, you need:
For CloudWatch Logs:
- AWS CloudTrail configured to send events to CloudWatch Logs
- IAM permissions:
logs:StartQuery,logs:GetQueryResults,logs:DescribeLogGroups - MCP server will automatically discover available CloudTrail log groups
For CloudTrail Lake:
- CloudTrail Lake event data store created and configured
- IAM permissions:
cloudtrail:StartQuery,cloudtrail:GetQueryResults,cloudtrail:DescribeEventDataStores,cloudtrail:ListEventDataStores(see CloudTrail Lake permissions) - MCP server will automatically discover available CloudTrail Lake event data stores
For Both:
- MCP server configured in your agent
- AWS credentials with appropriate permissions
Configuration
To configure the CloudTrail MCP server in your agent, follow the setup instructions in the AWS MCP Servers Documentation. The MCP server automatically discovers available CloudTrail data sources (CloudWatch Logs and CloudTrail Lake) in your AWS account.
In your prompts, you can optionally specify which data source to query:
Using CloudWatch Logs, show me all failed login attempts in the last 24 hours.
Using CloudTrail Lake, show me all IAM policy changes in the last 90 days.