awslabs.cloudtrail-mcp-server 0.0.2__tar.gz → 0.0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/CHANGELOG.md +12 -0
  2. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/Dockerfile +31 -21
  3. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/PKG-INFO +1 -1
  4. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/awslabs/cloudtrail_mcp_server/__init__.py +1 -1
  5. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/awslabs/cloudtrail_mcp_server/tools.py +95 -5
  6. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/docker-healthcheck.sh +7 -8
  7. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/pyproject.toml +1 -1
  8. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/uv-requirements.txt +1 -0
  9. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/uv.lock +1 -1
  10. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/.gitignore +0 -0
  11. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/.python-version +0 -0
  12. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/LICENSE +0 -0
  13. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/NOTICE +0 -0
  14. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/README.md +0 -0
  15. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/awslabs/__init__.py +0 -0
  16. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/awslabs/cloudtrail_mcp_server/common.py +0 -0
  17. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/awslabs/cloudtrail_mcp_server/models.py +0 -0
  18. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/awslabs/cloudtrail_mcp_server/server.py +0 -0
  19. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/tests/__init__.py +0 -0
  20. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/tests/conftest.py +0 -0
  21. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/tests/test_init.py +0 -0
  22. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/tests/test_main.py +0 -0
  23. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/tests/test_models.py +0 -0
  24. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/tests/test_server.py +0 -0
  25. {awslabs_cloudtrail_mcp_server-0.0.2 → awslabs_cloudtrail_mcp_server-0.0.4}/tests/test_tools.py +0 -0
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.0.3] - 2025-09-22
9
+
10
+ ### Changed
11
+
12
+ - Update the context to include event schema for better generation of SQL.
13
+
14
+ ## [0.0.1] - 2025-08-25
15
+
16
+ ### Added
17
+
18
+ - Tools for CloudTrail Lookup and Lake.
19
+
8
20
  ## Unreleased
9
21
 
10
22
  ### Added
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  # dependabot should continue to update this to the latest hash.
16
- FROM public.ecr.aws/sam/build-python3.10@sha256:e78695db10ca8cb129e59e30f7dc9789b0dbd0181dba195d68419c72bac51ac1 AS uv
16
+ FROM public.ecr.aws/docker/library/python:3.13-alpine@sha256:070342a0cc1011532c0e69972cce2bbc6cc633eba294bae1d12abea8bd05303b AS uv
17
17
 
18
18
  # Install the project into `/app`
19
19
  WORKDIR /app
@@ -33,38 +33,48 @@ ENV UV_FROZEN=true
33
33
  # Copy the required files first
34
34
  COPY pyproject.toml uv.lock uv-requirements.txt ./
35
35
 
36
+ # Python optimization and uv configuration
37
+ ENV PIP_NO_CACHE_DIR=1 \
38
+ PIP_DISABLE_PIP_VERSION_CHECK=1
39
+
40
+ # Install system dependencies and Python package manager
41
+ RUN apk update && \
42
+ apk add --no-cache --virtual .build-deps \
43
+ build-base \
44
+ gcc \
45
+ musl-dev \
46
+ libffi-dev \
47
+ openssl-dev \
48
+ cargo
49
+
36
50
  # Install the project's dependencies using the lockfile and settings
37
51
  RUN --mount=type=cache,target=/root/.cache/uv \
38
- pip install --require-hashes --requirement uv-requirements.txt && \
39
- uv sync --frozen --no-install-project --no-dev --no-editable
52
+ pip install --require-hashes --requirement uv-requirements.txt --no-cache-dir && \
53
+ uv sync --python 3.13 --frozen --no-install-project --no-dev --no-editable
40
54
 
41
55
  # Then, add the rest of the project source code and install it
42
56
  # Installing separately from its dependencies allows optimal layer caching
43
57
  COPY . /app
44
58
  RUN --mount=type=cache,target=/root/.cache/uv \
45
- uv sync --frozen --no-dev --no-editable
59
+ uv sync --python 3.13 --frozen --no-dev --no-editable
46
60
 
47
61
  # Make the directory just in case it doesn't exist
48
62
  RUN mkdir -p /root/.local
49
63
 
