awslabs.elasticache-mcp-server 0.1.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.
Files changed (60) hide show
  1. awslabs/__init__.py +16 -0
  2. awslabs/elasticache_mcp_server/__init__.py +17 -0
  3. awslabs/elasticache_mcp_server/common/__init__.py +15 -0
  4. awslabs/elasticache_mcp_server/common/connection.py +117 -0
  5. awslabs/elasticache_mcp_server/common/decorators.py +41 -0
  6. awslabs/elasticache_mcp_server/common/server.py +30 -0
  7. awslabs/elasticache_mcp_server/context.py +39 -0
  8. awslabs/elasticache_mcp_server/main.py +52 -0
  9. awslabs/elasticache_mcp_server/tools/__init__.py +15 -0
  10. awslabs/elasticache_mcp_server/tools/cc/__init__.py +31 -0
  11. awslabs/elasticache_mcp_server/tools/cc/connect.py +444 -0
  12. awslabs/elasticache_mcp_server/tools/cc/create.py +212 -0
  13. awslabs/elasticache_mcp_server/tools/cc/delete.py +65 -0
  14. awslabs/elasticache_mcp_server/tools/cc/describe.py +80 -0
  15. awslabs/elasticache_mcp_server/tools/cc/modify.py +159 -0
  16. awslabs/elasticache_mcp_server/tools/cc/parsers.py +78 -0
  17. awslabs/elasticache_mcp_server/tools/cc/processors.py +74 -0
  18. awslabs/elasticache_mcp_server/tools/ce/__init__.py +19 -0
  19. awslabs/elasticache_mcp_server/tools/ce/get_cost_and_usage.py +76 -0
  20. awslabs/elasticache_mcp_server/tools/cw/__init__.py +19 -0
  21. awslabs/elasticache_mcp_server/tools/cw/get_metric_statistics.py +85 -0
  22. awslabs/elasticache_mcp_server/tools/cwlogs/__init__.py +29 -0
  23. awslabs/elasticache_mcp_server/tools/cwlogs/create_log_group.py +68 -0
  24. awslabs/elasticache_mcp_server/tools/cwlogs/describe_log_groups.py +123 -0
  25. awslabs/elasticache_mcp_server/tools/cwlogs/describe_log_streams.py +120 -0
  26. awslabs/elasticache_mcp_server/tools/cwlogs/filter_log_events.py +122 -0
  27. awslabs/elasticache_mcp_server/tools/cwlogs/get_log_events.py +99 -0
  28. awslabs/elasticache_mcp_server/tools/firehose/__init__.py +19 -0
  29. awslabs/elasticache_mcp_server/tools/firehose/list_delivery_streams.py +63 -0
  30. awslabs/elasticache_mcp_server/tools/misc/__init__.py +31 -0
  31. awslabs/elasticache_mcp_server/tools/misc/batch_apply_update_action.py +62 -0
  32. awslabs/elasticache_mcp_server/tools/misc/batch_stop_update_action.py +62 -0
  33. awslabs/elasticache_mcp_server/tools/misc/describe_cache_engine_versions.py +79 -0
  34. awslabs/elasticache_mcp_server/tools/misc/describe_engine_default_parameters.py +64 -0
  35. awslabs/elasticache_mcp_server/tools/misc/describe_events.py +86 -0
  36. awslabs/elasticache_mcp_server/tools/misc/describe_service_updates.py +71 -0
  37. awslabs/elasticache_mcp_server/tools/rg/__init__.py +54 -0
  38. awslabs/elasticache_mcp_server/tools/rg/complete_migration.py +94 -0
  39. awslabs/elasticache_mcp_server/tools/rg/connect.py +537 -0
  40. awslabs/elasticache_mcp_server/tools/rg/create.py +318 -0
  41. awslabs/elasticache_mcp_server/tools/rg/delete.py +68 -0
  42. awslabs/elasticache_mcp_server/tools/rg/describe.py +68 -0
  43. awslabs/elasticache_mcp_server/tools/rg/modify.py +236 -0
  44. awslabs/elasticache_mcp_server/tools/rg/parsers.py +268 -0
  45. awslabs/elasticache_mcp_server/tools/rg/processors.py +227 -0
  46. awslabs/elasticache_mcp_server/tools/rg/start_migration.py +151 -0
  47. awslabs/elasticache_mcp_server/tools/rg/test_migration.py +139 -0
  48. awslabs/elasticache_mcp_server/tools/serverless/__init__.py +37 -0
  49. awslabs/elasticache_mcp_server/tools/serverless/connect.py +451 -0
  50. awslabs/elasticache_mcp_server/tools/serverless/create.py +174 -0
  51. awslabs/elasticache_mcp_server/tools/serverless/delete.py +49 -0
  52. awslabs/elasticache_mcp_server/tools/serverless/describe.py +69 -0
  53. awslabs/elasticache_mcp_server/tools/serverless/models.py +160 -0
  54. awslabs/elasticache_mcp_server/tools/serverless/modify.py +95 -0
  55. awslabs_elasticache_mcp_server-0.1.1.dist-info/METADATA +257 -0
  56. awslabs_elasticache_mcp_server-0.1.1.dist-info/RECORD +60 -0
  57. awslabs_elasticache_mcp_server-0.1.1.dist-info/WHEEL +4 -0
  58. awslabs_elasticache_mcp_server-0.1.1.dist-info/entry_points.txt +2 -0
  59. awslabs_elasticache_mcp_server-0.1.1.dist-info/licenses/LICENSE +175 -0
  60. awslabs_elasticache_mcp_server-0.1.1.dist-info/licenses/NOTICE +2 -0
