awslabs.eks-mcp-server 0.1.1__py3-none-any.whl → 0.1.2__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/eks_mcp_server/aws_helper.py +3 -2
- awslabs/eks_mcp_server/eks_stack_handler.py +21 -1
- awslabs/eks_mcp_server/k8s_apis.py +12 -8
- awslabs/eks_mcp_server/k8s_handler.py +35 -0
- {awslabs_eks_mcp_server-0.1.1.dist-info → awslabs_eks_mcp_server-0.1.2.dist-info}/METADATA +29 -24
- {awslabs_eks_mcp_server-0.1.1.dist-info → awslabs_eks_mcp_server-0.1.2.dist-info}/RECORD +10 -10
- {awslabs_eks_mcp_server-0.1.1.dist-info → awslabs_eks_mcp_server-0.1.2.dist-info}/WHEEL +0 -0
- {awslabs_eks_mcp_server-0.1.1.dist-info → awslabs_eks_mcp_server-0.1.2.dist-info}/entry_points.txt +0 -0
- {awslabs_eks_mcp_server-0.1.1.dist-info → awslabs_eks_mcp_server-0.1.2.dist-info}/licenses/LICENSE +0 -0
- {awslabs_eks_mcp_server-0.1.1.dist-info → awslabs_eks_mcp_server-0.1.2.dist-info}/licenses/NOTICE +0 -0
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import boto3
|
|
15
15
|
import os
|
|
16
|
+
from awslabs.eks_mcp_server import __version__
|
|
16
17
|
from botocore.config import Config
|
|
17
18
|
from typing import Any, Optional
|
|
18
19
|
|
|
@@ -38,7 +39,7 @@ class AwsHelper:
|
|
|
38
39
|
def create_boto3_client(cls, service_name: str, region_name: Optional[str] = None) -> Any:
|
|
39
40
|
"""Create a boto3 client with the appropriate profile and region.
|
|
40
41
|
|
|
41
|
-
The client is configured with a custom user agent suffix 'awslabs/mcp/eks-mcp-server/
|
|
42
|
+
The client is configured with a custom user agent suffix 'awslabs/mcp/eks-mcp-server/{version}'
|
|
42
43
|
to identify API calls made by the EKS MCP Server.
|
|
43
44
|
|
|
44
45
|
Args:
|
|
@@ -55,7 +56,7 @@ class AwsHelper:
|
|
|
55
56
|
profile = cls.get_aws_profile()
|
|
56
57
|
|
|
57
58
|
# Create config with user agent suffix
|
|
58
|
-
config = Config(user_agent_extra='awslabs/mcp/eks-mcp-server/
|
|
59
|
+
config = Config(user_agent_extra=f'awslabs/mcp/eks-mcp-server/{__version__}')
|
|
59
60
|
|
|
60
61
|
# Create session with profile if specified
|
|
61
62
|
if profile:
|
|
@@ -36,7 +36,7 @@ from awslabs.eks_mcp_server.models import (
|
|
|
36
36
|
from mcp.server.fastmcp import Context
|
|
37
37
|
from mcp.types import EmbeddedResource, ImageContent, TextContent
|
|
38
38
|
from pydantic import Field
|
|
39
|
-
from typing import Dict, List, Optional, Tuple, Union, cast
|
|
39
|
+
from typing import Any, Dict, List, Optional, Tuple, Union, cast
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
class EksStackHandler:
|
|
@@ -345,6 +345,10 @@ class EksStackHandler:
|
|
|
345
345
|
if 'Parameters' in template_yaml and 'ClusterName' in template_yaml['Parameters']:
|
|
346
346
|
template_yaml['Parameters']['ClusterName']['Default'] = cluster_name
|
|
347
347
|
|
|
348
|
+
# Remove checkov metadata from the EKS cluster resource
|
|
349
|
+
if 'Resources' in template_yaml and 'EksCluster' in template_yaml['Resources']:
|
|
350
|
+
self._remove_checkov_metadata(template_yaml['Resources']['EksCluster'])
|
|
351
|
+
|
|
348
352
|
# Convert back to YAML
|
|
349
353
|
modified_template = yaml.dump(template_yaml, default_flow_style=False)
|
|
350
354
|
|
|
@@ -589,6 +593,22 @@ class EksStackHandler:
|
|
|
589
593
|
outputs={},
|
|
590
594
|
)
|
|
591
595
|
|
|
596
|
+
def _remove_checkov_metadata(self, resource: Dict[str, Any]) -> None:
|
|
597
|
+
"""Remove checkov metadata from a resource and clean up empty Metadata sections.
|
|
598
|
+
|
|
599
|
+
Args:
|
|
600
|
+
resource: The resource dictionary to process
|
|
601
|
+
"""
|
|
602
|
+
if 'Metadata' in resource:
|
|
603
|
+
# Check if there's checkov metadata
|
|
604
|
+
if 'checkov' in resource['Metadata']:
|
|
605
|
+
# Remove only the checkov metadata
|
|
606
|
+
del resource['Metadata']['checkov']
|
|
607
|
+
|
|
608
|
+
# If Metadata is now empty, remove it entirely
|
|
609
|
+
if not resource['Metadata']:
|
|
610
|
+
del resource['Metadata']
|
|
611
|
+
|
|
592
612
|
async def _delete_stack(
|
|
593
613
|
self, ctx: Context, stack_name: str, cluster_name: str
|
|
594
614
|
) -> DeleteStackResponse:
|
|
@@ -407,22 +407,26 @@ class K8sApis:
|
|
|
407
407
|
Pod logs as a string
|
|
408
408
|
"""
|
|
409
409
|
try:
|
|
410
|
-
|
|
411
|
-
|
|
410
|
+
from kubernetes import client
|
|
411
|
+
|
|
412
|
+
# Create CoreV1Api client
|
|
413
|
+
core_v1_api = client.CoreV1Api(self.api_client)
|
|
412
414
|
|
|
413
|
-
# Prepare parameters for the
|
|
415
|
+
# Prepare parameters for the read_namespaced_pod_log method
|
|
414
416
|
params = {}
|
|
415
417
|
if container_name:
|
|
416
418
|
params['container'] = container_name
|
|
417
419
|
if since_seconds:
|
|
418
|
-
params['
|
|
420
|
+
params['since_seconds'] = since_seconds
|
|
419
421
|
if tail_lines:
|
|
420
|
-
params['
|
|
422
|
+
params['tail_lines'] = tail_lines
|
|
421
423
|
if limit_bytes:
|
|
422
|
-
params['
|
|
424
|
+
params['limit_bytes'] = limit_bytes
|
|
423
425
|
|
|
424
|
-
# Call the
|
|
425
|
-
logs_response =
|
|
426
|
+
# Call the read_namespaced_pod_log method
|
|
427
|
+
logs_response = core_v1_api.read_namespaced_pod_log(
|
|
428
|
+
name=pod_name, namespace=namespace, **params
|
|
429
|
+
)
|
|
426
430
|
|
|
427
431
|
return logs_response
|
|
428
432
|
|
|
@@ -780,6 +780,37 @@ class K8sHandler:
|
|
|
780
780
|
output_file_path='',
|
|
781
781
|
)
|
|
782
782
|
|
|
783
|
+
def _remove_checkov_skip_annotations(self, content: str) -> str:
|
|
784
|
+
"""Remove checkov skip annotations from YAML content.
|
|
785
|
+
|
|
786
|
+
Args:
|
|
787
|
+
content: YAML content as string
|
|
788
|
+
|
|
789
|
+
Returns:
|
|
790
|
+
YAML content with checkov skip annotations removed
|
|
791
|
+
"""
|
|
792
|
+
# Use yaml to parse and modify the content
|
|
793
|
+
yaml_content = yaml.safe_load(content)
|
|
794
|
+
if (
|
|
795
|
+
yaml_content
|
|
796
|
+
and 'metadata' in yaml_content
|
|
797
|
+
and 'annotations' in yaml_content['metadata']
|
|
798
|
+
):
|
|
799
|
+
# Remove all checkov skip annotations
|
|
800
|
+
annotations = yaml_content['metadata']['annotations']
|
|
801
|
+
checkov_keys = [key for key in annotations.keys() if key.startswith('checkov.io/skip')]
|
|
802
|
+
for key in checkov_keys:
|
|
803
|
+
del annotations[key]
|
|
804
|
+
|
|
805
|
+
# If annotations is now empty, remove it
|
|
806
|
+
if not annotations:
|
|
807
|
+
del yaml_content['metadata']['annotations']
|
|
808
|
+
|
|
809
|
+
# Convert back to YAML string
|
|
810
|
+
content = yaml.dump(yaml_content, default_flow_style=False)
|
|
811
|
+
|
|
812
|
+
return content
|
|
813
|
+
|
|
783
814
|
def _load_yaml_template(self, template_files: list, values: Dict[str, Any]) -> str:
|
|
784
815
|
"""Load and process Kubernetes template files.
|
|
785
816
|
|
|
@@ -804,6 +835,10 @@ class K8sHandler:
|
|
|
804
835
|
for key, value in values.items():
|
|
805
836
|
content = content.replace(key, value)
|
|
806
837
|
|
|
838
|
+
# Remove checkov skip annotations if present
|
|
839
|
+
if template_file == 'deployment.yaml':
|
|
840
|
+
content = self._remove_checkov_skip_annotations(content)
|
|
841
|
+
|
|
807
842
|
template_contents.append(content)
|
|
808
843
|
|
|
809
844
|
# Combine templates into a single YAML document with separator
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: awslabs.eks-mcp-server
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: An AWS Labs Model Context Protocol (MCP) server for EKS
|
|
5
5
|
Project-URL: homepage, https://awslabs.github.io/mcp/
|
|
6
6
|
Project-URL: docs, https://awslabs.github.io/mcp/servers/eks-mcp-server/
|
|
@@ -89,30 +89,35 @@ For read operations, the following permissions are required:
|
|
|
89
89
|
|
|
90
90
|
### Write Operations Policy
|
|
91
91
|
|
|
92
|
-
For write operations, the following
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
],
|
|
106
|
-
"Resource": "*",
|
|
107
|
-
"Condition": {
|
|
108
|
-
"StringEquals": {
|
|
109
|
-
"aws:RequestTag/CreatedBy": "EksMcpServer"
|
|
110
|
-
}
|
|
92
|
+
For write operations, we recommend the following IAM policies to ensure successful deployment of EKS clusters using the CloudFormation template in `/awslabs/eks_mcp_server/templates/eks-templates/eks-with-vpc.yaml`:
|
|
93
|
+
- [**IAMFullAccess**](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/IAMFullAccess.html): Enables creation and management of IAM roles and policies required for cluster operation
|
|
94
|
+
- [**AmazonVPCFullAccess**](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonVPCFullAccess.html): Allows creation and configuration of VPC resources including subnets, route tables, internet gateways, and NAT gateways
|
|
95
|
+
- [**AWSCloudFormationFullAccess**](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AWSCloudFormationFullAccess.html): Provides permissions to create, update, and delete CloudFormation stacks that orchestrate the deployment
|
|
96
|
+
- **EKS Full Access (provided below)**: Required for creating and managing EKS clusters, including control plane configuration, node groups, and add-ons
|
|
97
|
+
```
|
|
98
|
+
{
|
|
99
|
+
"Version": "2012-10-17",
|
|
100
|
+
"Statement": [
|
|
101
|
+
{
|
|
102
|
+
"Effect": "Allow",
|
|
103
|
+
"Action": "eks:*",
|
|
104
|
+
"Resource": "*"
|
|
111
105
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
**Important Security Note**: Users should exercise caution when `--allow-write` and `--allow-sensitive-data-access` modes are enabled with these broad permissions, as this combination grants significant privileges to the MCP server. Only enable these flags when necessary and in trusted environments. For production use, consider creating more restrictive custom policies.
|
|
112
|
+
|
|
113
|
+
### Kubernetes API Access Requirements
|
|
114
|
+
|
|
115
|
+
All Kubernetes API operations will only work when one of the following conditions is met:
|
|
116
|
+
|
|
117
|
+
1. The user's principal (IAM role/user) actually created the EKS cluster being accessed
|
|
118
|
+
2. An EKS Access Entry has been configured for the user's principal
|
|
119
|
+
|
|
120
|
+
If you encounter authorization errors when using Kubernetes API operations, verify that an access entry has been properly configured for your principal.
|
|
116
121
|
|
|
117
122
|
## Quickstart
|
|
118
123
|
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
awslabs/__init__.py,sha256=47wJeKcStxEJwX7SVVV2pnAWYR8FxcaYoT3YTmZ5Plg,674
|
|
2
2
|
awslabs/eks_mcp_server/__init__.py,sha256=ClxsTrvClkBctqdiivFNI1oYee4M8mHm0E2jlQxmw_Y,611
|
|
3
|
-
awslabs/eks_mcp_server/aws_helper.py,sha256=
|
|
3
|
+
awslabs/eks_mcp_server/aws_helper.py,sha256=eN8T-khiUVBHlab4PBcuLSErW7Q_dqG6J8Mtm9ukyEw,2793
|
|
4
4
|
awslabs/eks_mcp_server/cloudwatch_handler.py,sha256=ZwWsym2zn4a9ounIXVrB4Xsw9I4TbzkHk5a9eotO-so,28874
|
|
5
5
|
awslabs/eks_mcp_server/consts.py,sha256=tYxCxyDQy_Y1W__U6BeyBsB0Rcz3cTj-meWdJtIzPeE,1323
|
|
6
6
|
awslabs/eks_mcp_server/eks_kb_handler.py,sha256=h5xEo_-X_lMt7ifZmfJm9PiEOkR_85j5BsS5ivskv88,3489
|
|
7
|
-
awslabs/eks_mcp_server/eks_stack_handler.py,sha256=
|
|
7
|
+
awslabs/eks_mcp_server/eks_stack_handler.py,sha256=CeQuUNtGOT_cMAIOYjzCAZs7ZtLG7VKAS4agC-N2ZkQ,29237
|
|
8
8
|
awslabs/eks_mcp_server/iam_handler.py,sha256=hRF_YUwjHP-QAQkJOoutjsvTJungBCY0ouMAznXdPug,14266
|
|
9
|
-
awslabs/eks_mcp_server/k8s_apis.py,sha256=
|
|
9
|
+
awslabs/eks_mcp_server/k8s_apis.py,sha256=lo13Uc-1XaY4RuHhsezeU1WZg6jHcb31OS9ZYPHkQec,20203
|
|
10
10
|
awslabs/eks_mcp_server/k8s_client_cache.py,sha256=KFlDt6_tq1PjhGhOy1Q4EOMyK0NkPu6xKzZf4ciGFvI,5814
|
|
11
|
-
awslabs/eks_mcp_server/k8s_handler.py,sha256=
|
|
11
|
+
awslabs/eks_mcp_server/k8s_handler.py,sha256=PJUrLdqf8yWdpik6XQZjWwl-SSuhCMT3ktATd8-G-dg,48930
|
|
12
12
|
awslabs/eks_mcp_server/logging_helper.py,sha256=p_7SbWclTIVQNcQvPf5jP7OSFEJNOFbSq9b1U4v6Cxw,1797
|
|
13
13
|
awslabs/eks_mcp_server/models.py,sha256=YlTuQeweBlqt0aBPfK27_OFWhq4XFD023BBjbTPJWnY,11575
|
|
14
14
|
awslabs/eks_mcp_server/server.py,sha256=PDoyTTkhYs_Saqp4uo1M-4jVT6H7ZWvw7MTLIIl7P_E,6247
|
|
15
15
|
awslabs/eks_mcp_server/templates/eks-templates/eks-with-vpc.yaml,sha256=_Lxk2MEXNA7N0-kvXckxwBamDEagjGvC6-Z5uxhVO5s,10774
|
|
16
16
|
awslabs/eks_mcp_server/templates/k8s-templates/deployment.yaml,sha256=J2efYFISlT3sTvf8_BJV3p0_m51cltqiRhXdBXb9YJs,2343
|
|
17
17
|
awslabs/eks_mcp_server/templates/k8s-templates/service.yaml,sha256=DA0Db_5yjUZmnnYy5Bljcv3hj7D6YvFFWFRB6GiIstY,414
|
|
18
|
-
awslabs_eks_mcp_server-0.1.
|
|
19
|
-
awslabs_eks_mcp_server-0.1.
|
|
20
|
-
awslabs_eks_mcp_server-0.1.
|
|
21
|
-
awslabs_eks_mcp_server-0.1.
|
|
22
|
-
awslabs_eks_mcp_server-0.1.
|
|
23
|
-
awslabs_eks_mcp_server-0.1.
|
|
18
|
+
awslabs_eks_mcp_server-0.1.2.dist-info/METADATA,sha256=ka7LZj3o5jeY6Nsdtllq4PkbBNTnd4bTFjzCQVLHZCc,25687
|
|
19
|
+
awslabs_eks_mcp_server-0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
20
|
+
awslabs_eks_mcp_server-0.1.2.dist-info/entry_points.txt,sha256=VydotfOJYck8o4TPsaF6Pjmc8Bp_doacYXSE_71qH4c,78
|
|
21
|
+
awslabs_eks_mcp_server-0.1.2.dist-info/licenses/LICENSE,sha256=CeipvOyAZxBGUsFoaFqwkx54aPnIKEtm9a5u2uXxEws,10142
|
|
22
|
+
awslabs_eks_mcp_server-0.1.2.dist-info/licenses/NOTICE,sha256=gnCtD34qTDnb2Lykm9kNFYkqZIvqJHGuq1ZJBkl6EgE,90
|
|
23
|
+
awslabs_eks_mcp_server-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
{awslabs_eks_mcp_server-0.1.1.dist-info → awslabs_eks_mcp_server-0.1.2.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{awslabs_eks_mcp_server-0.1.1.dist-info → awslabs_eks_mcp_server-0.1.2.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{awslabs_eks_mcp_server-0.1.1.dist-info → awslabs_eks_mcp_server-0.1.2.dist-info}/licenses/NOTICE
RENAMED
|
File without changes
|