awslabs.eks-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.
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.eks-mcp-server"""
13
+
14
+ __version__ = '0.1.0'
@@ -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"). 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
+ """AWS helper for the EKS MCP Server."""
13
+
14
+ import boto3
15
+ import os
16
+ from botocore.config import Config
17
+ from typing import Any, Optional
18
+
19
+
20
+ class AwsHelper:
21
+ """Helper class for AWS operations.
22
+
23
+ This class provides utility methods for interacting with AWS services,
24
+ including region and profile management and client creation.
25
+ """
26
+
27
+ @staticmethod
28
+ def get_aws_region() -> Optional[str]:
29
+ """Get the AWS region from the environment if set."""
30
+ return os.environ.get('AWS_REGION')
31
+
32
+ @staticmethod
33
+ def get_aws_profile() -> Optional[str]:
34
+ """Get the AWS profile from the environment if set."""
35
+ return os.environ.get('AWS_PROFILE')
36
+
37
+ @classmethod
38
+ def create_boto3_client(cls, service_name: str, region_name: Optional[str] = None) -> Any:
39
+ """Create a boto3 client with the appropriate profile and region.
40
+
41
+ The client is configured with a custom user agent suffix 'awslabs/mcp/eks-mcp-server/0.1.0'
42
+ to identify API calls made by the EKS MCP Server.
43
+
44
+ Args:
45
+ service_name: The AWS service name (e.g., 'ec2', 's3', 'eks')
46
+ region_name: Optional region name override
47
+
48
+ Returns:
49
+ A boto3 client for the specified service
50
+ """
51
+ # Get region from parameter or environment if set
52
+ region: Optional[str] = region_name if region_name is not None else cls.get_aws_region()
53
+
54
+ # Get profile from environment if set
55
+ profile = cls.get_aws_profile()
56
+
57
+ # Create config with user agent suffix
58
+ config = Config(user_agent_extra='awslabs/mcp/eks-mcp-server/0.1.0')
59
+
60
+ # Create session with profile if specified
61
+ if profile:
62
+ session = boto3.Session(profile_name=profile)
63
+ if region is not None:
64
+ return session.client(service_name, region_name=region, config=config)
65
+ else:
66
+ return session.client(service_name, config=config)
67
+ else:
68
+ if region is not None:
69
+ return boto3.client(service_name, region_name=region, config=config)
70
+ else:
71
+ return boto3.client(service_name, config=config)