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.
@@ -0,0 +1,33 @@
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
+ """Constants for the EKS MCP Server."""
13
+
14
+ # EKS Stack Management Operations
15
+ GENERATE_OPERATION = 'generate'
16
+ DEPLOY_OPERATION = 'deploy'
17
+ DESCRIBE_OPERATION = 'describe'
18
+ DELETE_OPERATION = 'delete'
19
+
20
+ # AWS CloudFormation
21
+ CFN_STACK_NAME_TEMPLATE = 'eks-{cluster_name}-stack'
22
+ CFN_CAPABILITY_IAM = 'CAPABILITY_IAM'
23
+ CFN_ON_FAILURE_DELETE = 'DELETE'
24
+ CFN_CREATED_BY_TAG = 'EksMcpServer'
25
+ CFN_STACK_TAG_KEY = 'CreatedBy'
26
+ CFN_STACK_TAG_VALUE = 'EksMcpServer'
27
+
28
+ # Error message templates
29
+ STACK_NOT_OWNED_ERROR_TEMPLATE = (
30
+ 'Stack {stack_name} exists but was not created by {tool_name}. '
31
+ 'For safety reasons, this tool will only {operation} stacks that were created by itself. '
32
+ 'To manage this stack, please use the AWS Console, CLI, or the tool that created it.'
33
+ )
@@ -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"). 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
+ """Knowledge Base Retrival handler for the EKS MCP Server."""
13
+
14
+ import requests
15
+ from loguru import logger
16
+ from pydantic import Field
17
+ from requests_auth_aws_sigv4 import AWSSigV4
18
+
19
+
20
+ # API endpoint for the EKS Knowledge Base
21
+ API_ENDPOINT = 'https://mcpserver.eks-beta.us-west-2.api.aws/'
22
+ AWS_REGION = 'us-west-2'
23
+ AWS_SERVICE = 'eks-mcpserver'
24
+
25
+
26
+ class EKSKnowledgeBaseHandler:
27
+ """Handler for retriving troubleshooting guide from the EKS Knowledge Base.
28
+
29
+ This class provides tools for fetching instructions to troubleshoot issues from the EKS Hosted MCP service.
30
+ """
31
+
32
+ def __init__(self, mcp):
33
+ """Initialize the EKS Knowledge Base handler.
34
+
35
+ Args:
36
+ mcp: The MCP server instance
37
+ """
38
+ self.mcp = mcp
39
+
40
+ # Register tools
41
+ self.mcp.tool(name='search_eks_troubleshoot_guide')(self.search_eks_troubleshoot_guide)
42
+
43
+ async def search_eks_troubleshoot_guide(
44
+ self,
45
+ query: str = Field(
46
+ ...,
47
+ description='Your specific question or issue description related to EKS troubleshooting',
48
+ ),
49
+ ) -> str:
50
+ """Search the EKS Troubleshoot Guide for troubleshooting information.
51
+
52
+ This tool provides troubleshooting guidance for Amazon EKS issues by querying
53
+ a specialized knowledge base of EKS troubleshooting information. It helps identify
54
+ common problems and provides step-by-step solutions for resolving cluster creation issues,
55
+ node group management problems, workload deployment issues, and diagnosing error messages.
56
+
57
+ ## Requirements
58
+ - Internet connectivity to access the EKS Knowledge Base API
59
+ - Valid AWS credentials with permissions to access the EKS Knowledge Base
60
+ - IAM permission: eks-mcpserver:QueryKnowledgeBase
61
+
62
+ ## Response Information
63
+ The response includes bullet-point instructions for troubleshooting EKS issues.
64
+
65
+ ## Usage Tips
66
+ - Provide specific error messages or symptoms in your query
67
+ - Try running this tool 2-3 times with different phrasings or related queries to increase the chance of retrieving the most relevant guidance
68
+
69
+ Args:
70
+ query: Your specific question or issue description related to EKS troubleshooting. Question has to be less than 300 characters and can only
71
+ contain letters, numbers, commas, periods, question marks, colons, and spaces.
72
+
73
+ Returns:
74
+ str: Detailed troubleshooting guidance for the EKS issue
75
+ """
76
+ try:
77
+ response = requests.post(
78
+ API_ENDPOINT,
79
+ json={'question': query},
80
+ auth=AWSSigV4(AWS_SERVICE, region=AWS_REGION),
81
+ )
82
+ response.raise_for_status()
83
+ return response.text
84
+ except Exception as e:
85
+ logger.error(f'Error in search_eks_troubleshoot_guide: {str(e)}')
86
+ return f'Error: {str(e)}'