50
- FROM public.ecr.aws/sam/build-python3.10@sha256:e78695db10ca8cb129e59e30f7dc9789b0dbd0181dba195d68419c72bac51ac1
64
+ FROM public.ecr.aws/docker/library/python:3.13-alpine@sha256:070342a0cc1011532c0e69972cce2bbc6cc633eba294bae1d12abea8bd05303b
51
65
 
52
66
  # Place executables in the environment at the front of the path and include other binaries
53
- ENV PATH="/app/.venv/bin:$PATH:/usr/sbin"
54
-
55
- # Install lsof for the healthcheck
56
- # Install other tools as needed for the MCP server
57
- # Add non-root user and ability to change directory into /root
58
- RUN yum update -y && \
59
- yum install -y lsof && \
60
- yum clean all -y && \
61
- rm -rf /var/cache/yum && \
62
- groupadd --force --system app && \
63
- useradd app -g app -d /app && \
64
- chmod o+x /root
65
-
66
- # Get the project from the uv layer
67
- COPY --from=uv --chown=app:app /root/.local /root/.local
67
+ ENV PATH="/app/.venv/bin:$PATH" \
68
+ PYTHONUNBUFFERED=1
69
+
70
+ # Install runtime dependencies and create application user
71
+ RUN apk update && \
72
+ apk add --no-cache ca-certificates && \
73
+ update-ca-certificates && \
74
+ addgroup -S app && \
75
+ adduser -S app -G app -h /app
76
+
77
+ # Copy application artifacts from build stage
68
78
  COPY --from=uv --chown=app:app /app/.venv /app/.venv
69
79
 
70
80
  # Get healthcheck script
@@ -74,5 +84,5 @@ COPY ./docker-healthcheck.sh /usr/local/bin/docker-healthcheck.sh
74
84
  USER app
75
85
 
76
86
  # When running the container, add --db-path and a bind mount to the host's db file