awslabs/__init__.py ADDED
@@ -0,0 +1,16 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # This file is part of the awslabs namespace.
16
+ # It is intentionally minimal to support PEP 420 namespace packages.
@@ -0,0 +1,17 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """awslabs.elasticache-mcp-server"""
16
+
17
+ __version__ = '0.1.0'
@@ -0,0 +1,15 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Common package for ElastiCache MCP server."""
@@ -0,0 +1,117 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Connection management for AWS services used by MCP Server."""
16
+
17
+ import boto3
18
+ import os
19
+ from botocore.config import Config
20
+ from typing import Any, Optional
21
+
22
+
23
+ class BaseConnectionManager:
24
+ """Base class for AWS service connection managers."""
25
+
26
+ _client: Optional[Any] = None
27
+ _service_name: str = '' # Must be overridden by subclasses
28
+ _env_prefix: str = '' # Must be overridden by subclasses
29
+
30
+ @classmethod
31
+ def get_connection(cls) -> Any:
32
+ """Get or create an AWS service client connection with retry capabilities.
33
+
34
+ Returns:
35
+ boto3.client: An AWS service client configured with retries
36
+ """
37
+ if cls._client is None:
38
+ # Get AWS configuration from environment
39
+ aws_profile = os.environ.get('AWS_PROFILE', 'default')
40
+ aws_region = os.environ.get('AWS_REGION', 'us-east-1')
41
+
42
+ # Configure retry settings
43
+ max_retries = int(os.environ.get(f'{cls._env_prefix}_MAX_RETRIES', '3'))
44
+ retry_mode = os.environ.get(f'{cls._env_prefix}_RETRY_MODE', 'standard')
45
+ connect_timeout = int(os.environ.get(f'{cls._env_prefix}_CONNECT_TIMEOUT', '5'))
46
+ read_timeout = int(os.environ.get(f'{cls._env_prefix}_READ_TIMEOUT', '10'))
47
+
48
+ # Create boto3 config with retry settings
49
+ config = Config(
50
+ retries={'max_attempts': max_retries, 'mode': retry_mode},
51
+ connect_timeout=connect_timeout,
52
+ read_timeout=read_timeout,
53
+ # Configure custom user agent to identify requests from LLM/MCP
54
+ user_agent_extra='MCP/ElastiCacheServer',
55
+ )
56
+
57
+ # Initialize AWS client with session and config
58
+ # so that if user changes credential, it will be reflected immediately in the next call
59
+ session = boto3.Session(profile_name=aws_profile, region_name=aws_region)
60
+ cls._client = session.client(service_name=cls._service_name, config=config)
61
+
62
+ return cls._client
63
+
64
+ @classmethod
65
+ def close_connection(cls) -> None:
66
+ """Close the AWS service client connection."""
67
+ if cls._client is not None:
68
+ cls._client.close()
69
+ cls._client = None
70
+
71
+
72
+ class ElastiCacheConnectionManager(BaseConnectionManager):
73
+ """Manages connection to ElastiCache using boto3."""
74
+
75
+ _client: Optional[Any] = None
76
+ _service_name = 'elasticache'
77
+ _env_prefix = 'ELASTICACHE'
78
+
79
+
80
+ class EC2ConnectionManager(BaseConnectionManager):
81
+ """Manages connection to EC2 using boto3."""
82
+
83
+ _client: Optional[Any] = None
84
+ _service_name = 'ec2'
85
+ _env_prefix = 'EC2'
86
+
87
+
88
+ class CloudWatchLogsConnectionManager(BaseConnectionManager):
89
+ """Manages connection to CloudWatch Logs using boto3."""
90
+
91
+ _client: Optional[Any] = None
92
+ _service_name = 'logs'
93
+ _env_prefix = 'CLOUDWATCH_LOGS'
94
+
95
+
96
+ class FirehoseConnectionManager(BaseConnectionManager):
97
+ """Manages connection to Kinesis Firehose using boto3."""
98
+
99
+ _client: Optional[Any] = None
100
+ _service_name = 'firehose'
101
+ _env_prefix = 'FIREHOSE'
102
+
103
+
104
+ class CostExplorerConnectionManager(BaseConnectionManager):
105
+ """Manages connection to AWS Cost Explorer using boto3."""
106
+
107
+ _client: Optional[Any] = None
108
+ _service_name = 'ce'
109
+ _env_prefix = 'COST_EXPLORER'
110
+
111
+
112
+ class CloudWatchConnectionManager(BaseConnectionManager):
113
+ """Manages connection to CloudWatch using boto3."""
114
+
115
+ _client: Optional[Any] = None
116
+ _service_name = 'cloudwatch'
117
+ _env_prefix = 'CLOUDWATCH'
@@ -0,0 +1,41 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Decorators for ElastiCache MCP Server."""
16
+
17
+ from functools import wraps
18
+ from typing import Any, Callable
19
+
20
+
21
+ def handle_exceptions(func: Callable) -> Callable:
22
+ """Decorator to handle exceptions in ElastiCache operations.
23
+
24
+ Wraps the function in a try-catch block and returns any exceptions
25
+ in a standardized error format.
26
+
27
+ Args:
28
+ func: The function to wrap
29
+
30
+ Returns:
31
+ The wrapped function that handles exceptions
32
+ """
33
+
34
+ @wraps(func)
35
+ async def wrapper(*args: Any, **kwargs: Any):
36
+ try:
37
+ return await func(*args, **kwargs)
38
+ except Exception as e:
39
+ return {'error': str(e)}
40
+
41
+ return wrapper
@@ -0,0 +1,30 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Common MCP server configuration."""
16
+
17
+ from mcp.server.fastmcp import FastMCP
18
+
19
+
20
+ mcp = FastMCP(
21
+ 'awslabs.elasticache-mcp-server',
22
+ instructions="""AWS ElastiCache MCP Server provides tools for interacting with Amazon ElastiCache.
23
+ These tools allow you to describe and manage serverless caches in your AWS account.
24
+ You can use these capabilities to get information about cache configurations, endpoints, and more.""",
25
+ dependencies=[
26
+ 'pydantic',
27
+ 'loguru',
28
+ 'boto3',
29
+ ],
30
+ )
@@ -0,0 +1,39 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Context management for ElastiCache MCP Server."""
16
+
17
+
18
+ class Context:
19
+ """Context class for ElastiCache MCP Server."""
20
+
21
+ _readonly = False
22
+
23
+ @classmethod
24
+ def initialize(cls, readonly: bool = False):
25
+ """Initialize the context.
26
+
27
+ Args:
28
+ readonly: Whether to run in readonly mode
29
+ """
30
+ cls._readonly = readonly
31
+
32
+ @classmethod
33
+ def readonly_mode(cls) -> bool:
34
+ """Check if the server is running in readonly mode.
35
+
36
+ Returns:
37
+ True if readonly mode is enabled, False otherwise
38
+ """
39
+ return cls._readonly
@@ -0,0 +1,52 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """awslabs elasticache MCP Server implementation."""
16
+
17
+ import argparse
18
+ from awslabs.elasticache_mcp_server.common.server import mcp
19
+ from awslabs.elasticache_mcp_server.context import Context
20
+ from awslabs.elasticache_mcp_server.tools import ( # noqa: F401 - imported for side effects to register tools
21
+ cc,
22
+ ce,
23
+ cw,
24
+ cwlogs,
25
+ firehose,
26
+ misc,
27
+ rg,
28
+ serverless,
29
+ )
30
+ from loguru import logger
31
+
32
+
33
+ def main():
34
+ """Run the MCP server with CLI argument support."""
35
+ parser = argparse.ArgumentParser(
36
+ description='An AWS Labs Model Context Protocol (MCP) server for interacting with Amazon ElastiCache'
37
+ )
38
+ parser.add_argument(
39
+ '--readonly',
40
+ action=argparse.BooleanOptionalAction,
41
+ help='Prevents the MCP server from performing mutating operations',
42
+ )
43
+
44
+ args = parser.parse_args()
45
+ Context.initialize(args.readonly)
46
+
47
+ logger.info('Amazon ElastiCache MCP Server Started...')
48
+ mcp.run()
49
+
50
+
51
+ if __name__ == '__main__':
52
+ main()
@@ -0,0 +1,15 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Tools package for ElastiCache MCP server."""
@@ -0,0 +1,31 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Cache cluster tools for ElastiCache MCP server."""
16
+
17
+ from .create import create_cache_cluster
18
+ from .delete import delete_cache_cluster
19
+ from .describe import describe_cache_clusters
20
+ from .modify import modify_cache_cluster
21
+ from .connect import connect_jump_host_cc, get_ssh_tunnel_command_cc, create_jump_host_cc
22
+
23
+ __all__ = [
24
+ 'create_cache_cluster',
25
+ 'delete_cache_cluster',
26
+ 'describe_cache_clusters',
27
+ 'modify_cache_cluster',
28
+ 'connect_jump_host_cc',
29
+ 'get_ssh_tunnel_command_cc',
30
+ 'create_jump_host_cc',
31
+ ]