Skip to main content
Glama
Brucedh

AWS‑IReveal‑MCP

cloudtrail_lookup_events

Search AWS CloudTrail management events using specific filters to audit API activity and monitor account changes.

Instructions

Lookup CloudTrail events using filters.

If the user request falls into one of these scenarios, use the Athena tools instead:
- EventName is a data event (e.g. GetObject, DeleteObject, PutObject);
- the user wants to filter by role name;
- the user wants to filter by principal ID;
- the user wants to filter by IP address;
- the user wants to filter by bucket name;
- the user wants to filter by file object in buckets;
- the user wants to filter using regex;
When filtering for EventName, note that the event name is case-sensitive and must match the exact name of the event.
If you want to use operators like 'equals', 'not equals', 'contains', etc., you must use the Athena tools instead.

<IMPORTANT>
Call datetime.datetime.now() to get the current date and time before providing the start and end times.
If the user asks for events happened in the last 7 days, run 'datetime.datetime.now() - datetime.timedelta(days=7)' to get the start date.
Print out the start and end times to the user.
</IMPORTANT>

Parameters:
  aws_region (str): The AWS region - use 'us-east-1' if not specified.
  attribute_key (str): The name of the event to search for.
    Valid attributes keys: EventId | EventName | ReadOnly | Username | ResourceType | ResourceName | EventSource | AccessKeyId
  attribute_value (str): The value of the event to search for.
    If no key-value pair is provided, use 'ReadOnly'='false'.
  start_time (str): start timestamp with format 'YYYY-MM-DD HH:MM:SS' (e.g. '2025-04-10 12:45:50').
    If not provided, use 'datetime.datetime.now() - datetime.timedelta(days=7)' to get the start date.
  end_time (str): end timestamp with format 'YYYY-MM-DD HH:MM:SS' (e.g. '2025-04-11 12:45:50').
    If not provided, use 'datetime.datetime.now()' to get the end date.
  max_results (int): Maximum number of events to return.

Returns:
    list: A list of CloudTrail events matching the specified criteria.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aws_regionYes
attribute_keyYes
attribute_valueYes
start_timeYes
end_timeYes
max_resultsNo

Implementation Reference

  • server.py:31-94 (handler)
    The handler function for 'cloudtrail_lookup_events' tool. It is registered via @mcp.tool() decorator and implements the AWS CloudTrail 'lookup_events' API call, filtering by attribute key-value pair, time range, and max results. Returns a list of event summaries or error message.
    @mcp.tool()
    async def cloudtrail_lookup_events(
        aws_region: str, 
        attribute_key: str, 
        attribute_value: str, 
        start_time: str, 
        end_time: str, 
        max_results: int = 50
    ) -> list:
        """
        Lookup CloudTrail events using filters.
    
        If the user request falls into one of these scenarios, use the Athena tools instead:
        - EventName is a data event (e.g. GetObject, DeleteObject, PutObject);
        - the user wants to filter by role name;
        - the user wants to filter by principal ID;
        - the user wants to filter by IP address;
        - the user wants to filter by bucket name;
        - the user wants to filter by file object in buckets;
        - the user wants to filter using regex;
        When filtering for EventName, note that the event name is case-sensitive and must match the exact name of the event.
        If you want to use operators like 'equals', 'not equals', 'contains', etc., you must use the Athena tools instead.
        
        <IMPORTANT>
        Call datetime.datetime.now() to get the current date and time before providing the start and end times.
        If the user asks for events happened in the last 7 days, run 'datetime.datetime.now() - datetime.timedelta(days=7)' to get the start date.
        Print out the start and end times to the user.
        </IMPORTANT>
    
        Parameters:
          aws_region (str): The AWS region - use 'us-east-1' if not specified.
          attribute_key (str): The name of the event to search for.
            Valid attributes keys: EventId | EventName | ReadOnly | Username | ResourceType | ResourceName | EventSource | AccessKeyId
          attribute_value (str): The value of the event to search for.
            If no key-value pair is provided, use 'ReadOnly'='false'.
          start_time (str): start timestamp with format 'YYYY-MM-DD HH:MM:SS' (e.g. '2025-04-10 12:45:50').
            If not provided, use 'datetime.datetime.now() - datetime.timedelta(days=7)' to get the start date.
          end_time (str): end timestamp with format 'YYYY-MM-DD HH:MM:SS' (e.g. '2025-04-11 12:45:50').
            If not provided, use 'datetime.datetime.now()' to get the end date.
          max_results (int): Maximum number of events to return.
    
        Returns:
            list: A list of CloudTrail events matching the specified criteria.
        """
        try:
            cloudtrail_client = boto3.client('cloudtrail', region_name=aws_region)
            response = cloudtrail_client.lookup_events(
                LookupAttributes=[{'AttributeKey': attribute_key, 'AttributeValue': attribute_value}],
                StartTime=start_time,
                EndTime=end_time,
                MaxResults=max_results
            )
            events = response.get('Events', [])
            return [
                {
                    'EventId': event.get('EventId'),
                    'EventName': event.get('EventName'),
                    'EventTime': event.get('EventTime').isoformat() if event.get('EventTime') else None,
                    'Username': event.get('Username')
                } for event in events
            ]
        except Exception as e:
            return f"Error looking up events: {str(e)}"
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: the tool filters CloudTrail events, has case-sensitive EventName matching, requires specific datetime handling, and returns a list of events. It also mentions constraints like not supporting regex or certain operators. However, it doesn't cover aspects like rate limits, authentication requirements, or error handling.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately structured with clear sections (purpose, usage guidelines, important notes, parameters, returns). However, it includes some redundancy (datetime instructions appear in both the IMPORTANT section and parameter descriptions) and could be more concise. The length is justified by the complexity of the tool, but some sentences could be tightened.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 6 parameters, 0% schema coverage, no annotations, and no output schema, the description provides substantial context. It covers purpose, usage guidelines, parameter semantics, and return format. The main gap is lack of output structure details (what fields events contain), but given the tool's complexity, the description is reasonably complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Given 0% schema description coverage, the description fully compensates by providing detailed parameter semantics. It explains each parameter's purpose, default values, valid options for attribute_key, format requirements for timestamps, and default behaviors when parameters aren't provided. This adds significant value beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Lookup CloudTrail events using filters.' It specifies the resource (CloudTrail events) and action (lookup with filters). However, it doesn't explicitly differentiate from sibling tools like 'athena_query_events' beyond mentioning when to use Athena tools instead, which is more about usage guidelines than purpose distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool versus alternatives: it lists six specific scenarios where Athena tools should be used instead (e.g., data events, filtering by role name, principal ID, etc.). It also includes important operational instructions about datetime handling and printing times to the user, which are clear usage directives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Brucedh/aws-ireveal-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server