Skip to main content

An AWS Labs Model Context Protocol (MCP) server for cloudtrail

Project description

AWS Labs CloudTrail MCP Server

This AWS Labs Model Context Protocol (MCP) server for CloudTrail enables your AI agents to query AWS account activity for security investigations, compliance auditing, and operational troubleshooting. It provides comprehensive access to CloudTrail events and CloudTrail Lake analytics, allowing agents to track API calls, analyze user activity, and perform advanced security analysis. This server gives AI agents seamless access to CloudTrail data through standardized MCP interfaces, eliminating the need for custom API integrations and enabling powerful security insights and audit capabilities.

Instructions

The CloudTrail MCP Server provides specialized tools to address common security and operational scenarios including event lookup, user activity analysis, API call tracking, and advanced CloudTrail Lake analytics. Each tool encapsulates one or multiple CloudTrail APIs into task-oriented operations.

Features

Event Lookup - Search CloudTrail events by various attributes including username, event name, resource name, and more. Provides access to the last 90 days of management events for security investigations and troubleshooting.

CloudTrail Lake Analytics - Execute advanced SQL queries against CloudTrail Lake for complex analytics, filtering, and aggregation. Supports Trino-compatible SQL syntax for comprehensive event analysis.

User Activity Analysis - Track and analyze user activities across AWS services by filtering events by username, access key, or other user-related attributes.

API Call Tracking - Monitor specific API calls and their patterns across your AWS environment for security and compliance purposes.

Event Data Store Management - List and explore available CloudTrail Lake Event Data Stores to understand data sources and capabilities.

Prerequisites

  1. An AWS account with CloudTrail enabled. CloudTrail Event History is enabled by default. CloudTrail Lake needs to be enabled for advance SQL queries.
  2. This MCP server can only be run locally on the same host as your LLM client.
  3. Set up AWS credentials with access to AWS services
    • You need an AWS account with appropriate permissions (See required permissions below)
    • Configure AWS credentials with aws configure or environment variables

Available Tools

Tools for CloudTrail Events

  • lookup_events - Look up CloudTrail events based on various criteria such as username, event name, resource name, etc. Provides access to the last 90 days of management events with pagination support

Tools for CloudTrail Lake Analytics

  • lake_query - Execute SQL queries against CloudTrail Lake for complex analytics and filtering. Supports Trino-compatible SQL syntax for advanced analysis
  • list_event_data_stores - List available CloudTrail Lake Event Data Stores with their capabilities and event selectors
  • get_query_status - Get the status of a CloudTrail Lake query to monitor long-running queries
  • get_query_results - Get the results of a completed CloudTrail Lake query with pagination support for large result sets

Required IAM Permissions

  • cloudtrail:LookupEvents
  • cloudtrail:ListEventDataStores
  • cloudtrail:GetEventDataStore
  • cloudtrail:StartQuery
  • cloudtrail:DescribeQuery
  • cloudtrail:GetQueryResults

Installation

Option 1: Python (UVX)

Prerequisites

  1. Install uv from Astral or the GitHub README
  2. Install Python using uv python install 3.10

One Click Install

Cursor VS Code
Install MCP Server Install on VS Code

MCP Config (Q CLI, Cline)

  • For Q CLI, update MCP Config Amazon Q Developer CLI (~/.aws/amazonq/mcp.json)
  • For Cline click on "Configure MCP Servers" option from MCP tab
{
  "mcpServers": {
    "awslabs.cloudtrail-mcp-server": {
      "autoApprove": [],
      "disabled": false,
      "command": "uvx",
      "args": [
        "awslabs.cloudtrail-mcp-server@latest"
      ],
      "env": {
        "AWS_PROFILE": "[The AWS Profile Name to use for AWS access]",
        "FASTMCP_LOG_LEVEL": "ERROR"
      },
      "transportType": "stdio"
    }
  }
}

Please reference AWS documentation to create and manage your credentials profile

Option 2: Docker Image

Prerequisites

Build and install docker image locally on the same host of your LLM client

  1. Install Docker
  2. git clone https://github.com/awslabs/mcp.git
  3. Go to sub-directory cd src/cloudtrail-mcp-server/
  4. Run docker build -t awslabs/cloudtrail-mcp-server:latest .

One Click Cursor Install

Install CloudTrail MCP Server

MCP Config using Docker image(Q CLI, Cline)

  {
    "mcpServers": {
      "awslabs.cloudtrail-mcp-server": {
        "command": "docker",
        "args": [
          "run",
          "--rm",
          "--interactive",
          "-v ~/.aws:/root/.aws",
          "-e AWS_PROFILE=[The AWS Profile Name to use for AWS access]",
          "awslabs/cloudtrail-mcp-server:latest"
        ],
        "env": {},
        "disabled": false,
        "autoApprove": []
      }
    }
  }

Please reference AWS documentation to create and manage your credentials profile

Contributing

Contributions are welcome! Please see the CONTRIBUTING.md in the monorepo root for guidelines.

Feedback and Issues

We value your feedback! Submit your feedback, feature requests and any bugs at GitHub issues with prefix cloudtrail-mcp-server in title.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awslabs_cloudtrail_mcp_server-0.0.1.tar.gz (93.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

awslabs_cloudtrail_mcp_server-0.0.1-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file awslabs_cloudtrail_mcp_server-0.0.1.tar.gz.

File metadata

File hashes

Hashes for awslabs_cloudtrail_mcp_server-0.0.1.tar.gz
Algorithm Hash digest
SHA256 73f8eb0ab83ec323ceece3acc7b529a5279b1aa9aae7a6bece85efa8893a45a8
MD5 129564470b030eb602effbf3a199bfe5
BLAKE2b-256 9d3e9e2902ef7bdbf8ebfd044037b8f823a1f6414083848c7d5f117a456210c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for awslabs_cloudtrail_mcp_server-0.0.1.tar.gz:

Publisher: release.yml on awslabs/mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file awslabs_cloudtrail_mcp_server-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for awslabs_cloudtrail_mcp_server-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 580b8754ba2109a72604f21a1de0ecc89ba5b662e6c5025397bda84dc4be06b1
MD5 bc818b4cffaa1a67c5d2430c04831fa2
BLAKE2b-256 300cacc537d1efed7eb29c44ddbe590f923df198b49f1aec042d7256b7e81cc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for awslabs_cloudtrail_mcp_server-0.0.1-py3-none-any.whl:

Publisher: release.yml on awslabs/mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page