mcp-server-kubernetes 1.6.2 → 2.1.0

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 (98) hide show
  1. package/README.md +46 -22
  2. package/dist/config/container-templates.d.ts +2 -2
  3. package/dist/index.d.ts +314 -736
  4. package/dist/index.js +93 -200
  5. package/dist/models/resource-models.d.ts +6 -6
  6. package/dist/tools/kubectl-apply.d.ts +46 -0
  7. package/dist/tools/kubectl-apply.js +110 -0
  8. package/dist/tools/kubectl-context.d.ts +49 -0
  9. package/dist/tools/kubectl-context.js +233 -0
  10. package/dist/tools/kubectl-create.d.ts +150 -0
  11. package/dist/tools/kubectl-create.js +321 -0
  12. package/dist/tools/kubectl-delete.d.ts +77 -0
  13. package/dist/tools/kubectl-delete.js +177 -0
  14. package/dist/tools/kubectl-describe.d.ts +47 -0
  15. package/dist/tools/kubectl-describe.js +96 -0
  16. package/dist/tools/kubectl-generic.d.ts +71 -0
  17. package/dist/tools/kubectl-generic.js +121 -0
  18. package/dist/tools/kubectl-get.d.ts +72 -0
  19. package/dist/tools/kubectl-get.js +251 -0
  20. package/dist/tools/kubectl-list.d.ts +61 -0
  21. package/dist/tools/kubectl-list.js +189 -0
  22. package/dist/tools/{get_logs.d.ts → kubectl-logs.d.ts} +35 -19
  23. package/dist/tools/kubectl-logs.js +312 -0
  24. package/dist/tools/kubectl-patch.d.ts +57 -0
  25. package/dist/tools/kubectl-patch.js +128 -0
  26. package/dist/tools/kubectl-rollout.d.ts +67 -0
  27. package/dist/tools/kubectl-rollout.js +115 -0
  28. package/dist/tools/{scale_deployment.d.ts → kubectl-scale.d.ts} +13 -3
  29. package/dist/tools/kubectl-scale.js +73 -0
  30. package/dist/utils/kubernetes-manager.d.ts +4 -0
  31. package/dist/utils/kubernetes-manager.js +21 -3
  32. package/package.json +1 -1
  33. package/dist/tools/create_configmap.d.ts +0 -33
  34. package/dist/tools/create_configmap.js +0 -66
  35. package/dist/tools/create_cronjob.d.ts +0 -47
  36. package/dist/tools/create_cronjob.js +0 -93
  37. package/dist/tools/create_deployment.d.ts +0 -135
  38. package/dist/tools/create_deployment.js +0 -162
  39. package/dist/tools/create_namespace.d.ts +0 -22
  40. package/dist/tools/create_namespace.js +0 -48
  41. package/dist/tools/create_pod.d.ts +0 -130
  42. package/dist/tools/create_pod.js +0 -153
  43. package/dist/tools/create_service.d.ts +0 -74
  44. package/dist/tools/create_service.js +0 -102
  45. package/dist/tools/delete_configmap.d.ts +0 -26
  46. package/dist/tools/delete_configmap.js +0 -49
  47. package/dist/tools/delete_cronjob.d.ts +0 -26
  48. package/dist/tools/delete_cronjob.js +0 -48
  49. package/dist/tools/delete_deployment.d.ts +0 -31
  50. package/dist/tools/delete_deployment.js +0 -47
  51. package/dist/tools/delete_namespace.d.ts +0 -27
  52. package/dist/tools/delete_namespace.js +0 -44
  53. package/dist/tools/delete_pod.d.ts +0 -31
  54. package/dist/tools/delete_pod.js +0 -45
  55. package/dist/tools/delete_service.d.ts +0 -32
  56. package/dist/tools/delete_service.js +0 -46
  57. package/dist/tools/describe_cronjob.d.ts +0 -27
  58. package/dist/tools/describe_cronjob.js +0 -83
  59. package/dist/tools/describe_deployment.d.ts +0 -26
  60. package/dist/tools/describe_deployment.js +0 -40
  61. package/dist/tools/describe_node.d.ts +0 -22
  62. package/dist/tools/describe_node.js +0 -84
  63. package/dist/tools/describe_pod.d.ts +0 -33
  64. package/dist/tools/describe_pod.js +0 -81
  65. package/dist/tools/describe_service.d.ts +0 -34
  66. package/dist/tools/describe_service.js +0 -85
  67. package/dist/tools/get_configmap.d.ts +0 -27
  68. package/dist/tools/get_configmap.js +0 -48
  69. package/dist/tools/get_current_context.d.ts +0 -23
  70. package/dist/tools/get_current_context.js +0 -55
  71. package/dist/tools/get_events.d.ts +0 -28
  72. package/dist/tools/get_events.js +0 -66
  73. package/dist/tools/get_job_logs.d.ts +0 -40
  74. package/dist/tools/get_job_logs.js +0 -104
  75. package/dist/tools/get_logs.js +0 -150
  76. package/dist/tools/list_contexts.d.ts +0 -23
  77. package/dist/tools/list_contexts.js +0 -39
  78. package/dist/tools/list_cronjobs.d.ts +0 -23
  79. package/dist/tools/list_cronjobs.js +0 -35
  80. package/dist/tools/list_deployments.d.ts +0 -23
  81. package/dist/tools/list_deployments.js +0 -30
  82. package/dist/tools/list_jobs.d.ts +0 -29
  83. package/dist/tools/list_jobs.js +0 -77
  84. package/dist/tools/list_nodes.d.ts +0 -15
  85. package/dist/tools/list_nodes.js +0 -21
  86. package/dist/tools/list_pods.d.ts +0 -23
  87. package/dist/tools/list_pods.js +0 -29
  88. package/dist/tools/list_services.d.ts +0 -23
  89. package/dist/tools/list_services.js +0 -31
  90. package/dist/tools/scale_deployment.js +0 -50
  91. package/dist/tools/set_current_context.d.ts +0 -23
  92. package/dist/tools/set_current_context.js +0 -35
  93. package/dist/tools/update_configmap.d.ts +0 -33
  94. package/dist/tools/update_configmap.js +0 -71
  95. package/dist/tools/update_deployment.d.ts +0 -113
  96. package/dist/tools/update_deployment.js +0 -155
  97. package/dist/tools/update_service.d.ts +0 -72
  98. package/dist/tools/update_service.js +0 -125
