awslabs.cfn-mcp-server 0.0.1__py3-none-any.whl
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.
- awslabs/__init__.py +13 -0
- awslabs/cfn_mcp_server/__init__.py +14 -0
- awslabs/cfn_mcp_server/aws_client.py +64 -0
- awslabs/cfn_mcp_server/cloud_control_utils.py +58 -0
- awslabs/cfn_mcp_server/context.py +23 -0
- awslabs/cfn_mcp_server/errors.py +91 -0
- awslabs/cfn_mcp_server/schema_manager.py +163 -0
- awslabs/cfn_mcp_server/server.py +381 -0
- awslabs_cfn_mcp_server-0.0.1.dist-info/METADATA +197 -0
- awslabs_cfn_mcp_server-0.0.1.dist-info/RECORD +14 -0
- awslabs_cfn_mcp_server-0.0.1.dist-info/WHEEL +4 -0
- awslabs_cfn_mcp_server-0.0.1.dist-info/entry_points.txt +2 -0
- awslabs_cfn_mcp_server-0.0.1.dist-info/licenses/LICENSE +175 -0
- awslabs_cfn_mcp_server-0.0.1.dist-info/licenses/NOTICE +2 -0
awslabs/__init__.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
12
|
+
# This file is part of the awslabs namespace.
|
|
13
|
+
# It is intentionally minimal to support PEP 420 namespace packages.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
12
|
+
"""awslabs.cfn-mcp-server"""
|
|
13
|
+
|
|
14
|
+
__version__ = '0.0.0'
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
12
|
+
import sys
|
|
13
|
+
from awslabs.cfn_mcp_server.errors import ClientError
|
|
14
|
+
from boto3 import Session
|
|
15
|
+
from os import environ
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
session = Session(profile_name=environ.get('AWS_PROFILE'))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_aws_client(service_name, region_name=None):
|
|
22
|
+
"""Create and return an AWS service client with dynamically detected credentials.
|
|
23
|
+
|
|
24
|
+
This function implements a credential provider chain that tries different
|
|
25
|
+
credential sources in the following order:
|
|
26
|
+
1. Environment variables (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY)
|
|
27
|
+
2. Shared credential file (~/.aws/credentials)
|
|
28
|
+
3. IAM role for Amazon EC2 / ECS task role / EKS pod identity
|
|
29
|
+
4. AWS SSO or Web Identity token
|
|
30
|
+
|
|
31
|
+
The function caches clients based on the compound key of service_name and region_name
|
|
32
|
+
to avoid creating duplicate clients for the same service and region.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
service_name: AWS service name (e.g., 'cloudcontrol', 'logs', 'marketplace-catalog')
|
|
36
|
+
region_name: AWS region name (defaults to environment variable or 'us-east-1')
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
Boto3 client for the specified service
|
|
40
|
+
"""
|
|
41
|
+
# Default region handling
|
|
42
|
+
if not region_name:
|
|
43
|
+
region_name = environ.get('AWS_REGION', 'us-east-1')
|
|
44
|
+
|
|
45
|
+
# Credential detection and client creation
|
|
46
|
+
try:
|
|
47
|
+
print(
|
|
48
|
+
f'Creating new {service_name} client for region {region_name} with auto-detected credentials'
|
|
49
|
+
)
|
|
50
|
+
client = session.client(service_name, region_name=region_name)
|
|
51
|
+
|
|
52
|
+
print('Created client for service with credentials')
|
|
53
|
+
return client
|
|
54
|
+
|
|
55
|
+
except Exception as e:
|
|
56
|
+
print(f'Error creating {service_name} client: {str(e)}', file=sys.stderr)
|
|
57
|
+
if 'ExpiredToken' in str(e):
|
|
58
|
+
raise ClientError('Your AWS credentials have expired. Please refresh them.')
|
|
59
|
+
elif 'NoCredentialProviders' in str(e):
|
|
60
|
+
raise ClientError(
|
|
61
|
+
'No AWS credentials found. Please configure credentials using environment variables or AWS configuration.'
|
|
62
|
+
)
|
|
63
|
+
else:
|
|
64
|
+
raise ClientError('Got an error when loading your client.')
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
12
|
+
from awslabs.cfn_mcp_server.errors import ClientError
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def validate_patch(patch_document: list):
|
|
16
|
+
"""A best effort check that makes sure that the format of a patch document is valid before sending it to CloudControl."""
|
|
17
|
+
for patch_op in patch_document:
|
|
18
|
+
if not isinstance(patch_op, dict):
|
|
19
|
+
raise ClientError('Each patch operation must be a dictionary')
|
|
20
|
+
if 'op' not in patch_op:
|
|
21
|
+
raise ClientError("Each patch operation must include an 'op' field")
|
|
22
|
+
if patch_op['op'] not in ['add', 'remove', 'replace', 'move', 'copy', 'test']:
|
|
23
|
+
raise ClientError(
|
|
24
|
+
f"Operation '{patch_op['op']}' is not supported. Must be one of: add, remove, replace, move, copy, test"
|
|
25
|
+
)
|
|
26
|
+
if 'path' not in patch_op:
|
|
27
|
+
raise ClientError("Each patch operation must include a 'path' field")
|
|
28
|
+
# Value is required for add, replace, and test operations
|
|
29
|
+
if patch_op['op'] in ['add', 'replace', 'test'] and 'value' not in patch_op:
|
|
30
|
+
raise ClientError(f"The '{patch_op['op']}' operation requires a 'value' field")
|
|
31
|
+
# From is required for move and copy operations
|
|
32
|
+
if patch_op['op'] in ['move', 'copy'] and 'from' not in patch_op:
|
|
33
|
+
raise ClientError(f"The '{patch_op['op']}' operation requires a 'from' field")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def progress_event(response_event) -> dict[str, str]:
|
|
37
|
+
"""Map a CloudControl API response to a standard output format for the MCP."""
|
|
38
|
+
response = {
|
|
39
|
+
'status': response_event['OperationStatus'],
|
|
40
|
+
'resource_type': response_event['TypeName'],
|
|
41
|
+
'is_complete': response_event['OperationStatus'] == 'SUCCESS',
|
|
42
|
+
'request_token': response_event['RequestToken'],
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if response_event.get('Identifier', None):
|
|
46
|
+
response['identifier'] = response_event['Identifier']
|
|
47
|
+
if response_event.get('StatusMessage', None):
|
|
48
|
+
response['status_message'] = response_event['StatusMessage']
|
|
49
|
+
if response_event.get('ResourceModel', None):
|
|
50
|
+
response['resource_info'] = response_event['ResourceModel']
|
|
51
|
+
if response_event.get('ErrorCode', None):
|
|
52
|
+
response['error_code'] = response_event['ErrorCode']
|
|
53
|
+
if response_event.get('EventTime', None):
|
|
54
|
+
response['event_time'] = response_event['EventTime']
|
|
55
|
+
if response_event.get('RetryAfter', None):
|
|
56
|
+
response['retry_after'] = response_event['RetryAfter']
|
|
57
|
+
|
|
58
|
+
return response
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from awslabs.cfn_mcp_server.errors import ServerError
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Context:
|
|
5
|
+
"""A singleton which includes context for the MCP server such as startup parameters."""
|
|
6
|
+
|
|
7
|
+
_instance = None
|
|
8
|
+
|
|
9
|
+
def __init__(self, readonly_mode: bool):
|
|
10
|
+
"""Initializes the context."""
|
|
11
|
+
self._readonly_mode = readonly_mode
|
|
12
|
+
|
|
13
|
+
@classmethod
|
|
14
|
+
def readonly_mode(cls) -> bool:
|
|
15
|
+
"""If a the server was started up with the argument --readonly True, this will be set to True."""
|
|
16
|
+
if cls._instance is None:
|
|
17
|
+
raise ServerError('Context was not initialized')
|
|
18
|
+
return cls._instance._readonly_mode
|
|
19
|
+
|
|
20
|
+
@classmethod
|
|
21
|
+
def initialize(cls, readonly_mode: bool):
|
|
22
|
+
"""Create the singleton instance of the type."""
|
|
23
|
+
cls._instance = cls(readonly_mode)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def handle_aws_api_error(e: Exception) -> Exception:
|
|
14
|
+
"""Handle common AWS API errors and return standardized error responses.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
e: The exception that was raised
|
|
18
|
+
resource_type: Optional resource type related to the error
|
|
19
|
+
identifier: Optional resource identifier related to the error
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
Standardized error response dictionary
|
|
23
|
+
"""
|
|
24
|
+
print('performing error mapping for an AWS exception')
|
|
25
|
+
error_message = str(e)
|
|
26
|
+
error_type = 'UnknownError'
|
|
27
|
+
|
|
28
|
+
# Extract error type from AWS exceptions if possible
|
|
29
|
+
if hasattr(e, 'response') and 'Error' in getattr(e, 'response', {}):
|
|
30
|
+
error_type = e.response['Error'].get('Code', 'UnknownError') # pyright: ignore[reportAttributeAccessIssue]
|
|
31
|
+
|
|
32
|
+
# Handle common AWS error patterns
|
|
33
|
+
if 'AccessDenied' in error_message or error_type == 'AccessDeniedException':
|
|
34
|
+
return ClientError('Access denied. Please check your AWS credentials and permissions.')
|
|
35
|
+
elif 'IncompleteSignature' in error_message:
|
|
36
|
+
return ClientError(
|
|
37
|
+
'Incomplete signature. The request signature does not conform to AWS standards.'
|
|
38
|
+
)
|
|
39
|
+
elif 'InvalidAction' in error_message:
|
|
40
|
+
return ClientError(
|
|
41
|
+
'Invalid action. The action or operation requested is invalid. Verify that the action is typed correctly.'
|
|
42
|
+
)
|
|
43
|
+
elif 'InvalidClientTokenId' in error_message:
|
|
44
|
+
return ClientError(
|
|
45
|
+
'Invalid client token id. The X.509 certificate or AWS access key ID provided does not exist in our records.'
|
|
46
|
+
)
|
|
47
|
+
elif 'NotAuthorized' in error_message:
|
|
48
|
+
return ClientError('Not authorized. You do not have permission to perform this action.')
|
|
49
|
+
elif 'ValidationException' in error_message or error_type == 'ValidationException':
|
|
50
|
+
return ClientError('Validation error. Please check your input parameters.')
|
|
51
|
+
elif 'ResourceNotFoundException' in error_message or error_type == 'ResourceNotFoundException':
|
|
52
|
+
return ClientError('Resource was not found')
|
|
53
|
+
elif (
|
|
54
|
+
'UnsupportedActionException' in error_message or error_type == 'UnsupportedActionException'
|
|
55
|
+
):
|
|
56
|
+
return ClientError('This action is not supported for this resource type.')
|
|
57
|
+
elif 'InvalidPatchException' in error_message:
|
|
58
|
+
return ClientError(
|
|
59
|
+
'The patch document provided contains errors or is not RFC 6902 compliant.'
|
|
60
|
+
)
|
|
61
|
+
elif 'ThrottlingException' in error_message or error_type == 'ThrottlingException':
|
|
62
|
+
return ClientError('Request was throttled. Please reduce your request rate.')
|
|
63
|
+
elif 'InternalFailure' in error_message or error_type == 'InternalFailure':
|
|
64
|
+
return ServerError('Internal failure. The server failed to process the request.')
|
|
65
|
+
elif 'ServiceUnavailable' in error_message or error_type == 'ServiceUnavailable':
|
|
66
|
+
return ServerError('Service unavailable. The server failed to process the request.')
|
|
67
|
+
else:
|
|
68
|
+
# Generic error handling - we might shift to this for everything eventually since it gives more context to the LLM, will have to test
|
|
69
|
+
return ClientError(f'An error occurred: {error_message}')
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class ClientError(Exception):
|
|
73
|
+
"""An error that indicates that the request was malformed or incorrect in some way. There was no issue on the server side."""
|
|
74
|
+
|
|
75
|
+
def __init__(self, message):
|
|
76
|
+
"""Call super and set message."""
|
|
77
|
+
# Call the base class constructor with the parameters it needs
|
|
78
|
+
super().__init__(message)
|
|
79
|
+
self.type = 'client'
|
|
80
|
+
self.message = message
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class ServerError(Exception):
|
|
84
|
+
"""An error that indicates that there was an issue processing the request."""
|
|
85
|
+
|
|
86
|
+
def __init__(self, log):
|
|
87
|
+
"""Call super."""
|
|
88
|
+
# Call the base class constructor with the parameters it needs
|
|
89
|
+
super().__init__('An internal error occured while processing your request')
|
|
90
|
+
print(log)
|
|
91
|
+
self.type = 'server'
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
from awslabs.cfn_mcp_server.aws_client import get_aws_client
|
|
15
|
+
from awslabs.cfn_mcp_server.errors import ClientError
|
|
16
|
+
from datetime import datetime, timedelta
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from typing import Dict
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# all schema metadata is stored in .schemas/schema_metadata.json. The schemas themselves are all stored in the directory.
|
|
22
|
+
SCHEMA_CACHE_DIR = '.schemas'
|
|
23
|
+
SCHEMA_METADATA_FILE = 'schema_metadata.json'
|
|
24
|
+
SCHEMA_UPDATE_INTERVAL = timedelta(days=7) # Check for updates weekly
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class SchemaManager:
|
|
28
|
+
"""Responsible for keeping track of schemas, cacheing them locally, and updating them if they are outdated."""
|
|
29
|
+
|
|
30
|
+
def __init__(self):
|
|
31
|
+
"""Initialize the schema manager with the cache directory."""
|
|
32
|
+
cache_dir = os.path.join(os.path.dirname(__file__), '.schemas')
|
|
33
|
+
self.cache_dir = Path(cache_dir)
|
|
34
|
+
self.metadata_file = self.cache_dir / SCHEMA_METADATA_FILE
|
|
35
|
+
self.schema_registry: Dict[str, dict] = {}
|
|
36
|
+
|
|
37
|
+
# Ensure cache directory exists
|
|
38
|
+
self.cache_dir.mkdir(exist_ok=True)
|
|
39
|
+
|
|
40
|
+
# Load metadata if it exists
|
|
41
|
+
self.metadata = self._load_metadata()
|
|
42
|
+
|
|
43
|
+
# Load cached schemas into registry
|
|
44
|
+
self._load_cached_schemas()
|
|
45
|
+
|
|
46
|
+
def _load_metadata(self) -> dict:
|
|
47
|
+
"""Load schema metadata from file or create if it doesn't exist."""
|
|
48
|
+
if self.metadata_file.exists():
|
|
49
|
+
try:
|
|
50
|
+
with open(self.metadata_file, 'r') as f:
|
|
51
|
+
return json.load(f)
|
|
52
|
+
except json.JSONDecodeError:
|
|
53
|
+
print('Corrupted metadata file. Creating new one.')
|
|
54
|
+
|
|
55
|
+
# Default metadata
|
|
56
|
+
metadata = {'version': '1', 'schemas': {}}
|
|
57
|
+
|
|
58
|
+
# Save default metadata
|
|
59
|
+
with open(self.metadata_file, 'w') as f:
|
|
60
|
+
json.dump(metadata, f, indent=2)
|
|
61
|
+
|
|
62
|
+
return metadata
|
|
63
|
+
|
|
64
|
+
def _load_cached_schemas(self):
|
|
65
|
+
"""Load all cached schemas into the registry."""
|
|
66
|
+
for schema_file in self.cache_dir.glob('*.json'):
|
|
67
|
+
if schema_file.name == SCHEMA_METADATA_FILE:
|
|
68
|
+
continue
|
|
69
|
+
|
|
70
|
+
try:
|
|
71
|
+
with open(schema_file, 'r') as f:
|
|
72
|
+
schema = json.load(f)
|
|
73
|
+
if 'typeName' in schema:
|
|
74
|
+
resource_type = schema['typeName']
|
|
75
|
+
self.schema_registry[resource_type] = schema
|
|
76
|
+
print(f'Loaded schema for {resource_type} from cache')
|
|
77
|
+
except (json.JSONDecodeError, IOError) as e:
|
|
78
|
+
print(f'Error loading schema from {schema_file}: {str(e)}')
|
|
79
|
+
|
|
80
|
+
async def get_schema(self, resource_type: str, region: str | None = None) -> dict:
|
|
81
|
+
"""Get schema for a resource type, downloading it if necessary."""
|
|
82
|
+
# Check if schema is in registry and not forced to refresh
|
|
83
|
+
if resource_type in self.schema_registry:
|
|
84
|
+
# Check if schema needs to be updated based on last update time
|
|
85
|
+
if resource_type in self.metadata['schemas']:
|
|
86
|
+
schema_metadata = self.metadata['schemas'][resource_type]
|
|
87
|
+
last_updated_str = schema_metadata.get('last_updated')
|
|
88
|
+
|
|
89
|
+
if last_updated_str:
|
|
90
|
+
try:
|
|
91
|
+
last_updated = datetime.fromisoformat(last_updated_str)
|
|
92
|
+
if datetime.now() - last_updated < SCHEMA_UPDATE_INTERVAL:
|
|
93
|
+
# Schema is recent enough, use cached version
|
|
94
|
+
return self.schema_registry[resource_type]
|
|
95
|
+
else:
|
|
96
|
+
print(
|
|
97
|
+
f'Schema for {resource_type} is older than {SCHEMA_UPDATE_INTERVAL.days} days, refreshing...'
|
|
98
|
+
)
|
|
99
|
+
except ValueError:
|
|
100
|
+
print(f'Invalid timestamp format for {resource_type}: {last_updated_str}')
|
|
101
|
+
else:
|
|
102
|
+
# No metadata for this schema, use cached version
|
|
103
|
+
return self.schema_registry[resource_type]
|
|
104
|
+
|
|
105
|
+
# Download schema
|
|
106
|
+
schema = await self._download_resource_schema(resource_type, region)
|
|
107
|
+
return schema
|
|
108
|
+
|
|
109
|
+
async def _download_resource_schema(
|
|
110
|
+
self, resource_type: str, region: str | None = None
|
|
111
|
+
) -> dict:
|
|
112
|
+
"""Download schema for a specific resource type.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
resource_type: The AWS resource type (e.g., "AWS::S3::Bucket")
|
|
116
|
+
region: AWS region to use for API calls
|
|
117
|
+
|
|
118
|
+
Returns:
|
|
119
|
+
The downloaded schema or None if download failed
|
|
120
|
+
"""
|
|
121
|
+
# Extract service name from resource type
|
|
122
|
+
parts = resource_type.split('::')
|
|
123
|
+
if len(parts) < 2:
|
|
124
|
+
raise ClientError(
|
|
125
|
+
f"Invalid resource type format: {resource_type}. Expected format like 'Namespace::Service::Resource'"
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
# If no local spec file or it failed to load, try CloudFormation API
|
|
129
|
+
try:
|
|
130
|
+
print(f'Downloading schema for {resource_type} using CloudFormation API')
|
|
131
|
+
cfn_client = get_aws_client('cloudformation', region)
|
|
132
|
+
resp = cfn_client.describe_type(Type='RESOURCE', TypeName=resource_type)
|
|
133
|
+
schema_str = resp['Schema']
|
|
134
|
+
spec = json.loads(schema_str)
|
|
135
|
+
|
|
136
|
+
# Save schema to cache
|
|
137
|
+
schema_file = self.cache_dir / f'{resource_type.replace("::", "_")}.json'
|
|
138
|
+
with open(schema_file, 'w') as f:
|
|
139
|
+
f.write(schema_str)
|
|
140
|
+
|
|
141
|
+
# Update metadata
|
|
142
|
+
self.metadata['schemas'][resource_type] = {
|
|
143
|
+
'last_updated': datetime.now().isoformat(),
|
|
144
|
+
'file_path': str(schema_file),
|
|
145
|
+
'source': 'cloudformation_api',
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
with open(self.metadata_file, 'w') as f:
|
|
149
|
+
json.dump(self.metadata, f, indent=2)
|
|
150
|
+
|
|
151
|
+
print(f'Processed and cached schema for {resource_type}')
|
|
152
|
+
return spec
|
|
153
|
+
except Exception as e:
|
|
154
|
+
raise ClientError(f'Error downloading the schema for {resource_type}: {str(e)}')
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
_schema_manager_instance = SchemaManager()
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
# used to load a single instance of the schema manager
|
|
161
|
+
def schema_manager() -> SchemaManager:
|
|
162
|
+
"""Loads a singleton of the resource."""
|
|
163
|
+
return _schema_manager_instance
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
12
|
+
"""awslabs CFN MCP Server implementation."""
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import json
|
|
16
|
+
from awslabs.cfn_mcp_server.aws_client import get_aws_client
|
|
17
|
+
from awslabs.cfn_mcp_server.cloud_control_utils import progress_event, validate_patch
|
|
18
|
+
from awslabs.cfn_mcp_server.context import Context
|
|
19
|
+
from awslabs.cfn_mcp_server.errors import ClientError, handle_aws_api_error
|
|
20
|
+
from awslabs.cfn_mcp_server.schema_manager import schema_manager
|
|
21
|
+
from mcp.server.fastmcp import FastMCP
|
|
22
|
+
from pydantic import Field
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
mcp = FastMCP(
|
|
26
|
+
'awslabs.cfn-mcp-server',
|
|
27
|
+
instructions="""
|
|
28
|
+
# CloudFormation MCP
|
|
29
|
+
|
|
30
|
+
This MCP allows you to:
|
|
31
|
+
1. Read and List all of your AWS resources by the CloudFormation type name (e.g. AWS::S3::Bucket)
|
|
32
|
+
2. Create/Update/Delete your AWS resources
|
|
33
|
+
""",
|
|
34
|
+
dependencies=[
|
|
35
|
+
'pydantic',
|
|
36
|
+
'loguru',
|
|
37
|
+
'boto3',
|
|
38
|
+
],
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@mcp.tool()
|
|
43
|
+
async def get_resource_schema_information(
|
|
44
|
+
resource_type: str = Field(
|
|
45
|
+
description='The AWS resource type (e.g., "AWS::S3::Bucket", "AWS::RDS::DBInstance")'
|
|
46
|
+
),
|
|
47
|
+
region: str | None = Field(
|
|
48
|
+
description='The AWS region that the operation should be performed in', default=None
|
|
49
|
+
),
|
|
50
|
+
) -> dict:
|
|
51
|
+
"""Get schema information for an AWS resource.
|
|
52
|
+
|
|
53
|
+
Parameters:
|
|
54
|
+
resource_type: The AWS resource type (e.g., "AWS::S3::Bucket")
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
The resource schema information
|
|
58
|
+
"""
|
|
59
|
+
if not resource_type:
|
|
60
|
+
raise ClientError('Please provide a resource type (e.g., AWS::S3::Bucket)')
|
|
61
|
+
|
|
62
|
+
sm = schema_manager()
|
|
63
|
+
schema = await sm.get_schema(resource_type, region)
|
|
64
|
+
return schema
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@mcp.tool()
|
|
68
|
+
async def list_resources(
|
|
69
|
+
resource_type: str = Field(
|
|
70
|
+
description='The AWS resource type (e.g., "AWS::S3::Bucket", "AWS::RDS::DBInstance")'
|
|
71
|
+
),
|
|
72
|
+
region: str | None = Field(
|
|
73
|
+
description='The AWS region that the operation should be performed in', default=None
|
|
74
|
+
),
|
|
75
|
+
) -> list:
|
|
76
|
+
"""List AWS resources of a specified type.
|
|
77
|
+
|
|
78
|
+
Parameters:
|
|
79
|
+
resource_type: The AWS resource type (e.g., "AWS::S3::Bucket", "AWS::RDS::DBInstance")
|
|
80
|
+
region: AWS region to use (e.g., "us-east-1", "us-west-2")
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
A list of resource identifiers
|
|
84
|
+
"""
|
|
85
|
+
if not resource_type:
|
|
86
|
+
raise ClientError('Please provide a resource type (e.g., AWS::S3::Bucket)')
|
|
87
|
+
|
|
88
|
+
cloudcontrol = get_aws_client('cloudcontrol', region)
|
|
89
|
+
paginator = cloudcontrol.get_paginator('list_resources')
|
|
90
|
+
|
|
91
|
+
results = []
|
|
92
|
+
page_iterator = paginator.paginate(TypeName=resource_type)
|
|
93
|
+
try:
|
|
94
|
+
for page in page_iterator:
|
|
95
|
+
results.extend(page['ResourceDescriptions'])
|
|
96
|
+
except Exception as e:
|
|
97
|
+
raise handle_aws_api_error(e)
|
|
98
|
+
|
|
99
|
+
return [response['Identifier'] for response in results]
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@mcp.tool()
|
|
103
|
+
async def get_resource(
|
|
104
|
+
resource_type: str = Field(
|
|
105
|
+
description='The AWS resource type (e.g., "AWS::S3::Bucket", "AWS::RDS::DBInstance")'
|
|
106
|
+
),
|
|
107
|
+
identifier: str = Field(
|
|
108
|
+
description='The primary identifier of the resource to get (e.g., bucket name for S3 buckets)'
|
|
109
|
+
),
|
|
110
|
+
region: str | None = Field(
|
|
111
|
+
description='The AWS region that the operation should be performed in', default=None
|
|
112
|
+
),
|
|
113
|
+
) -> dict:
|
|
114
|
+
"""Get details of a specific AWS resource.
|
|
115
|
+
|
|
116
|
+
Parameters:
|
|
117
|
+
resource_type: The AWS resource type (e.g., "AWS::S3::Bucket")
|
|
118
|
+
identifier: The primary identifier of the resource to get (e.g., bucket name for S3 buckets)
|
|
119
|
+
region: AWS region to use (e.g., "us-east-1", "us-west-2")
|
|
120
|
+
|
|
121
|
+
Returns:
|
|
122
|
+
Detailed information about the specified resource with a consistent structure:
|
|
123
|
+
{
|
|
124
|
+
"identifier": The resource identifier,
|
|
125
|
+
"properties": The detailed information about the resource
|
|
126
|
+
}
|
|
127
|
+
"""
|
|
128
|
+
if not resource_type:
|
|
129
|
+
raise ClientError('Please provide a resource type (e.g., AWS::S3::Bucket)')
|
|
130
|
+
|
|
131
|
+
if not identifier:
|
|
132
|
+
raise ClientError('Please provide a resource identifier')
|
|
133
|
+
|
|
134
|
+
cloudcontrol = get_aws_client('cloudcontrol', region)
|
|
135
|
+
try:
|
|
136
|
+
result = cloudcontrol.get_resource(TypeName=resource_type, Identifier=identifier)
|
|
137
|
+
return {
|
|
138
|
+
'identifier': result['ResourceDescription']['Identifier'],
|
|
139
|
+
'properties': result['ResourceDescription']['Properties'],
|
|
140
|
+
}
|
|
141
|
+
except Exception as e:
|
|
142
|
+
raise handle_aws_api_error(e)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
@mcp.tool()
|
|
146
|
+
async def update_resource(
|
|
147
|
+
resource_type: str = Field(
|
|
148
|
+
description='The AWS resource type (e.g., "AWS::S3::Bucket", "AWS::RDS::DBInstance")'
|
|
149
|
+
),
|
|
150
|
+
identifier: str = Field(
|
|
151
|
+
description='The primary identifier of the resource to get (e.g., bucket name for S3 buckets)'
|
|
152
|
+
),
|
|
153
|
+
patch_document: list = Field(
|
|
154
|
+
description='A list of RFC 6902 JSON Patch operations to apply', default=[]
|
|
155
|
+
),
|
|
156
|
+
region: str | None = Field(
|
|
157
|
+
description='The AWS region that the operation should be performed in', default=None
|
|
158
|
+
),
|
|
159
|
+
) -> dict:
|
|
160
|
+
"""Update an AWS resource.
|
|
161
|
+
|
|
162
|
+
Parameters:
|
|
163
|
+
resource_type: The AWS resource type (e.g., "AWS::S3::Bucket")
|
|
164
|
+
identifier: The primary identifier of the resource to update
|
|
165
|
+
patch_document: A list of RFC 6902 JSON Patch operations to apply
|
|
166
|
+
region: AWS region to use (e.g., "us-east-1", "us-west-2")
|
|
167
|
+
|
|
168
|
+
Returns:
|
|
169
|
+
Information about the updated resource with a consistent structure:
|
|
170
|
+
{
|
|
171
|
+
"status": Status of the operation ("SUCCESS", "PENDING", "FAILED", etc.)
|
|
172
|
+
"resource_type": The AWS resource type
|
|
173
|
+
"identifier": The resource identifier
|
|
174
|
+
"is_complete": Boolean indicating whether the operation is complete
|
|
175
|
+
"status_message": Human-readable message describing the result
|
|
176
|
+
"request_token": A token that allows you to track long running operations via the get_request_status tool
|
|
177
|
+
"resource_info": Optional information about the resource properties
|
|
178
|
+
}
|
|
179
|
+
"""
|
|
180
|
+
if not resource_type:
|
|
181
|
+
raise ClientError('Please provide a resource type (e.g., AWS::S3::Bucket)')
|
|
182
|
+
|
|
183
|
+
if not identifier:
|
|
184
|
+
raise ClientError('Please provide a resource identifier')
|
|
185
|
+
|
|
186
|
+
if not patch_document:
|
|
187
|
+
raise ClientError('Please provide a patch document for the update')
|
|
188
|
+
|
|
189
|
+
if Context.readonly_mode():
|
|
190
|
+
raise ClientError(
|
|
191
|
+
'You have configured this tool in readonly mode. To make this change you will have to update your configuration.'
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
validate_patch(patch_document)
|
|
195
|
+
cloudcontrol_client = get_aws_client('cloudcontrol', region)
|
|
196
|
+
|
|
197
|
+
# Convert patch document to JSON string for the API
|
|
198
|
+
patch_document_str = json.dumps(patch_document)
|
|
199
|
+
|
|
200
|
+
# Update the resource
|
|
201
|
+
try:
|
|
202
|
+
response = cloudcontrol_client.update_resource(
|
|
203
|
+
TypeName=resource_type, Identifier=identifier, PatchDocument=patch_document_str
|
|
204
|
+
)
|
|
205
|
+
except Exception as e:
|
|
206
|
+
raise handle_aws_api_error(e)
|
|
207
|
+
|
|
208
|
+
return progress_event(response['ProgressEvent'])
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
@mcp.tool()
|
|
212
|
+
async def create_resource(
|
|
213
|
+
resource_type: str = Field(
|
|
214
|
+
description='The AWS resource type (e.g., "AWS::S3::Bucket", "AWS::RDS::DBInstance")'
|
|
215
|
+
),
|
|
216
|
+
properties: dict = Field(description='A dictionary of properties for the resource'),
|
|
217
|
+
region: str | None = Field(
|
|
218
|
+
description='The AWS region that the operation should be performed in', default=None
|
|
219
|
+
),
|
|
220
|
+
) -> dict:
|
|
221
|
+
"""Create an AWS resource.
|
|
222
|
+
|
|
223
|
+
Parameters:
|
|
224
|
+
resource_type: The AWS resource type (e.g., "AWS::S3::Bucket")
|
|
225
|
+
properties: A dictionary of properties for the resource
|
|
226
|
+
region: AWS region to use (e.g., "us-east-1", "us-west-2")
|
|
227
|
+
|
|
228
|
+
Returns:
|
|
229
|
+
Information about the created resource with a consistent structure:
|
|
230
|
+
{
|
|
231
|
+
"status": Status of the operation ("SUCCESS", "PENDING", "FAILED", etc.)
|
|
232
|
+
"resource_type": The AWS resource type
|
|
233
|
+
"identifier": The resource identifier
|
|
234
|
+
"is_complete": Boolean indicating whether the operation is complete
|
|
235
|
+
"status_message": Human-readable message describing the result
|
|
236
|
+
"request_token": A token that allows you to track long running operations via the get_request_status tool
|
|
237
|
+
"resource_info": Optional information about the resource properties
|
|
238
|
+
}
|
|
239
|
+
"""
|
|
240
|
+
if not resource_type:
|
|
241
|
+
raise ClientError('Please provide a resource type (e.g., AWS::S3::Bucket)')
|
|
242
|
+
|
|
243
|
+
if not properties:
|
|
244
|
+
raise ClientError('Please provide the properties for the desired resource')
|
|
245
|
+
|
|
246
|
+
if Context.readonly_mode():
|
|
247
|
+
raise ClientError(
|
|
248
|
+
'You have configured this tool in readonly mode. To make this change you will have to update your configuration.'
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
cloudcontrol_client = get_aws_client('cloudcontrol', region)
|
|
252
|
+
try:
|
|
253
|
+
response = cloudcontrol_client.create_resource(
|
|
254
|
+
TypeName=resource_type, DesiredState=json.dumps(properties)
|
|
255
|
+
)
|
|
256
|
+
except Exception as e:
|
|
257
|
+
raise handle_aws_api_error(e)
|
|
258
|
+
|
|
259
|
+
return progress_event(response['ProgressEvent'])
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
@mcp.tool()
|
|
263
|
+
async def delete_resource(
|
|
264
|
+
resource_type: str = Field(
|
|
265
|
+
description='The AWS resource type (e.g., "AWS::S3::Bucket", "AWS::RDS::DBInstance")'
|
|
266
|
+
),
|
|
267
|
+
identifier: str = Field(
|
|
268
|
+
description='The primary identifier of the resource to get (e.g., bucket name for S3 buckets)'
|
|
269
|
+
),
|
|
270
|
+
region: str | None = Field(
|
|
271
|
+
description='The AWS region that the operation should be performed in', default=None
|
|
272
|
+
),
|
|
273
|
+
) -> dict:
|
|
274
|
+
"""Delete an AWS resource.
|
|
275
|
+
|
|
276
|
+
Parameters:
|
|
277
|
+
resource_type: The AWS resource type (e.g., "AWS::S3::Bucket")
|
|
278
|
+
identifier: The primary identifier of the resource to delete (e.g., bucket name for S3 buckets)
|
|
279
|
+
region: AWS region to use (e.g., "us-east-1", "us-west-2")
|
|
280
|
+
|
|
281
|
+
Returns:
|
|
282
|
+
Information about the deletion operation with a consistent structure:
|
|
283
|
+
{
|
|
284
|
+
"status": Status of the operation ("SUCCESS", "PENDING", "FAILED", "NOT_FOUND", etc.)
|
|
285
|
+
"resource_type": The AWS resource type
|
|
286
|
+
"identifier": The resource identifier
|
|
287
|
+
"is_complete": Boolean indicating whether the operation is complete
|
|
288
|
+
"status_message": Human-readable message describing the result
|
|
289
|
+
"request_token": A token that allows you to track long running operations via the get_request_status tool
|
|
290
|
+
}
|
|
291
|
+
"""
|
|
292
|
+
if not resource_type:
|
|
293
|
+
raise ClientError('Please provide a resource type (e.g., AWS::S3::Bucket)')
|
|
294
|
+
|
|
295
|
+
if not identifier:
|
|
296
|
+
raise ClientError('Please provide a resource identifier')
|
|
297
|
+
|
|
298
|
+
if Context.readonly_mode():
|
|
299
|
+
raise ClientError(
|
|
300
|
+
'You have configured this tool in readonly mode. To make this change you will have to update your configuration.'
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
cloudcontrol_client = get_aws_client('cloudcontrol', region)
|
|
304
|
+
try:
|
|
305
|
+
response = cloudcontrol_client.delete_resource(
|
|
306
|
+
TypeName=resource_type, Identifier=identifier
|
|
307
|
+
)
|
|
308
|
+
except Exception as e:
|
|
309
|
+
raise handle_aws_api_error(e)
|
|
310
|
+
|
|
311
|
+
return progress_event(response['ProgressEvent'])
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
@mcp.tool()
|
|
315
|
+
async def get_request_status(
|
|
316
|
+
request_token: str = Field(
|
|
317
|
+
description='The request_token returned from the long running operation'
|
|
318
|
+
),
|
|
319
|
+
region: str | None = Field(
|
|
320
|
+
description='The AWS region that the operation should be performed in', default=None
|
|
321
|
+
),
|
|
322
|
+
) -> dict:
|
|
323
|
+
"""Get the status of a long running operation with the request token.
|
|
324
|
+
|
|
325
|
+
Args:
|
|
326
|
+
request_token: The request_token returned from the long running operation
|
|
327
|
+
region: AWS region to use (e.g., "us-east-1", "us-west-2")
|
|
328
|
+
|
|
329
|
+
Returns:
|
|
330
|
+
Detailed information about the request status structured as
|
|
331
|
+
{
|
|
332
|
+
"status": Status of the operation ("SUCCESS", "PENDING", "FAILED", "NOT_FOUND", etc.)
|
|
333
|
+
"resource_type": The AWS resource type
|
|
334
|
+
"identifier": The resource identifier
|
|
335
|
+
"is_complete": Boolean indicating whether the operation is complete
|
|
336
|
+
"status_message": Human-readable message describing the result
|
|
337
|
+
"request_token": A token that allows you to track long running operations via the get_request_status tool
|
|
338
|
+
"error_code": A code associated with any errors if the request failed
|
|
339
|
+
"retry_after": A duration to wait before retrying the request
|
|
340
|
+
}
|
|
341
|
+
"""
|
|
342
|
+
if not request_token:
|
|
343
|
+
raise ClientError('Please provide a request token to track the request')
|
|
344
|
+
|
|
345
|
+
cloudcontrol_client = get_aws_client('cloudcontrol', region)
|
|
346
|
+
try:
|
|
347
|
+
response = cloudcontrol_client.get_resource_request_status(
|
|
348
|
+
RequestToken=request_token,
|
|
349
|
+
)
|
|
350
|
+
except Exception as e:
|
|
351
|
+
raise handle_aws_api_error(e)
|
|
352
|
+
|
|
353
|
+
return progress_event(response['ProgressEvent'])
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
def main():
|
|
357
|
+
"""Run the MCP server with CLI argument support."""
|
|
358
|
+
parser = argparse.ArgumentParser(
|
|
359
|
+
description='An AWS Labs Model Context Protocol (MCP) server for doing common cloudformation tasks and for managing your resources in your AWS account'
|
|
360
|
+
)
|
|
361
|
+
parser.add_argument('--sse', action='store_true', help='Use SSE transport')
|
|
362
|
+
parser.add_argument('--port', type=int, default=8888, help='Port to run the server on')
|
|
363
|
+
parser.add_argument(
|
|
364
|
+
'--readonly',
|
|
365
|
+
action=argparse.BooleanOptionalAction,
|
|
366
|
+
help='Prevents the MCP server from performing mutating operations',
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
args = parser.parse_args()
|
|
370
|
+
Context.initialize(args.readonly)
|
|
371
|
+
|
|
372
|
+
# Run server with appropriate transport
|
|
373
|
+
if args.sse:
|
|
374
|
+
mcp.settings.port = args.port
|
|
375
|
+
mcp.run(transport='sse')
|
|
376
|
+
else:
|
|
377
|
+
mcp.run()
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
if __name__ == '__main__':
|
|
381
|
+
main()
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: awslabs.cfn-mcp-server
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: An AWS Labs Model Context Protocol (MCP) server for doing common cloudformation tasks and for managing your resources in your AWS account
|
|
5
|
+
Project-URL: homepage, https://awslabs.github.io/mcp/
|
|
6
|
+
Project-URL: docs, https://awslabs.github.io/mcp/servers/cfn-mcp-server/
|
|
7
|
+
Project-URL: documentation, https://awslabs.github.io/mcp/servers/cfn-mcp-server/
|
|
8
|
+
Project-URL: repository, https://github.com/awslabs/mcp.git
|
|
9
|
+
Project-URL: changelog, https://github.com/awslabs/mcp/blob/main/src/cfn-mcp-server/CHANGELOG.md
|
|
10
|
+
Author: Amazon Web Services
|
|
11
|
+
Author-email: AWSLabs MCP <203918161+awslabs-mcp@users.noreply.github.com>, Karam Singh <karam.singh.vir@gmail.com>, Brian Terry <brianter@amazon.com>, Shardul Vaidya <cam.v737@gmail.com>
|
|
12
|
+
License: Apache-2.0
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
License-File: NOTICE
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: boto3>=1.34.0
|
|
25
|
+
Requires-Dist: loguru>=0.7.0
|
|
26
|
+
Requires-Dist: mcp[cli]>=1.6.0
|
|
27
|
+
Requires-Dist: pydantic>=2.10.6
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# CloudFormation MCP Server
|
|
31
|
+
|
|
32
|
+
Model Context Protocol (MCP) server that enables LLMs to directly create and manage over 1,100 AWS resources through natural language using AWS Cloud Control API with Infrastructure as Code best practices.
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
- **Resource Creation**: Uses a declarative approach to create any of 1,100+ AWS resources through Cloud Control API
|
|
37
|
+
- **Resource Reading**: Reads all properties and attributes of specific AWS resources
|
|
38
|
+
- **Resource Updates**: Uses a declarative approach to apply changes to existing AWS resources
|
|
39
|
+
- **Resource Deletion**: Safely removes AWS resources with proper validation
|
|
40
|
+
- **Resource Listing**: Enumerates all resources of a specified type across your AWS environment
|
|
41
|
+
- **Schema Information**: Returns detailed CloudFormation schema for any resource to enable more effective operations
|
|
42
|
+
- **Natural Language Interface**: Transform infrastructure-as-code from static authoring to dynamic conversations
|
|
43
|
+
- **Partner Resource Support**: Works with both AWS-native and partner-defined resources
|
|
44
|
+
|
|
45
|
+
## Prerequisites
|
|
46
|
+
|
|
47
|
+
1. Configure AWS credentials:
|
|
48
|
+
- Via AWS CLI: `aws configure`
|
|
49
|
+
- Or set environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION)
|
|
50
|
+
2. Ensure your IAM role or user has the necessary permissions (see [Security Considerations](#security-considerations))
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
Here are some ways you can work with MCP across AWS, and we'll be adding support to more products including Amazon Q Developer CLI soon: (e.g. for Amazon Q Developer CLI MCP, `~/.aws/amazonq/mcp.json`):
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"mcpServers": {
|
|
59
|
+
"awslabs.cfn-mcp-server": {
|
|
60
|
+
"command": "uvx",
|
|
61
|
+
"args": [
|
|
62
|
+
"awslabs.aws-cfn-mcp-server@latest",
|
|
63
|
+
"--readonly" // Optional paramter if you would like to restrict the MCP to only read actions
|
|
64
|
+
],
|
|
65
|
+
"env": {
|
|
66
|
+
"AWS_PROFILE": "your-named-profile",
|
|
67
|
+
},
|
|
68
|
+
"disabled": false,
|
|
69
|
+
"autoApprove": []
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
or docker after a succesful `docker build -t awslabs/cfn-mcp-server .`:
|
|
76
|
+
|
|
77
|
+
```file
|
|
78
|
+
# ficticious `.env` file with AWS temporary credentials
|
|
79
|
+
AWS_ACCESS_KEY_ID=ASIAIOSFODNN7EXAMPLE
|
|
80
|
+
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
|
|
81
|
+
AWS_SESSION_TOKEN=AQoEXAMPLEH4aoAH0gNCAPy...truncated...zrkuWJOgQs8IZZaIv2BXIa2R4Olgk
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"mcpServers": {
|
|
87
|
+
"awslabs.cfn-mcp-server": {
|
|
88
|
+
"command": "docker",
|
|
89
|
+
"args": [
|
|
90
|
+
"run",
|
|
91
|
+
"--rm",
|
|
92
|
+
"--interactive",
|
|
93
|
+
"--env-file",
|
|
94
|
+
"/full/path/to/file/above/.env",
|
|
95
|
+
"awslabs/cfn-mcp-server:latest",
|
|
96
|
+
"--readonly" // Optional paramter if you would like to restrict the MCP to only read actions
|
|
97
|
+
],
|
|
98
|
+
"env": {},
|
|
99
|
+
"disabled": false,
|
|
100
|
+
"autoApprove": []
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
NOTE: Your credentials will need to be kept refreshed from your host
|
|
107
|
+
|
|
108
|
+
## Tools
|
|
109
|
+
|
|
110
|
+
### create_resource
|
|
111
|
+
Creates an AWS resource using the AWS Cloud Control API with a declarative approach.
|
|
112
|
+
**Example**: Create an S3 bucket with versioning and encryption enabled.
|
|
113
|
+
|
|
114
|
+
### get_resource
|
|
115
|
+
Gets details of a specific AWS resource using the AWS Cloud Control API.
|
|
116
|
+
**Example**: Get the configuration of an EC2 instance.
|
|
117
|
+
|
|
118
|
+
### update_resource
|
|
119
|
+
Updates an AWS resource using the AWS Cloud Control API with a declarative approach.
|
|
120
|
+
**Example**: Update an RDS instance's storage capacity.
|
|
121
|
+
|
|
122
|
+
### delete_resource
|
|
123
|
+
Deletes an AWS resource using the AWS Cloud Control API.
|
|
124
|
+
**Example**: Remove an unused NAT gateway.
|
|
125
|
+
|
|
126
|
+
### list_resources
|
|
127
|
+
Lists AWS resources of a specified type using AWS Cloud Control API.
|
|
128
|
+
**Example**: List all EC2 instances in a region.
|
|
129
|
+
|
|
130
|
+
### get_resource_schema_information
|
|
131
|
+
Get schema information for an AWS CloudFormation resource.
|
|
132
|
+
**Example**: Get the schema for AWS::S3::Bucket to understand all available properties.
|
|
133
|
+
|
|
134
|
+
### get_request_status
|
|
135
|
+
Get the status of a mutation that was initiated by create/update/delete resource
|
|
136
|
+
**Example**: Give me the status of the last request I made
|
|
137
|
+
|
|
138
|
+
## Basic Usage
|
|
139
|
+
|
|
140
|
+
Examples of how to use the AWS Infrastructure as Code MCP Server:
|
|
141
|
+
|
|
142
|
+
- "Create a new S3 bucket with versioning and encryption enabled"
|
|
143
|
+
- "List all EC2 instances in the production environment"
|
|
144
|
+
- "Update the RDS instance to increase storage to 500GB"
|
|
145
|
+
- "Delete unused NAT gateways in VPC-123"
|
|
146
|
+
- "Set up a three-tier architecture with web, app, and database layers"
|
|
147
|
+
- "Create a disaster recovery environment in us-east-1"
|
|
148
|
+
- "Configure CloudWatch alarms for all production resources"
|
|
149
|
+
- "Implement cross-region replication for critical S3 buckets"
|
|
150
|
+
- "Show me the schema for AWS::Lambda::Function"
|
|
151
|
+
|
|
152
|
+
## Resource Type support
|
|
153
|
+
Resources which are supported by this MCP and the supported operations can be found here: https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/supported-resources.html
|
|
154
|
+
|
|
155
|
+
## Security Considerations
|
|
156
|
+
|
|
157
|
+
When using this MCP server, you should consider:
|
|
158
|
+
|
|
159
|
+
- Ensuring proper IAM permissions are configured before use
|
|
160
|
+
- Use AWS CloudTrail for additional security monitoring
|
|
161
|
+
- Configure resource-specific permissions when possible instead of wildcard permissions
|
|
162
|
+
- Consider using resource tagging for better governance and cost management
|
|
163
|
+
- Review all changes made by the MCP server as part of your regular security reviews
|
|
164
|
+
- If you would like to restrict the MCP to readonly operations, specify --readonly True in the startup arguments for the MCP
|
|
165
|
+
|
|
166
|
+
### Required IAM Permissions
|
|
167
|
+
|
|
168
|
+
Ensure your AWS credentials have the following minimum permissions:
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"Version": "2012-10-17",
|
|
173
|
+
"Statement": [
|
|
174
|
+
{
|
|
175
|
+
"Effect": "Allow",
|
|
176
|
+
"Action": [
|
|
177
|
+
"cloudcontrol:ListResources",
|
|
178
|
+
"cloudcontrol:GetResource",
|
|
179
|
+
"cloudcontrol:CreateResource",
|
|
180
|
+
"cloudcontrol:DeleteResource",
|
|
181
|
+
"cloudcontrol:UpdateResource"
|
|
182
|
+
],
|
|
183
|
+
"Resource": "*"
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Limitations
|
|
190
|
+
|
|
191
|
+
- Operations are limited to resources supported by AWS Cloud Control API
|
|
192
|
+
- Performance depends on the underlying AWS services' response times
|
|
193
|
+
- Some complex resource relationships may require multiple operations
|
|
194
|
+
- This MCP server can only manage resources in the AWS regions where Cloud Control API is available
|
|
195
|
+
- Resource modification operations may be limited by service-specific constraints
|
|
196
|
+
- Rate limiting may affect operations when managing many resources simultaneously
|
|
197
|
+
- Some resource types might not support all operations (create, read, update, delete)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
awslabs/__init__.py,sha256=47wJeKcStxEJwX7SVVV2pnAWYR8FxcaYoT3YTmZ5Plg,674
|
|
2
|
+
awslabs/cfn_mcp_server/__init__.py,sha256=0iDzkNDzH_VHat2joZdYA_i2NeOiAWYlorKpKaW1vpE,611
|
|
3
|
+
awslabs/cfn_mcp_server/aws_client.py,sha256=E7ekLizw0P6q9Pem40UDnhFTHKo5TMYmPeajuFDnMBY,2649
|
|
4
|
+
awslabs/cfn_mcp_server/cloud_control_utils.py,sha256=wUDT-J9iEAOYnqZAG2vDtBsXUp0EUZ__jQzJ4RJ6AvM,2973
|
|
5
|
+
awslabs/cfn_mcp_server/context.py,sha256=YpJZPjyzHW7df9O-lyj2j8yuenZI-yPxLuVuyvmnAnE,777
|
|
6
|
+
awslabs/cfn_mcp_server/errors.py,sha256=rNHaKx9t3xJGLLypSxXO6ec8nl1h19e8_2yYMTmDP4g,4480
|
|
7
|
+
awslabs/cfn_mcp_server/schema_manager.py,sha256=7dw2W2hgdn1ODRU5PrUmOG9_rvnKUhGD51q8Wz4Ksks,6775
|
|
8
|
+
awslabs/cfn_mcp_server/server.py,sha256=y0ipXAv2TKIxYTaGQZDkU1nxb7y6bXN9BW-TkzFSzuU,14177
|
|
9
|
+
awslabs_cfn_mcp_server-0.0.1.dist-info/METADATA,sha256=q3oLI4k5q_bNnJHwGmrxleB97Y_IBbxA9IGdZMdB_kk,7875
|
|
10
|
+
awslabs_cfn_mcp_server-0.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
11
|
+
awslabs_cfn_mcp_server-0.0.1.dist-info/entry_points.txt,sha256=Hartc24s_fYgi3o2m2tBHahod0pqXYwpebQy2_tXL7s,78
|
|
12
|
+
awslabs_cfn_mcp_server-0.0.1.dist-info/licenses/LICENSE,sha256=CeipvOyAZxBGUsFoaFqwkx54aPnIKEtm9a5u2uXxEws,10142
|
|
13
|
+
awslabs_cfn_mcp_server-0.0.1.dist-info/licenses/NOTICE,sha256=bcw4NZAgn5eQZzrtuDiwOe23BRSm_JiRzn0gxBLDzlg,90
|
|
14
|
+
awslabs_cfn_mcp_server-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|