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
@@ -0,0 +1,62 @@
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
+ """Batch apply update action tool for ElastiCache MCP server."""
16
+
17
+ from ...common.connection import ElastiCacheConnectionManager
18
+ from ...common.decorators import handle_exceptions
19
+ from ...common.server import mcp
20
+ from ...context import Context
21
+ from typing import Dict, List, Optional
22
+
23
+
24
+ @mcp.tool(name='batch-apply-update-action')
25
+ @handle_exceptions
26
+ async def batch_apply_update_action(
27
+ service_update_name: str,
28
+ replication_group_ids: Optional[List[str]] = None,
29
+ cache_cluster_ids: Optional[List[str]] = None,
30
+ ) -> Dict:
31
+ """Apply service update to multiple ElastiCache resources.
32
+
33
+ Parameters:
34
+ service_update_name (str): The unique ID of the service update to apply.
35
+ replication_group_ids (Optional[List[str]]): List of replication group IDs to update.
36
+ Either this or cache_cluster_ids must be provided.
37
+ cache_cluster_ids (Optional[List[str]]): List of cache cluster IDs to update.
38
+ Either this or replication_group_ids must be provided.
39
+
40
+ Returns:
41
+ Dict containing information about the batch update operation.
42
+ """
43
+ # Check if readonly mode is enabled
44
+ if Context.readonly_mode():
45
+ raise ValueError(
46
+ 'You have configured this tool in readonly mode. To make this change you will have to update your configuration.'
47
+ )
48
+
49
+ # Get ElastiCache client
50
+ elasticache_client = ElastiCacheConnectionManager.get_connection()
51
+
52
+ # Build request
53
+ request: Dict[str, str | List[str]] = {'ServiceUpdateName': service_update_name}
54
+
55
+ if replication_group_ids:
56
+ request['ReplicationGroupIds'] = replication_group_ids
57
+ if cache_cluster_ids:
58
+ request['CacheClusterIds'] = cache_cluster_ids
59
+
60
+ # Apply the service update
61
+ response = elasticache_client.batch_apply_update_action(**request)
62
+ return response
@@ -0,0 +1,62 @@
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
+ """Batch stop update action tool for ElastiCache MCP server."""
16
+
17
+ from ...common.connection import ElastiCacheConnectionManager
18
+ from ...common.decorators import handle_exceptions
19
+ from ...common.server import mcp
20
+ from ...context import Context
21
+ from typing import Dict, List, Optional
22
+
23
+
24
+ @mcp.tool(name='batch-stop-update-action')
25
+ @handle_exceptions
26
+ async def batch_stop_update_action(
27
+ service_update_name: str,
28
+ replication_group_ids: Optional[List[str]] = None,
29
+ cache_cluster_ids: Optional[List[str]] = None,
30
+ ) -> Dict:
31
+ """Stop service update for multiple ElastiCache resources.
32
+
33
+ Parameters:
34
+ service_update_name (str): The unique ID of the service update to stop.
35
+ replication_group_ids (Optional[List[str]]): List of replication group IDs to stop update.
36
+ Either this or cache_cluster_ids must be provided.
37
+ cache_cluster_ids (Optional[List[str]]): List of cache cluster IDs to stop update.
38
+ Either this or replication_group_ids must be provided.
39
+
40
+ Returns:
41
+ Dict containing information about the batch stop operation.
42
+ """
43
+ # Check if readonly mode is enabled
44
+ if Context.readonly_mode():
45
+ raise ValueError(
46
+ 'You have configured this tool in readonly mode. To make this change you will have to update your configuration.'
47
+ )
48
+
49
+ # Get ElastiCache client
50
+ elasticache_client = ElastiCacheConnectionManager.get_connection()
51
+
52
+ # Build request
53
+ request: Dict[str, str | List[str]] = {'ServiceUpdateName': service_update_name}
54
+
55
+ if replication_group_ids:
56
+ request['ReplicationGroupIds'] = replication_group_ids
57
+ if cache_cluster_ids:
58
+ request['CacheClusterIds'] = cache_cluster_ids
59
+
60
+ # Stop the service update
61
+ response = elasticache_client.batch_stop_update_action(**request)
62
+ return response
@@ -0,0 +1,79 @@
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
+ """Describe cache engine versions tool for ElastiCache MCP server."""
16
+
17
+ from ...common.connection import ElastiCacheConnectionManager
18
+ from ...common.decorators import handle_exceptions
19
+ from ...common.server import mcp
20
+ from typing import Dict, Optional
21
+
22
+
23
+ @mcp.tool(name='describe-cache-engine-versions')
24
+ @handle_exceptions
25
+ async def describe_cache_engine_versions(
26
+ engine: Optional[str] = None,
27
+ engine_version: Optional[str] = None,
28
+ cache_parameter_group_family: Optional[str] = None,
29
+ max_records: Optional[int] = None,
30
+ marker: Optional[str] = None,
31
+ default_only: Optional[bool] = None,
32
+ ) -> Dict:
33
+ """Returns a list of the available cache engines and their versions.
34
+
35
+ Parameters:
36
+ engine (Optional[str]): The cache engine to return. Valid values: memcached | redis | valkey
37
+ engine_version (Optional[str]): The cache engine version to return.
38
+ Example: memcached 1.4.14, redis 6.x, valkey 8.0
39
+ cache_parameter_group_family (Optional[str]): The name of a specific cache parameter group family.
40
+ Valid values are: memcached1.4 | memcached1.5 | memcached1.6 | redis2.6 | redis2.8 |
41
+ redis3.2 | redis4.0 | redis5.0 | redis6.x | redis7.x | valkey7.x | valkey8.x
42
+ max_records (Optional[int]): The maximum number of records to include in the response.
43
+ If more records exist than the specified MaxRecords value, a marker is included
44
+ in the response so that the remaining results can be retrieved.
45
+ marker (Optional[str]): An optional marker returned from a previous request. Use this marker
46
+ for pagination of results from this operation. If this parameter is specified,
47
+ the response includes only records beyond the marker, up to the value specified
48
+ by MaxRecords.
49
+ default_only (Optional[bool]): If true, specifies that only the default version of the specified engine
50
+ or engine and major version combination is to be returned.
51
+
52
+ Returns:
53
+ Dict containing information about the cache engine versions, including:
54
+ - CacheEngineVersions: List of cache engine versions
55
+ - Marker: Pagination marker for next set of results
56
+ """
57
+ # Get ElastiCache client
58
+ elasticache_client = ElastiCacheConnectionManager.get_connection()
59
+
60
+ # Build describe request
61
+ describe_request = {}
62
+
63
+ # Add optional parameters if provided
64
+ if engine:
65
+ describe_request['Engine'] = engine
66
+ if engine_version:
67
+ describe_request['EngineVersion'] = engine_version
68
+ if cache_parameter_group_family:
69
+ describe_request['CacheParameterGroupFamily'] = cache_parameter_group_family
70
+ if max_records:
71
+ describe_request['MaxRecords'] = max_records
72
+ if marker:
73
+ describe_request['Marker'] = marker
74
+ if default_only is not None:
75
+ describe_request['DefaultOnly'] = default_only
76
+
77
+ # Describe the cache engine versions
78
+ response = elasticache_client.describe_cache_engine_versions(**describe_request)
79
+ return response
@@ -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");
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
+ """Describe engine default parameters tool for ElastiCache MCP server."""
16
+
17
+ from ...common.connection import ElastiCacheConnectionManager
18
+ from ...common.decorators import handle_exceptions
19
+ from ...common.server import mcp
20
+ from typing import Dict, Optional
21
+
22
+
23
+ @mcp.tool(name='describe-engine-default-parameters')
24
+ @handle_exceptions
25
+ async def describe_engine_default_parameters(
26
+ cache_parameter_group_family: str,
27
+ max_records: Optional[int] = None,
28
+ marker: Optional[str] = None,
29
+ ) -> Dict:
30
+ """Returns the default engine and system parameter information for the specified cache engine family.
31
+
32
+ Parameters:
33
+ cache_parameter_group_family (str): The name of the cache parameter group family.
34
+ Valid values are: memcached1.4 | memcached1.5 | memcached1.6 | redis2.6 | redis2.8 |
35
+ redis3.2 | redis4.0 | redis5.0 | redis6.x | redis7.x | valkey7.x | valkey8.x
36
+ max_records (Optional[int]): The maximum number of records to include in the response.
37
+ If more records exist than the specified MaxRecords value, a marker is included
38
+ in the response so that the remaining results can be retrieved.
39
+ marker (Optional[str]): An optional marker returned from a previous request. Use this marker
40
+ for pagination of results from this operation. If this parameter is specified,
41
+ the response includes only records beyond the marker, up to the value specified
42
+ by MaxRecords.
43
+
44
+ Returns:
45
+ Dict containing information about the engine default parameters, including:
46
+ - Parameters: List of parameters with their details
47
+ - CacheParameterGroupFamily: The name of the cache parameter group family
48
+ - Marker: Pagination marker for next set of results
49
+ """
50
+ # Get ElastiCache client
51
+ elasticache_client = ElastiCacheConnectionManager.get_connection()
52
+
53
+ # Build describe request
54
+ describe_request = {'CacheParameterGroupFamily': cache_parameter_group_family}
55
+
56
+ # Add optional parameters if provided
57
+ if max_records is not None:
58
+ describe_request['MaxRecords'] = str(max_records)
59
+ if marker:
60
+ describe_request['Marker'] = marker
61
+
62
+ # Describe the engine default parameters
63
+ response = elasticache_client.describe_engine_default_parameters(**describe_request)
64
+ return response
@@ -0,0 +1,86 @@
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
+ """Describe events tool for ElastiCache MCP server."""
16
+
17
+ from ...common.connection import ElastiCacheConnectionManager
18
+ from ...common.decorators import handle_exceptions
19
+ from ...common.server import mcp
20
+ from datetime import datetime
21
+ from typing import Dict, Optional
22
+
23
+
24
+ @mcp.tool(name='describe-events')
25
+ @handle_exceptions
26
+ async def describe_events(
27
+ source_type: Optional[str] = None,
28
+ source_identifier: Optional[str] = None,
29
+ start_time: Optional[datetime] = None,
30
+ end_time: Optional[datetime] = None,
31
+ duration: Optional[int] = None,
32
+ max_records: Optional[int] = None,
33
+ marker: Optional[str] = None,
34
+ ) -> Dict:
35
+ """Returns events related to clusters, cache security groups, and parameter groups.
36
+
37
+ Parameters:
38
+ source_type (Optional[str]): The event source to retrieve events for. If not specified, all
39
+ events are returned. Valid values: cache-cluster | cache-parameter-group |
40
+ cache-security-group | cache-subnet-group | replication-group | user | user-group
41
+ source_identifier (Optional[str]): The identifier of the event source for which events are
42
+ returned. For example, if source_type is cache-cluster, you can specify a cluster
43
+ identifier to see all events for only that cluster.
44
+ start_time (Optional[datetime]): The beginning of the time interval to retrieve events for,
45
+ specified in ISO 8601 format.
46
+ end_time (Optional[datetime]): The end of the time interval to retrieve events for,
47
+ specified in ISO 8601 format.
48
+ duration (Optional[int]): The number of minutes worth of events to retrieve.
49
+ max_records (Optional[int]): The maximum number of records to include in the response.
50
+ If more records exist than the specified MaxRecords value, a marker is included
51
+ in the response so that the remaining results can be retrieved.
52
+ marker (Optional[str]): An optional marker returned from a previous request. Use this marker
53
+ for pagination of results from this operation. If this parameter is specified,
54
+ the response includes only records beyond the marker, up to the value specified
55
+ by MaxRecords.
56
+
57
+ Returns:
58
+ Dict containing information about the events, including:
59
+ - Events: List of events
60
+ - Marker: Pagination marker for next set of results
61
+ """
62
+ # Get ElastiCache client
63
+ elasticache_client = ElastiCacheConnectionManager.get_connection()
64
+
65
+ # Build describe request
66
+ describe_request = {}
67
+
68
+ # Add optional parameters if provided
69
+ if source_type:
70
+ describe_request['SourceType'] = source_type
71
+ if source_identifier:
72
+ describe_request['SourceIdentifier'] = source_identifier
73
+ if start_time:
74
+ describe_request['StartTime'] = start_time
75
+ if end_time:
76
+ describe_request['EndTime'] = end_time
77
+ if duration:
78
+ describe_request['Duration'] = duration
79
+ if max_records:
80
+ describe_request['MaxRecords'] = max_records
81
+ if marker:
82
+ describe_request['Marker'] = marker
83
+
84
+ # Describe the events
85
+ response = elasticache_client.describe_events(**describe_request)
86
+ return response
@@ -0,0 +1,71 @@
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
+ """Describe service updates tool for ElastiCache MCP server."""
16
+
17
+ from ...common.connection import ElastiCacheConnectionManager
18
+ from ...common.decorators import handle_exceptions
19
+ from ...common.server import mcp
20
+ from typing import Dict, List, Optional
21
+
22
+
23
+ @mcp.tool(name='describe-service-updates')
24
+ @handle_exceptions
25
+ async def describe_service_updates(
26
+ service_update_name: Optional[str] = None,
27
+ service_update_status: Optional[List[str]] = None,
28
+ starting_token: Optional[str] = None,
29
+ page_size: Optional[int] = None,
30
+ max_items: Optional[int] = None,
31
+ ) -> Dict:
32
+ """Returns details of the service updates.
33
+
34
+ Parameters:
35
+ service_update_name (Optional[str]): The unique ID of the service update to describe.
36
+ service_update_status (Optional[List[str]]): List of status values to filter by.
37
+ Valid values: available | cancelled | expired | complete
38
+ starting_token (Optional[str]): An optional token returned from a previous request.
39
+ Use this token for pagination of results from this operation.
40
+ page_size (Optional[int]): The maximum number of records to include in each page
41
+ of results.
42
+ max_items (Optional[int]): The maximum number of records to include in the response.
43
+ If more records exist than the specified MaxItems value, a marker is included
44
+ in the response so that the remaining results can be retrieved.
45
+
46
+ Returns:
47
+ Dict containing information about the service updates, including:
48
+ - ServiceUpdates: List of service updates
49
+ - NextToken: Token for next set of results
50
+ """
51
+ # Get ElastiCache client
52
+ elasticache_client = ElastiCacheConnectionManager.get_connection()
53
+
54
+ # Build describe request
55
+ describe_request = {}
56
+
57
+ # Add optional parameters if provided
58
+ if service_update_name:
59
+ describe_request['ServiceUpdateName'] = service_update_name
60
+ if service_update_status:
61
+ describe_request['ServiceUpdateStatus'] = service_update_status
62
+ if starting_token:
63
+ describe_request['Marker'] = starting_token
64
+ if page_size:
65
+ describe_request['MaxRecords'] = page_size
66
+ if max_items:
67
+ describe_request['MaxItems'] = max_items
68
+
69
+ # Describe the service updates
70
+ response = elasticache_client.describe_service_updates(**describe_request)
71
+ return response
@@ -0,0 +1,54 @@
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
+ """Replication group tools for ElastiCache MCP server."""
16
+
17
+ from .create import create_replication_group
18
+ from .connect import create_jump_host_rg, connect_jump_host_rg, get_ssh_tunnel_command_rg
19
+ from .delete import delete_replication_group
20
+ from .describe import describe_replication_groups
21
+ from .modify import modify_replication_group, modify_replication_group_shard_configuration
22
+ from .test_migration import test_migration
23
+ from .start_migration import start_migration
24
+ from .complete_migration import complete_migration
25
+ from .parsers import (
26
+ parse_shorthand_nodegroup,
27
+ parse_shorthand_log_delivery,
28
+ parse_shorthand_resharding,
29
+ )
30
+ from .processors import (
31
+ process_log_delivery_configurations,
32
+ process_nodegroup_configuration,
33
+ process_resharding_configuration,
34
+ )
35
+
36
+ __all__ = [
37
+ 'connect_jump_host_rg',
38
+ 'create_jump_host_rg',
39
+ 'create_replication_group',
40
+ 'delete_replication_group',
41
+ 'describe_replication_groups',
42
+ 'get_ssh_tunnel_command_rg',
43
+ 'modify_replication_group',
44
+ 'modify_replication_group_shard_configuration',
45
+ 'parse_shorthand_nodegroup',
46
+ 'parse_shorthand_log_delivery',
47
+ 'parse_shorthand_resharding',
48
+ 'process_log_delivery_configurations',
49
+ 'process_nodegroup_configuration',
50
+ 'process_resharding_configuration',
51
+ 'test_migration',
52
+ 'start_migration',
53
+ 'complete_migration',
54
+ ]
@@ -0,0 +1,94 @@
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
+ """Complete migration tool for ElastiCache MCP server."""
16
+
17
+ from ...common.connection import ElastiCacheConnectionManager
18
+ from ...common.decorators import handle_exceptions
19
+ from ...common.server import mcp
20
+ from ...context import Context
21
+ from pydantic import BaseModel, ConfigDict, Field
22
+ from typing import Any, Dict, Optional
23
+
24
+
25
+ class CompleteMigrationRequest(BaseModel):
26
+ """Request model for completing migration to an ElastiCache replication group."""
27
+
28
+ model_config = ConfigDict(validate_by_name=True, arbitrary_types_allowed=True)
29
+
30
+ replication_group_id: str = Field(
31
+ ..., description='The ID of the replication group to which data is being migrated'
32
+ )
33
+ force: Optional[bool] = Field(
34
+ None,
35
+ description='Forces the migration to stop without ensuring that data is in sync. '
36
+ 'It is recommended to use this option only to abort the migration and not recommended '
37
+ 'when application wants to continue migration to ElastiCache.',
38
+ )
39
+
40
+
41
+ def prepare_request_dict(request: CompleteMigrationRequest) -> Dict[str, Any]:
42
+ """Prepare the request dictionary for the AWS API.
43
+
44
+ Args:
45
+ request: The CompleteMigrationRequest object
46
+
47
+ Returns:
48
+ Dict containing the properly formatted request parameters
49
+ """
50
+ # Start with required parameters
51
+ complete_migration_request: Dict[str, Any] = {
52
+ 'ReplicationGroupId': request.replication_group_id,
53
+ }
54
+
55
+ # Add optional force parameter if provided
56
+ if request.force is not None:
57
+ complete_migration_request['Force'] = request.force
58
+
59
+ return complete_migration_request
60
+
61
+
62
+ @mcp.tool(name='complete-migration')
63
+ @handle_exceptions
64
+ async def complete_migration(request: CompleteMigrationRequest) -> Dict:
65
+ """Complete migration to an Amazon ElastiCache replication group.
66
+
67
+ This tool completes the migration of data from a Redis instance to an ElastiCache replication group.
68
+ It finalizes the data migration process and transitions the replication group to normal operation.
69
+
70
+ Args:
71
+ request: The CompleteMigrationRequest object containing:
72
+ - replication_group_id: The ID of the replication group to which data is being migrated
73
+ - force: (Optional) Forces the migration to stop without ensuring that data is in sync.
74
+ It is recommended to use this option only to abort the migration and not recommended
75
+ when application wants to continue migration to ElastiCache.
76
+
77
+ Returns:
78
+ Dict containing information about the migration completion result.
79
+ """
80
+ # Check if readonly mode is enabled
81
+ if Context.readonly_mode():
82
+ raise ValueError(
83
+ 'You have configured this tool in readonly mode. To make this change you will have to update your configuration.'
84
+ )
85
+
86
+ # Get ElastiCache client
87
+ elasticache_client = ElastiCacheConnectionManager.get_connection()
88
+
89
+ # Prepare request dictionary
90
+ complete_request = prepare_request_dict(request)
91
+
92
+ # Complete the migration
93
+ response = elasticache_client.complete_migration(**complete_request)
94
+ return response