@@ -1,45 +0,0 @@
1
- export const deletePodSchema = {
2
- name: "delete_pod",
3
- description: "Delete a Kubernetes pod",
4
- inputSchema: {
5
- type: "object",
6
- properties: {
7
- name: { type: "string" },
8
- namespace: { type: "string" },
9
- ignoreNotFound: { type: "boolean", default: false },
10
- },
11
- required: ["name", "namespace"],
12
- },
13
- };
14
- export async function deletePod(k8sManager, input) {
15
- try {
16
- await k8sManager.getCoreApi().deleteNamespacedPod(input.name, input.namespace);
17
- return {
18
- content: [
19
- {
20
- type: "text",
21
- text: JSON.stringify({
22
- success: true,
23
- status: "deleted",
24
- }, null, 2),
25
- },
26
- ],
27
- };
28
- }
29
- catch (error) {
30
- if (input.ignoreNotFound && error.response?.statusCode === 404) {
31
- return {
32
- content: [
33
- {
34
- type: "text",
35
- text: JSON.stringify({
36
- success: true,
37
- status: "not_found",
38
- }, null, 2),
39
- },
40
- ],
41
- };
42
- }
43
- throw error;
44
- }
45
- }
@@ -1,32 +0,0 @@
1
- import { KubernetesManager } from "../types.js";
2
- export declare const deleteServiceSchema: {
3
- readonly name: "delete_service";
4
- readonly description: "Delete a Kubernetes service";
5
- readonly inputSchema: {
6
- readonly type: "object";
7
- readonly properties: {
8
- readonly name: {
9
- readonly type: "string";
10
- };
11
- readonly namespace: {
12
- readonly type: "string";
13
- readonly default: "default";
14
- };
15
- readonly ignoreNotFound: {
16
- readonly type: "boolean";
17
- readonly default: false;
18
- };
19
- };
20
- readonly required: readonly ["name"];
21
- };
22
- };
23
- export declare function deleteService(k8sManager: KubernetesManager, input: {
24
- name: string;
25
- namespace?: string;
26
- ignoreNotFound?: boolean;
27
- }): Promise<{
28
- content: {
29
- type: string;
30
- text: string;
31
- }[];
32
- }>;
@@ -1,46 +0,0 @@
1
- export const deleteServiceSchema = {
2
- name: "delete_service",
3
- description: "Delete a Kubernetes service",
4
- inputSchema: {
5
- type: "object",
6
- properties: {
7
- name: { type: "string" },
8
- namespace: { type: "string", default: "default" },
9
- ignoreNotFound: { type: "boolean", default: false },
10
- },
11
- required: ["name"],
12
- },
13
- };
14
- export async function deleteService(k8sManager, input) {
15
- const namespace = input.namespace || "default";
16
- try {
17
- await k8sManager.getCoreApi().deleteNamespacedService(input.name, namespace);
18
- return {
19
- content: [
20
- {
21
- type: "text",
22
- text: JSON.stringify({
23
- success: true,
24
- status: "deleted",
25
- }, null, 2),
26
- },
27
- ],
28
- };
29
- }
30
- catch (error) {
31
- if (input.ignoreNotFound && error.response?.statusCode === 404) {
32
- return {
33
- content: [
34
- {
35
- type: "text",
36
- text: JSON.stringify({
37
- success: true,
38
- status: "not_found",
39
- }, null, 2),
40
- },
41
- ],
42
- };
43
- }
44
- throw error;
45
- }
46
- }
@@ -1,27 +0,0 @@
1
- import { KubernetesManager } from "../types.js";
2
- export declare const describeCronJobSchema: {
3
- readonly name: "describe_cronjob";
4
- readonly description: "Get detailed information about a Kubernetes CronJob including recent job history";
5
- readonly inputSchema: {
6
- readonly type: "object";
7
- readonly properties: {
8
- readonly name: {
9
- readonly type: "string";
10
- };
11
- readonly namespace: {
12
- readonly type: "string";
13
- readonly default: "default";
14
- };
15
- };
16
- readonly required: readonly ["name", "namespace"];
17
- };
18
- };
19
- export declare function describeCronJob(k8sManager: KubernetesManager, input: {
20
- name: string;
21
- namespace: string;
22
- }): Promise<{
23
- content: {
24
- type: string;
25
- text: string;
26
- }[];
27
- }>;
@@ -1,83 +0,0 @@
1
- export const describeCronJobSchema = {
2
- name: "describe_cronjob",
3
- description: "Get detailed information about a Kubernetes CronJob including recent job history",
4
- inputSchema: {
5
- type: "object",
6
- properties: {
7
- name: { type: "string" },
8
- namespace: { type: "string", default: "default" },
9
- },
10
- required: ["name", "namespace"],
11
- },
12
- };
13
- export async function describeCronJob(k8sManager, input) {
14
- try {
15
- // Get the CronJob details
16
- const batchV1Api = k8sManager.getBatchApi();
17
- const cronJobResponse = await batchV1Api.readNamespacedCronJob(input.name, input.namespace);
18
- const cronJob = cronJobResponse.body;
19
- // Get recent Jobs associated with this CronJob
20
- const labelSelector = `app=${input.name},cronjob-name=${input.name}`;
21
- const jobsResponse = await batchV1Api.listNamespacedJob(input.namespace, undefined, // pretty
22
- undefined, // allowWatchBookmarks
23
- undefined, // _continue
24
- undefined, // fieldSelector
25
- labelSelector);
26
- // Sort jobs by creation time (newest first)
27
- const jobs = jobsResponse.body.items.sort((a, b) => {
28
- const aTime = a.metadata?.creationTimestamp
29
- ? new Date(a.metadata.creationTimestamp)
30
- : new Date(0);
31
- const bTime = b.metadata?.creationTimestamp
32
- ? new Date(b.metadata.creationTimestamp)
33
- : new Date(0);
34
- return bTime.getTime() - aTime.getTime();
35
- });
36
- // Limit to 5 most recent jobs
37
- const recentJobs = jobs.slice(0, 5).map((job) => ({
38
- name: job.metadata?.name || "",
39
- creationTime: job.metadata?.creationTimestamp || "",
40
- status: {
41
- active: job.status?.active || 0,
42
- succeeded: job.status?.succeeded || 0,
43
- failed: job.status?.failed || 0,
44
- completionTime: job.status?.completionTime || null,
45
- },
46
- }));
47
- // Format the response with CronJob details and recent jobs
48
- const cronJobDetails = {
49
- name: cronJob.metadata?.name || "",
50
- namespace: cronJob.metadata?.namespace || "",
51
- schedule: cronJob.spec?.schedule || "",
52
- suspend: cronJob.spec?.suspend || false,
53
- concurrencyPolicy: cronJob.spec?.concurrencyPolicy || "Allow",
54
- lastScheduleTime: cronJob.status?.lastScheduleTime || null,
55
- lastSuccessfulTime: cronJob.status?.lastSuccessfulTime || null,
56
- creationTimestamp: cronJob.metadata?.creationTimestamp || "",
57
- recentJobs: recentJobs,
58
- jobTemplate: {
59
- image: cronJob.spec?.jobTemplate?.spec?.template?.spec?.containers?.[0]
60
- ?.image || "",
61
- command: cronJob.spec?.jobTemplate?.spec?.template?.spec?.containers?.[0]
62
- ?.command || [],
63
- restartPolicy: cronJob.spec?.jobTemplate?.spec?.template?.spec?.restartPolicy || "",
64
- },
65
- };
66
- return {
67
- content: [
68
- {
69
- type: "text",
70
- text: JSON.stringify(cronJobDetails, null, 2),
71
- },
72
- ],
73
- };
74
- }
75
- catch (error) {
76
- console.error("Error describing CronJob:", {
77
- status: error.response?.statusCode,
78
- message: error.response?.body?.message || error.message,
79
- details: error.response?.body,
80
- });
81
- throw error;
82
- }
83
- }
@@ -1,26 +0,0 @@
1
- import { KubernetesManager } from "../types.js";
2
- export declare const describeDeploymentSchema: {
3
- readonly name: "describe_deployment";
4
- readonly description: "Get details about a Kubernetes deployment";
5
- readonly inputSchema: {
6
- readonly type: "object";
7
- readonly properties: {
8
- readonly name: {
9
- readonly type: "string";
10
- };
11
- readonly namespace: {
12
- readonly type: "string";
13
- };
14
- };
15
- readonly required: readonly ["name", "namespace"];
16
- };
17
- };
18
- export declare function describeDeployment(k8sManager: KubernetesManager, input: {
19
- name: string;
20
- namespace: string;
21
- }): Promise<{
22
- content: {
23
- type: string;
24
- text: string;
25
- }[];
26
- }>;
@@ -1,40 +0,0 @@
1
- export const describeDeploymentSchema = {
2
- name: "describe_deployment",
3
- description: "Get details about a Kubernetes deployment",
4
- inputSchema: {
5
- type: "object",
6
- properties: {
7
- name: { type: "string" },
8
- namespace: { type: "string" },
9
- },
10
- required: ["name", "namespace"],
11
- },
12
- };
13
- export async function describeDeployment(k8sManager, input) {
14
- const { body } = await k8sManager
15
- .getAppsApi()
16
- .readNamespacedDeployment(input.name, input.namespace)
17
- .catch((error) => {
18
- console.error("Deployment description error:", {
19
- status: error.response?.statusCode,
20
- message: error.response?.body?.message || error.message,
21
- details: error.response?.body,
22
- });
23
- throw error;
24
- });
25
- return {
26
- content: [
27
- {
28
- type: "text",
29
- text: JSON.stringify({
30
- name: body.metadata?.name,
31
- namespace: body.metadata?.namespace,
32
- replicas: body.spec?.replicas,
33
- availableReplicas: body.status?.availableReplicas,
34
- spec: body.spec,
35
- status: body.status,
36
- }, null, 2),
37
- },
38
- ],
39
- };
40
- }
@@ -1,22 +0,0 @@
1
- import { KubernetesManager } from "../types.js";
2
- export declare const describeNodeSchema: {
3
- readonly name: "describe_node";
4
- readonly description: "Describe a Kubernetes node (read details like status, capacity, conditions, etc.)";
5
- readonly inputSchema: {
6
- readonly type: "object";
7
- readonly properties: {
8
- readonly name: {
9
- readonly type: "string";
10
- };
11
- };
12
- readonly required: readonly ["name"];
13
- };
14
- };
15
- export declare function describeNode(k8sManager: KubernetesManager, input: {
16
- name: string;
17
- }): Promise<{
18
- content: {
19
- type: string;
20
- text: string;
21
- }[];
22
- }>;
@@ -1,84 +0,0 @@
1
- import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
2
- export const describeNodeSchema = {
3
- name: "describe_node",
4
- description: "Describe a Kubernetes node (read details like status, capacity, conditions, etc.)",
5
- inputSchema: {
6
- type: "object",
7
- properties: {
8
- name: { type: "string" },
9
- },
10
- required: ["name"],
11
- },
12
- };
13
- export async function describeNode(k8sManager, input) {
14
- try {
15
- const { body } = await k8sManager.getCoreApi().readNode(input.name);
16
- if (!body) {
17
- return {
18
- content: [
19
- {
20
- type: "text",
21
- text: JSON.stringify({
22
- error: "Node not found",
23
- status: "not_found",
24
- }, null, 2),
25
- },
26
- ],
27
- };
28
- }
29
- // Format the node details for better readability
30
- const nodeDetails = {
31
- kind: body.kind,
32
- metadata: {
33
- name: body.metadata?.name,
34
- creationTimestamp: body.metadata?.creationTimestamp,
35
- labels: body.metadata?.labels,
36
- annotations: body.metadata?.annotations,
37
- },
38
- spec: {
39
- podCIDR: body.spec?.podCIDR,
40
- podCIDRs: body.spec?.podCIDRs,
41
- taints: body.spec?.taints,
42
- unschedulable: body.spec?.unschedulable,
43
- },
44
- status: {
45
- capacity: body.status?.capacity,
46
- allocatable: body.status?.allocatable,
47
- conditions: body.status?.conditions,
48
- nodeInfo: {
49
- architecture: body.status?.nodeInfo?.architecture,
50
- containerRuntimeVersion: body.status?.nodeInfo?.containerRuntimeVersion,
51
- kernelVersion: body.status?.nodeInfo?.kernelVersion,
52
- kubeletVersion: body.status?.nodeInfo?.kubeletVersion,
53
- operatingSystem: body.status?.nodeInfo?.operatingSystem,
54
- osImage: body.status?.nodeInfo?.osImage,
55
- },
56
- addresses: body.status?.addresses,
57
- },
58
- };
59
- return {
60
- content: [
61
- {
62
- type: "text",
63
- text: JSON.stringify(nodeDetails, null, 2),
64
- },
65
- ],
66
- };
67
- }
68
- catch (error) {
69
- if (error.response?.statusCode === 404) {
70
- return {
71
- content: [
72
- {
73
- type: "text",
74
- text: JSON.stringify({
75
- error: "Node not found",
76
- status: "not_found",
77
- }, null, 2),
78
- },
79
- ],
80
- };
81
- }
82
- throw new McpError(ErrorCode.InternalError, `Failed to describe node: ${error.response?.body?.message || error.message}`);
83
- }
84
- }
@@ -1,33 +0,0 @@
1
- import { KubernetesManager } from "../types.js";
2
- export declare const describePodSchema: {
3
- readonly name: "describe_pod";
4
- readonly description: "Describe a Kubernetes pod (read details like status, containers, etc.)";
5
- readonly inputSchema: {
6
- readonly type: "object";
7
- readonly properties: {
8
- readonly name: {
9
- readonly type: "string";
10
- };
11
- readonly namespace: {
12
- readonly type: "string";
13
- };
14
- };
15
- readonly required: readonly ["name", "namespace"];
16
- };
17
- };
18
- export declare function describePod(k8sManager: KubernetesManager, input: {
19
- name: string;
20
- namespace: string;
21
- }): Promise<{
22
- content: {
23
- type: string;
24
- text: string;
25
- }[];
26
- isError: boolean;
27
- } | {
28
- content: {
29
- type: string;
30
- text: string;
31
- }[];
32
- isError?: undefined;
33
- }>;
@@ -1,81 +0,0 @@
1
- import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
2
- export const describePodSchema = {
3
- name: "describe_pod",
4
- description: "Describe a Kubernetes pod (read details like status, containers, etc.)",
5
- inputSchema: {
6
- type: "object",
7
- properties: {
8
- name: { type: "string" },
9
- namespace: { type: "string" },
10
- },
11
- required: ["name", "namespace"],
12
- },
13
- };
14
- export async function describePod(k8sManager, input) {
15
- try {
16
- const { body } = await k8sManager.getCoreApi().readNamespacedPod(input.name, input.namespace);
17
- if (!body) {
18
- return {
19
- content: [
20
- {
21
- type: "text",
22
- text: JSON.stringify({
23
- error: "Pod not found",
24
- status: "not_found",
25
- }, null, 2),
26
- },
27
- ],
28
- isError: true,
29
- };
30
- }
31
- // Format the pod details for better readability
32
- const podDetails = {
33
- kind: body.kind,
34
- metadata: {
35
- name: body.metadata?.name,
36
- namespace: body.metadata?.namespace,
37
- creationTimestamp: body.metadata?.creationTimestamp,
38
- labels: body.metadata?.labels,
39
- },
40
- spec: {
41
- containers: body.spec?.containers.map((container) => ({
42
- name: container.name,
43
- image: container.image,
44
- ports: container.ports,
45
- resources: container.resources,
46
- })),
47
- nodeName: body.spec?.nodeName,
48
- },
49
- status: {
50
- phase: body.status?.phase,
51
- conditions: body.status?.conditions,
52
- containerStatuses: body.status?.containerStatuses,
53
- },
54
- };
55
- return {
56
- content: [
57
- {
58
- type: "text",
59
- text: JSON.stringify(podDetails, null, 2),
60
- },
61
- ],
62
- };
63
- }
64
- catch (error) {
65
- if (error.response?.statusCode === 404) {
66
- return {
67
- content: [
68
- {
69
- type: "text",
70
- text: JSON.stringify({
71
- error: "Pod not found",
72
- status: "not_found",
73
- }, null, 2),
74
- },
75
- ],
76
- isError: true,
77
- };
78
- }
79
- throw new McpError(ErrorCode.InternalError, `Failed to describe pod: ${error.response?.body?.message || error.message}`);
80
- }
81
- }
@@ -1,34 +0,0 @@
1
- import { KubernetesManager } from "../types.js";
2
- export declare const describeServiceSchema: {
3
- readonly name: "describe_service";
4
- readonly description: "Describe a Kubernetes service (read details like status, ports, selectors, etc.)";
5
- readonly inputSchema: {
6
- readonly type: "object";
7
- readonly properties: {
8
- readonly name: {
9
- readonly type: "string";
10
- };
11
- readonly namespace: {
12
- readonly type: "string";
13
- readonly default: "default";
14
- };
15
- };
16
- readonly required: readonly ["name"];
17
- };
18
- };
19
- export declare function describeService(k8sManager: KubernetesManager, input: {
20
- name: string;
21
- namespace?: string;
22
- }): Promise<{
23
- content: {
24
- type: string;
25
- text: string;
26
- }[];
27
- isError: boolean;
28
- } | {
29
- content: {
30
- type: string;
31
- text: string;
32
- }[];
33
- isError?: undefined;
34
- }>;
@@ -1,85 +0,0 @@
1
- import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
2
- export const describeServiceSchema = {
3
- name: "describe_service",
4
- description: "Describe a Kubernetes service (read details like status, ports, selectors, etc.)",
5
- inputSchema: {
6
- type: "object",
7
- properties: {
8
- name: { type: "string" },
9
- namespace: { type: "string", default: "default" },
10
- },
11
- required: ["name"],
12
- },
13
- };
14
- export async function describeService(k8sManager, input) {
15
- const namespace = input.namespace || "default";
16
- try {
17
- const { body } = await k8sManager.getCoreApi().readNamespacedService(input.name, namespace);
18
- if (!body) {
19
- return {
20
- content: [
21
- {
22
- type: "text",
23
- text: JSON.stringify({
24
- error: "Service not found",
25
- status: "not_found",
26
- }, null, 2),
27
- },
28
- ],
29
- isError: true,
30
- };
31
- }
32
- // Format service details for better readability
33
- const serviceDetails = {
34
- kind: body.kind,
35
- metadata: {
36
- name: body.metadata?.name,
37
- namespace: body.metadata?.namespace,
38
- creationTimestamp: body.metadata?.creationTimestamp,
39
- labels: body.metadata?.labels,
40
- },
41
- spec: {
42
- type: body.spec?.type,
43
- selector: body.spec?.selector,
44
- ports: body.spec?.ports?.map((port) => ({
45
- name: port.name,
46
- protocol: port.protocol,
47
- port: port.port,
48
- targetPort: port.targetPort,
49
- nodePort: port.nodePort,
50
- })),
51
- clusterIP: body.spec?.clusterIP,
52
- externalIPs: body.spec?.externalIPs,
53
- loadBalancerIP: body.spec?.loadBalancerIP,
54
- },
55
- status: {
56
- loadBalancer: body.status?.loadBalancer,
57
- },
58
- };
59
- return {
60
- content: [
61
- {
62
- type: "text",
63
- text: JSON.stringify(serviceDetails, null, 2),
64
- },
65
- ],
66
- };
67
- }
68
- catch (error) {
69
- if (error.response?.statusCode === 404) {
70
- return {
71
- content: [
72
- {
73
- type: "text",
74
- text: JSON.stringify({
75
- error: "Service not found",
76
- status: "not_found",
77
- }, null, 2),
78
- },
79
- ],
80
- isError: true,
81
- };
82
- }
83
- throw new McpError(ErrorCode.InternalError, `Failed to describe service: ${error.response?.body?.message || error.message}`);
84
- }
85
- }
@@ -1,27 +0,0 @@
1
- import { KubernetesManager } from "../types.js";
2
- export declare const GetConfigMapSchema: {
3
- name: string;
4
- description: string;
5
- inputSchema: {
6
- type: string;
7
- properties: {
8
- name: {
9
- type: string;
10
- };
11
- namespace: {
12
- type: string;
13
- };
14
- };
15
- required: string[];
16
- };
17
- };
18
- export declare function getConfigMap(k8sManager: KubernetesManager, input: {
19
- name: string;
20
- namespace: string;
21
- }): Promise<{
22
- content: {
23
- success: boolean;
24
- message: string;
25
- data?: Record<string, string>;
26
- }[];
27
- }>;