mcp-server-kubernetes 1.1.0 → 1.2.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.
- package/dist/index.js +12 -1
- package/dist/models/response-schemas.d.ts +44 -0
- package/dist/models/response-schemas.js +9 -0
- package/dist/tools/delete_cronjob.d.ts +26 -0
- package/dist/tools/delete_cronjob.js +48 -0
- package/dist/tools/delete_namespace.d.ts +27 -0
- package/dist/tools/delete_namespace.js +44 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import { explainResource, explainResourceSchema, listApiResources, listApiResour
|
|
|
14
14
|
import { createNamespace, createNamespaceSchema, } from "./tools/create_namespace.js";
|
|
15
15
|
import { createPod, createPodSchema } from "./tools/create_pod.js";
|
|
16
16
|
import { createCronJob, createCronJobSchema } from "./tools/create_cronjob.js";
|
|
17
|
+
import { DeleteCronJob, DeleteCronJobSchema } from "./tools/delete_cronjob.js";
|
|
17
18
|
import { deletePod, deletePodSchema } from "./tools/delete_pod.js";
|
|
18
19
|
import { describePod, describePodSchema } from "./tools/describe_pod.js";
|
|
19
20
|
import { getLogs, getLogsSchema } from "./tools/get_logs.js";
|
|
@@ -24,10 +25,11 @@ import { KubernetesManager } from "./types.js";
|
|
|
24
25
|
import { serverConfig } from "./config/server-config.js";
|
|
25
26
|
import { createDeploymentSchema } from "./config/deployment-config.js";
|
|
26
27
|
import { listNamespacesSchema } from "./config/namespace-config.js";
|
|
28
|
+
import { deleteNamespace, deleteNamespaceSchema } from "./tools/delete_namespace.js";
|
|
27
29
|
import { cleanupSchema } from "./config/cleanup-config.js";
|
|
28
30
|
import { startSSEServer } from "./utils/sse.js";
|
|
29
31
|
import { startPortForward, PortForwardSchema, stopPortForward, StopPortForwardSchema, } from "./tools/port_forward.js";
|
|
30
|
-
import { deleteDeployment } from "./tools/delete_deployment.js";
|
|
32
|
+
import { deleteDeployment, deleteDeploymentSchema } from "./tools/delete_deployment.js";
|
|
31
33
|
import { createDeployment } from "./tools/create_deployment.js";
|
|
32
34
|
import { scaleDeployment, scaleDeploymentSchema } from "./tools/scale_deployment.js";
|
|
33
35
|
import { describeDeployment, describeDeploymentSchema, } from "./tools/describe_deployment.js";
|
|
@@ -46,6 +48,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
46
48
|
createPodSchema,
|
|
47
49
|
createCronJobSchema,
|
|
48
50
|
deletePodSchema,
|
|
51
|
+
deleteDeploymentSchema,
|
|
52
|
+
deleteNamespaceSchema,
|
|
49
53
|
describeCronJobSchema,
|
|
50
54
|
describePodSchema,
|
|
51
55
|
describeDeploymentSchema,
|
|
@@ -67,6 +71,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
67
71
|
PortForwardSchema,
|
|
68
72
|
StopPortForwardSchema,
|
|
69
73
|
scaleDeploymentSchema,
|
|
74
|
+
DeleteCronJobSchema,
|
|
70
75
|
],
|
|
71
76
|
};
|
|
72
77
|
});
|
|
@@ -96,6 +101,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
96
101
|
case "create_cronjob": {
|
|
97
102
|
return await createCronJob(k8sManager, input);
|
|
98
103
|
}
|
|
104
|
+
case "delete_cronjob": {
|
|
105
|
+
return await DeleteCronJob(k8sManager, input);
|
|
106
|
+
}
|
|
99
107
|
case "delete_pod": {
|
|
100
108
|
return await deletePod(k8sManager, input);
|
|
101
109
|
}
|
|
@@ -169,6 +177,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
169
177
|
case "stop_port_forward": {
|
|
170
178
|
return await stopPortForward(k8sManager, input);
|
|
171
179
|
}
|
|
180
|
+
case "delete_namespace": {
|
|
181
|
+
return await deleteNamespace(k8sManager, input);
|
|
182
|
+
}
|
|
172
183
|
case "delete_deployment": {
|
|
173
184
|
return await deleteDeployment(k8sManager, input);
|
|
174
185
|
}
|
|
@@ -21,6 +21,28 @@ export declare const CreateNamespaceResponseSchema: z.ZodObject<{
|
|
|
21
21
|
text: string;
|
|
22
22
|
}[];
|
|
23
23
|
}>;
|
|
24
|
+
export declare const DeleteNamespaceResponseSchema: z.ZodObject<{
|
|
25
|
+
content: z.ZodArray<z.ZodObject<{
|
|
26
|
+
type: z.ZodLiteral<"text">;
|
|
27
|
+
text: z.ZodString;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
type: "text";
|
|
30
|
+
text: string;
|
|
31
|
+
}, {
|
|
32
|
+
type: "text";
|
|
33
|
+
text: string;
|
|
34
|
+
}>, "many">;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
content: {
|
|
37
|
+
type: "text";
|
|
38
|
+
text: string;
|
|
39
|
+
}[];
|
|
40
|
+
}, {
|
|
41
|
+
content: {
|
|
42
|
+
type: "text";
|
|
43
|
+
text: string;
|
|
44
|
+
}[];
|
|
45
|
+
}>;
|
|
24
46
|
export declare const CreatePodResponseSchema: z.ZodObject<{
|
|
25
47
|
content: z.ZodArray<z.ZodObject<{
|
|
26
48
|
type: z.ZodLiteral<"text">;
|
|
@@ -439,3 +461,25 @@ export declare const ScaleDeploymentResponseSchema: z.ZodObject<{
|
|
|
439
461
|
success: boolean;
|
|
440
462
|
}[];
|
|
441
463
|
}>;
|
|
464
|
+
export declare const DeleteCronJobResponseSchema: z.ZodObject<{
|
|
465
|
+
content: z.ZodArray<z.ZodObject<{
|
|
466
|
+
success: z.ZodBoolean;
|
|
467
|
+
message: z.ZodString;
|
|
468
|
+
}, "strip", z.ZodTypeAny, {
|
|
469
|
+
message: string;
|
|
470
|
+
success: boolean;
|
|
471
|
+
}, {
|
|
472
|
+
message: string;
|
|
473
|
+
success: boolean;
|
|
474
|
+
}>, "many">;
|
|
475
|
+
}, "strip", z.ZodTypeAny, {
|
|
476
|
+
content: {
|
|
477
|
+
message: string;
|
|
478
|
+
success: boolean;
|
|
479
|
+
}[];
|
|
480
|
+
}, {
|
|
481
|
+
content: {
|
|
482
|
+
message: string;
|
|
483
|
+
success: boolean;
|
|
484
|
+
}[];
|
|
485
|
+
}>;
|
|
@@ -7,6 +7,9 @@ const ToolResponseContent = z.object({
|
|
|
7
7
|
export const CreateNamespaceResponseSchema = z.object({
|
|
8
8
|
content: z.array(ToolResponseContent),
|
|
9
9
|
});
|
|
10
|
+
export const DeleteNamespaceResponseSchema = z.object({
|
|
11
|
+
content: z.array(ToolResponseContent),
|
|
12
|
+
});
|
|
10
13
|
export const CreatePodResponseSchema = z.object({
|
|
11
14
|
content: z.array(ToolResponseContent),
|
|
12
15
|
});
|
|
@@ -70,3 +73,9 @@ export const ScaleDeploymentResponseSchema = z.object({
|
|
|
70
73
|
message: z.string(),
|
|
71
74
|
})),
|
|
72
75
|
});
|
|
76
|
+
export const DeleteCronJobResponseSchema = z.object({
|
|
77
|
+
content: z.array(z.object({
|
|
78
|
+
success: z.boolean(),
|
|
79
|
+
message: z.string(),
|
|
80
|
+
})),
|
|
81
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { KubernetesManager } from "../types.js";
|
|
2
|
+
export declare const DeleteCronJobSchema: {
|
|
3
|
+
readonly name: "delete_cronjob";
|
|
4
|
+
readonly description: "Delete a Kubernetes CronJob";
|
|
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 DeleteCronJob(k8sManager: KubernetesManager, input: {
|
|
19
|
+
name: string;
|
|
20
|
+
namespace: string;
|
|
21
|
+
}): Promise<{
|
|
22
|
+
content: {
|
|
23
|
+
success: boolean;
|
|
24
|
+
message: string;
|
|
25
|
+
}[];
|
|
26
|
+
}>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const DeleteCronJobSchema = {
|
|
2
|
+
name: "delete_cronjob",
|
|
3
|
+
description: "Delete a Kubernetes CronJob",
|
|
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 DeleteCronJob(k8sManager, input) {
|
|
14
|
+
try {
|
|
15
|
+
const response = await k8sManager.getBatchApi().deleteNamespacedCronJob(input.name, input.namespace);
|
|
16
|
+
if (response.response?.statusCode !== undefined && (response.response.statusCode === 200 || response.response.statusCode === 202)) {
|
|
17
|
+
return {
|
|
18
|
+
content: [
|
|
19
|
+
{
|
|
20
|
+
success: true,
|
|
21
|
+
message: `Deleted cronjob ${input.name} in namespace ${input.namespace}.` +
|
|
22
|
+
(response.body?.details ? ` Details: ${response.body.details}` : "")
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return {
|
|
29
|
+
content: [
|
|
30
|
+
{
|
|
31
|
+
success: false,
|
|
32
|
+
message: `Failed to delete cronjob ${input.name} in namespace ${input.namespace}.` + (response.body?.details ? ` Details: ${response.body.details}` : "")
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
return {
|
|
40
|
+
content: [
|
|
41
|
+
{
|
|
42
|
+
success: false,
|
|
43
|
+
message: `Failed to delete cronjob: ${error.message}`
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { KubernetesManager } from "../types.js";
|
|
2
|
+
export declare const deleteNamespaceSchema: {
|
|
3
|
+
readonly name: "delete_namespace";
|
|
4
|
+
readonly description: "Delete a Kubernetes namespace";
|
|
5
|
+
readonly inputSchema: {
|
|
6
|
+
readonly type: "object";
|
|
7
|
+
readonly properties: {
|
|
8
|
+
readonly name: {
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
};
|
|
11
|
+
readonly ignoreNotFound: {
|
|
12
|
+
readonly type: "boolean";
|
|
13
|
+
readonly default: false;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
readonly required: readonly ["name"];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare function deleteNamespace(k8sManager: KubernetesManager, input: {
|
|
20
|
+
name: string;
|
|
21
|
+
ignoreNotFound?: boolean;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
content: {
|
|
24
|
+
type: string;
|
|
25
|
+
text: string;
|
|
26
|
+
}[];
|
|
27
|
+
}>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const deleteNamespaceSchema = {
|
|
2
|
+
name: "delete_namespace",
|
|
3
|
+
description: "Delete a Kubernetes namespace",
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {
|
|
7
|
+
name: { type: "string" },
|
|
8
|
+
ignoreNotFound: { type: "boolean", default: false },
|
|
9
|
+
},
|
|
10
|
+
required: ["name"],
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
export async function deleteNamespace(k8sManager, input) {
|
|
14
|
+
try {
|
|
15
|
+
await k8sManager.getCoreApi().deleteNamespace(input.name);
|
|
16
|
+
return {
|
|
17
|
+
content: [
|
|
18
|
+
{
|
|
19
|
+
type: "text",
|
|
20
|
+
text: JSON.stringify({
|
|
21
|
+
success: true,
|
|
22
|
+
status: "deleted",
|
|
23
|
+
}, null, 2),
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (input.ignoreNotFound && error.response?.statusCode === 404) {
|
|
30
|
+
return {
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
type: "text",
|
|
34
|
+
text: JSON.stringify({
|
|
35
|
+
success: true,
|
|
36
|
+
status: "not_found",
|
|
37
|
+
}, null, 2),
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-server-kubernetes",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "MCP server for interacting with Kubernetes clusters via kubectl",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@kubernetes/client-node": "0.20.0",
|
|
39
39
|
"@modelcontextprotocol/sdk": "1.7.0",
|
|
40
|
+
"express": "4.21.2",
|
|
40
41
|
"js-yaml": "4.1.0",
|
|
41
42
|
"yaml": "2.7.0",
|
|
42
|
-
"zod": "3.23.8"
|
|
43
|
-
"express": "4.21.2"
|
|
43
|
+
"zod": "3.23.8"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/express": "5.0.1",
|