77
- HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "docker-healthcheck.sh" ]
87
+ HEALTHCHECK --interval=60s --timeout=10s --start-period=10s --retries=3 CMD ["docker-healthcheck.sh"]
78
88
  ENTRYPOINT ["awslabs.cloudtrail-mcp-server"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: awslabs.cloudtrail-mcp-server
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: An AWS Labs Model Context Protocol (MCP) server for cloudtrail
5
5
  Project-URL: homepage, https://awslabs.github.io/mcp/
6
6
  Project-URL: docs, https://awslabs.github.io/mcp/servers/cloudtrail-mcp-server/
@@ -14,5 +14,5 @@
14
14
 
15
15
  """awslabs.cloudtrail-mcp-server"""
16
16
 
17
- __version__ = '0.0.2'
17
+ __version__ = '0.0.4'
18
18
  MCP_SERVER_VERSION = __version__
@@ -254,14 +254,104 @@ class CloudTrailTools:
254
254
  IMPORTANT LIMITATIONS:
255
255
  - CloudTrail Lake only supports SELECT statements using Trino-compatible SQL syntax
256
256
  - INSERT, UPDATE, DELETE, CREATE, DROP, and other DDL/DML operations are not supported
257
+ - Do not use Common Table Expression (CTE)
257
258
  - Your SQL query MUST include a valid Event Data Store (EDS) ID in the FROM clause
258
259
  - Use the list_event_data_stores tool first to get available EDS IDs, then reference the EDS ID
259
260
  directly in your FROM clause
260
-
261
- Valid SQL query examples:
262
- - SELECT eventname, count(*) FROM 0233062b-51c6-4d18-8dec-a8c90da840d9 WHERE eventtime > '2023-01-01' GROUP BY eventname
263
- - SELECT useridentity.username, eventname, eventtime FROM your-eds-id WHERE errorcode IS NOT NULL
264
- - SELECT DISTINCT awsregion FROM your-eds-id WHERE eventname = 'CreateUser'
261
+ - Always use a start and end time using eventtime or have a limit on total output by default
262
+
263
+ CLOUDTRAIL EVENT SCHEMA:
264
+ All CloudTrail events contain these key fields that you can query:
265
+
266
+ Core Fields (Always Present):
267
+ - eventTime: UTC timestamp when request completed
268
+ - eventVersion: Log format version (current: 1.11)
269
+ - eventSource: AWS service name (e.g., "s3.amazonaws.com")
270
+ - eventName: API action name
271
+ - awsRegion: AWS region where request was made
272
+ - sourceIPAddress: IP address of requester
273
+ - eventID: Unique GUID for this event
274
+ - eventType: AwsApiCall, AwsServiceEvent, AwsConsoleAction, AwsConsoleSignIn, AwsVpceEvent
275
+ - eventCategory: Management, Data, NetworkActivity, Insight
276
+
277
+ UserIdentity Object (Always Present):
278
+ - userIdentity.type: Root, IAMUser, AssumedRole, Role, FederatedUser, Directory, AWSAccount, AWSService, IdentityCenterUser, SAMLUser, WebIdentityUser, Unknown
279
+ - userIdentity.principalId: Unique identifier for the entity
280
+ - userIdentity.arn: ARN of the principal
281
+ - userIdentity.accountId: Account that owns the entity
282
+ - userIdentity.accessKeyId: Access key used (may be empty for security)
283
+ - userIdentity.userName: Friendly name (when available)
284
+ - userIdentity.invokedBy: AWS service that made the request
285
+ - userIdentity.identityProvider: External identity provider (SAML/Web)
286
+ - userIdentity.credentialId: Bearer token credential ID
287
+ - userIdentity.sessionContext: For temporary credentials (AssumedRole, FederatedUser)
288
+ - sessionIssuer.type: Source type (Root, IAMUser, Role)
289
+ - sessionIssuer.principalId: Internal ID of issuer
290
+ - sessionIssuer.arn: ARN of issuer
291
+ - sessionIssuer.accountId: Account of issuer
292
+ - sessionIssuer.userName: Name of credential issuer
293
+ - attributes.mfaAuthenticated: "true"/"false" if MFA was used
294
+ - attributes.creationDate: When credentials were issued (ISO 8601)
295
+ - webIdFederationData.federatedProvider: Identity provider name
296
+ - webIdFederationData.attributes: Provider-specific attributes
297
+ - sourceIdentity: Original user identity for role chaining
298
+ - ec2RoleDelivery: "1.0" or "2.0" for IMDS version
299
+ - assumedRoot: True for AssumeRoot sessions
300
+ - userIdentity.onBehalfOf: IAM Identity Center user info
301
+ - userId: Identity Center user ID
302
+ - identityStoreArn: Identity store ARN
303
+ - userIdentity.inScopeOf: Service scope information
304
+ - sourceArn: Invoking resource ARN
305
+ - sourceAccount: Source account ID
306
+ - issuerType: Credential issuer type
307
+ - credentialsIssuedTo: Credential target resource
308
+
309
+ Optional Fields (Conditionally Present):
310
+ - userAgent: Client that made the request (max 1KB)
311
+ - errorCode: AWS service error code if request failed (max 1KB)
312
+ - errorMessage: Error description if request failed (max 1KB)
313
+ - requestParameters: Request parameters (object, max 100KB)
314
+ - responseElements: Response elements for write operations (object, max 100KB)
315
+ - additionalEventData: Additional event data (object, max 28KB)
316
+ - requestID: Service-generated request identifier (max 1KB)
317
+ - apiVersion: API version for AwsApiCall events
318
+ - managementEvent: True if management event
319
+ - readOnly: true/false if read-only operation
320
+ - resources: Array of resources accessed
321
+ - resources[].type: Resource type (e.g., "AWS::S3::Object", "AWS::DynamoDB::Table")
322
+ - resources[].ARN: Resource ARN
323
+ - resources[].accountId: Resource owner account
324
+ - recipientAccountId: Account that received the event
325
+ - serviceEventDetails: Service event details (object, max 100KB)
326
+ - sharedEventID: Shared GUID for cross-account events
327
+ - vpcEndpointId: VPC endpoint identifier (for network events)
328
+ - vpcEndpointAccountId: VPC endpoint owner account
329
+ - addendum: Information about delayed/updated events
330
+ - reason: Why event was delayed (DELIVERY_DELAY, UPDATED_DATA, SERVICE_OUTAGE)
331
+ - updatedFields: Event record fields updated by addendum
332
+ - originalRequestID: Original unique ID of request
333
+ - originalEventID: Original event ID
334
+ - sessionCredentialFromConsole: "true" if from console session
335
+ - eventContext: Enriched event context (tags, IAM conditions)
336
+ - requestContext: IAM condition keys evaluated during authorization
337
+ - tagContext: Tags associated with resources and IAM principals
338
+ - resourceTags: Array of resource tag information
339
+ - resourceTags[].arn: ARN of the tagged resource
340
+ - resourceTags[].tags: Object containing tag key-value pairs
341
+ - principalTags: Tags associated with the IAM principal making the request
342
+ - edgeDeviceDetails: Edge device information (object, max 28KB)
343
+ - tlsDetails: TLS connection information
344
+ - tlsVersion: TLS version used
345
+ - cipherSuite: Cipher suite used
346
+ - clientProvidedHostHeader: Client-provided hostname
347
+
348
+ Example SQL queries:
349
+ - SELECT eventname, count(*) FROM eds-id WHERE eventtime > '2025-01-01 00:00:00' GROUP BY eventname
350
+ - SELECT errorcode, errormessage, eventname FROM eds-id WHERE errorcode IS NOT NULL OR errormessage IS NOT NULL LIMIT 10
351
+ - SELECT eventname, resources FROM eds-id WHERE any_match(resources, x -> x.type = 'AWS::S3::Object') LIMIT 10
352
+ - SELECT useridentity.sessioncontext.sessionissuer.username FROM eds-id WHERE useridentity.type = 'AssumedRole' LIMIT 10
353
+ - SELECT sourceipaddress, count(*) FROM eds-id WHERE eventname = 'ConsoleLogin' GROUP BY sourceipaddress LIMIT 10
354
+ - SELECT eventname, filter(resources, x -> x.type = 'AWS::Lambda::Function') as lambda_resources FROM eds-id WHERE cardinality(filter(resources, x -> x.type = 'AWS::Lambda::Function')) > 0 LIMIT 5
265
355
 
266
356
  Returns:
267
357
  --------
@@ -1,5 +1,4 @@
1
1
  #!/bin/sh
2
-
3
2
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
3
  #
5
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,13 +13,13 @@
14
13
  # See the License for the specific language governing permissions and
15
14
  # limitations under the License.
16
15
 
17
- if [ "$(lsof +c 0 -p 1 | grep -e "^awslabs\..*\s1\s.*\sunix\s.*socket$" | wc -l)" -ne "0" ]; then
18
- echo -n "$(lsof +c 0 -p 1 | grep -e "^awslabs\..*\s1\s.*\sunix\s.*socket$" | wc -l) awslabs.* streams found";
16
+ SERVER="cloudtrail-mcp-server"
17
+
18
+ # Check if the server process is running
19
+ if pgrep -P 0 -a -l -x -f "/app/.venv/bin/python3 /app/.venv/bin/awslabs.$SERVER" > /dev/null; then
20
+ echo -n "$SERVER is running";
19
21
  exit 0;
20
- else
21
- echo -n "Zero awslabs.* streams found";
22
- exit 1;
23
22
  fi;
24
23
 
25
- echo -n "Never should reach here";
26
- exit 99;
24
+ # Unhealthy
25
+ exit 1;
@@ -2,7 +2,7 @@
2
2
  name = "awslabs.cloudtrail-mcp-server"
3
3
 
4
4
  # NOTE: "Patch"=9223372036854775807 bumps next release to zero.
5
- version = "0.0.2"
5
+ version = "0.0.4"
6
6
 
7
7
  description = "An AWS Labs Model Context Protocol (MCP) server for cloudtrail"
8
8
  readme = "README.md"
@@ -1,4 +1,5 @@
1
1
  # This file was autogenerated by uv via the following command:
2
+ # echo "uv==0.8.10" > uv-requirements.in
2
3
  # uv pip compile --generate-hashes --output-file=uv-requirements.txt --strip-extras --python=3.10 uv-requirements.in
3
4
  uv==0.8.10 \
4
5
  --hash=sha256:31e4fc37ee94b94c032384a0957ad32ba7dce4ce6c04b4880fd3e31e25e51a82 \
@@ -46,7 +46,7 @@ wheels = [
46
46
 
47
47
  [[package]]
48
48
  name = "awslabs-cloudtrail-mcp-server"
49
- version = "0.0.2"
49
+ version = "0.0.4"
50
50
  source = { editable = "." }
51
51
  dependencies = [
52
52
  { name = "boto3" },