mcp-server-kubernetes 1.2.0 → 1.3.1

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 CHANGED
@@ -33,6 +33,7 @@ import { deleteDeployment, deleteDeploymentSchema } from "./tools/delete_deploym
33
33
  import { createDeployment } from "./tools/create_deployment.js";
34
34
  import { scaleDeployment, scaleDeploymentSchema } from "./tools/scale_deployment.js";
35
35
  import { describeDeployment, describeDeploymentSchema, } from "./tools/describe_deployment.js";
36
+ import { createConfigMap, CreateConfigMapSchema } from "./tools/create_configmap.js";
36
37
  const k8sManager = new KubernetesManager();
37
38
  const server = new Server({
38
39
  name: serverConfig.name,
@@ -72,6 +73,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
72
73
  StopPortForwardSchema,
73
74
  scaleDeploymentSchema,
74
75
  DeleteCronJobSchema,
76
+ CreateConfigMapSchema,
75
77
  ],
76
78
  };
77
79
  });
@@ -192,6 +194,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
192
194
  case "scale_deployment": {
193
195
  return await scaleDeployment(k8sManager, input);
194
196
  }
197
+ case "create_configmap": {
198
+ return await createConfigMap(k8sManager, input);
199
+ }
195
200
  default:
196
201
  throw new McpError(ErrorCode.InvalidRequest, `Unknown tool: ${name}`);
197
202
  }
@@ -483,3 +483,25 @@ export declare const DeleteCronJobResponseSchema: z.ZodObject<{
483
483
  success: boolean;
484
484
  }[];
485
485
  }>;
486
+ export declare const CreateConfigMapResponseSchema: z.ZodObject<{
487
+ content: z.ZodArray<z.ZodObject<{
488
+ success: z.ZodBoolean;
489
+ message: z.ZodString;
490
+ }, "strip", z.ZodTypeAny, {
491
+ message: string;
492
+ success: boolean;
493
+ }, {
494
+ message: string;
495
+ success: boolean;
496
+ }>, "many">;
497
+ }, "strip", z.ZodTypeAny, {
498
+ content: {
499
+ message: string;
500
+ success: boolean;
501
+ }[];
502
+ }, {
503
+ content: {
504
+ message: string;
505
+ success: boolean;
506
+ }[];
507
+ }>;
@@ -79,3 +79,9 @@ export const DeleteCronJobResponseSchema = z.object({
79
79
  message: z.string(),
80
80
  })),
81
81
  });
82
+ export const CreateConfigMapResponseSchema = z.object({
83
+ content: z.array(z.object({
84
+ success: z.boolean(),
85
+ message: z.string(),
86
+ })),
87
+ });
@@ -0,0 +1,33 @@
1
+ import { KubernetesManager } from "../types.js";
2
+ export declare const CreateConfigMapSchema: {
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
+ data: {
15
+ type: string;
16
+ ConfigData: {
17
+ type: string;
18
+ };
19
+ };
20
+ };
21
+ required: string[];
22
+ };
23
+ };
24
+ export declare function createConfigMap(k8sManager: KubernetesManager, input: {
25
+ name: string;
26
+ namespace: string;
27
+ data: Record<string, string>;
28
+ }): Promise<{
29
+ content: {
30
+ success: boolean;
31
+ message: string;
32
+ }[];
33
+ }>;
@@ -0,0 +1,66 @@
1
+ export const CreateConfigMapSchema = {
2
+ name: "create_configmap",
3
+ description: "Create a new Kubernetes ConfigMap",
4
+ inputSchema: {
5
+ type: "object",
6
+ properties: {
7
+ name: { type: "string" },
8
+ namespace: { type: "string" },
9
+ data: {
10
+ type: "object",
11
+ ConfigData: { type: "string" },
12
+ },
13
+ },
14
+ required: ["name", "namespace", "data"],
15
+ },
16
+ };
17
+ export async function createConfigMap(k8sManager, input) {
18
+ try {
19
+ const configmap = {
20
+ apiVersion: "v1",
21
+ kind: "ConfigMap",
22
+ binaryData: undefined,
23
+ data: input.data,
24
+ immutable: false,
25
+ metadata: {
26
+ name: input.name,
27
+ namespace: input.namespace,
28
+ labels: {
29
+ "mcp-managed": "true",
30
+ app: input.name,
31
+ },
32
+ },
33
+ };
34
+ const response = await k8sManager.getCoreApi().createNamespacedConfigMap(input.namespace, configmap);
35
+ if (response.response?.statusCode !== undefined && (response.response.statusCode == 200 || response.response.statusCode == 201 || response.response.statusCode == 202)) {
36
+ return {
37
+ content: [
38
+ {
39
+ success: true,
40
+ message: `Created ConfigMap ${response.body.metadata?.name} in namespace ${response.body.metadata?.namespace}`,
41
+ }
42
+ ]
43
+ };
44
+ }
45
+ else {
46
+ return {
47
+ content: [
48
+ {
49
+ success: false,
50
+ message: `Failed to create ConfigMap ${response.body.metadata?.name} in namespace ${response.body.metadata?.namespace}`,
51
+ }
52
+ ]
53
+ };
54
+ }
55
+ }
56
+ catch (error) {
57
+ return {
58
+ content: [
59
+ {
60
+ success: false,
61
+ message: `Failed to create ConfigMap ${input.name} in namespace ${input.namespace}. Error: ${error.message}`,
62
+ }
63
+ ]
64
+ };
65
+ }
66
+ }
@@ -30,7 +30,7 @@ export async function createNamespace(k8sManager, input) {
30
30
  {
31
31
  type: "text",
32
32
  text: JSON.stringify({
33
- podName: response.body.metadata.name,
33
+ namespaceName: response.body.metadata.name,
34
34
  status: "created",
35
35
  }, null, 2),
36
36
  },
@@ -24,6 +24,7 @@ export declare const installHelmChartSchema: {
24
24
  values: {
25
25
  type: string;
26
26
  description: string;
27
+ properties: {};
27
28
  additionalProperties: boolean;
28
29
  };
29
30
  };
@@ -55,6 +56,7 @@ export declare const upgradeHelmChartSchema: {
55
56
  values: {
56
57
  type: string;
57
58
  description: string;
59
+ properties: {};
58
60
  additionalProperties: boolean;
59
61
  };
60
62
  };
@@ -26,6 +26,7 @@ export const installHelmChartSchema = {
26
26
  values: {
27
27
  type: "object",
28
28
  description: "Chart values",
29
+ properties: {},
29
30
  additionalProperties: true,
30
31
  },
31
32
  },
@@ -57,6 +58,7 @@ export const upgradeHelmChartSchema = {
57
58
  values: {
58
59
  type: "object",
59
60
  description: "Chart values",
61
+ properties: {},
60
62
  additionalProperties: true,
61
63
  },
62
64
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-server-kubernetes",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "MCP server for interacting with Kubernetes clusters via kubectl",
5
5
  "license": "MIT",
6
6
  "type": "module",