mcp-server-kubernetes 1.6.2 → 2.0.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/README.md +46 -22
- package/dist/config/container-templates.d.ts +2 -2
- package/dist/index.d.ts +314 -736
- package/dist/index.js +93 -200
- package/dist/models/resource-models.d.ts +6 -6
- package/dist/tools/kubectl-apply.d.ts +46 -0
- package/dist/tools/kubectl-apply.js +110 -0
- package/dist/tools/kubectl-context.d.ts +49 -0
- package/dist/tools/kubectl-context.js +233 -0
- package/dist/tools/kubectl-create.d.ts +150 -0
- package/dist/tools/kubectl-create.js +321 -0
- package/dist/tools/kubectl-delete.d.ts +77 -0
- package/dist/tools/kubectl-delete.js +177 -0
- package/dist/tools/kubectl-describe.d.ts +47 -0
- package/dist/tools/kubectl-describe.js +96 -0
- package/dist/tools/kubectl-generic.d.ts +71 -0
- package/dist/tools/kubectl-generic.js +121 -0
- package/dist/tools/kubectl-get.d.ts +72 -0
- package/dist/tools/kubectl-get.js +251 -0
- package/dist/tools/kubectl-list.d.ts +61 -0
- package/dist/tools/kubectl-list.js +189 -0
- package/dist/tools/{get_logs.d.ts → kubectl-logs.d.ts} +35 -19
- package/dist/tools/kubectl-logs.js +312 -0
- package/dist/tools/kubectl-patch.d.ts +57 -0
- package/dist/tools/kubectl-patch.js +128 -0
- package/dist/tools/kubectl-rollout.d.ts +67 -0
- package/dist/tools/kubectl-rollout.js +115 -0
- package/dist/tools/{scale_deployment.d.ts → kubectl-scale.d.ts} +13 -3
- package/dist/tools/kubectl-scale.js +73 -0
- package/package.json +1 -1
- package/dist/tools/create_configmap.d.ts +0 -33
- package/dist/tools/create_configmap.js +0 -66
- package/dist/tools/create_cronjob.d.ts +0 -47
- package/dist/tools/create_cronjob.js +0 -93
- package/dist/tools/create_deployment.d.ts +0 -135
- package/dist/tools/create_deployment.js +0 -162
- package/dist/tools/create_namespace.d.ts +0 -22
- package/dist/tools/create_namespace.js +0 -48
- package/dist/tools/create_pod.d.ts +0 -130
- package/dist/tools/create_pod.js +0 -153
- package/dist/tools/create_service.d.ts +0 -74
- package/dist/tools/create_service.js +0 -102
- package/dist/tools/delete_configmap.d.ts +0 -26
- package/dist/tools/delete_configmap.js +0 -49
- package/dist/tools/delete_cronjob.d.ts +0 -26
- package/dist/tools/delete_cronjob.js +0 -48
- package/dist/tools/delete_deployment.d.ts +0 -31
- package/dist/tools/delete_deployment.js +0 -47
- package/dist/tools/delete_namespace.d.ts +0 -27
- package/dist/tools/delete_namespace.js +0 -44
- package/dist/tools/delete_pod.d.ts +0 -31
- package/dist/tools/delete_pod.js +0 -45
- package/dist/tools/delete_service.d.ts +0 -32
- package/dist/tools/delete_service.js +0 -46
- package/dist/tools/describe_cronjob.d.ts +0 -27
- package/dist/tools/describe_cronjob.js +0 -83
- package/dist/tools/describe_deployment.d.ts +0 -26
- package/dist/tools/describe_deployment.js +0 -40
- package/dist/tools/describe_node.d.ts +0 -22
- package/dist/tools/describe_node.js +0 -84
- package/dist/tools/describe_pod.d.ts +0 -33
- package/dist/tools/describe_pod.js +0 -81
- package/dist/tools/describe_service.d.ts +0 -34
- package/dist/tools/describe_service.js +0 -85
- package/dist/tools/get_configmap.d.ts +0 -27
- package/dist/tools/get_configmap.js +0 -48
- package/dist/tools/get_current_context.d.ts +0 -23
- package/dist/tools/get_current_context.js +0 -55
- package/dist/tools/get_events.d.ts +0 -28
- package/dist/tools/get_events.js +0 -66
- package/dist/tools/get_job_logs.d.ts +0 -40
- package/dist/tools/get_job_logs.js +0 -104
- package/dist/tools/get_logs.js +0 -150
- package/dist/tools/list_contexts.d.ts +0 -23
- package/dist/tools/list_contexts.js +0 -39
- package/dist/tools/list_cronjobs.d.ts +0 -23
- package/dist/tools/list_cronjobs.js +0 -35
- package/dist/tools/list_deployments.d.ts +0 -23
- package/dist/tools/list_deployments.js +0 -30
- package/dist/tools/list_jobs.d.ts +0 -29
- package/dist/tools/list_jobs.js +0 -77
- package/dist/tools/list_nodes.d.ts +0 -15
- package/dist/tools/list_nodes.js +0 -21
- package/dist/tools/list_pods.d.ts +0 -23
- package/dist/tools/list_pods.js +0 -29
- package/dist/tools/list_services.d.ts +0 -23
- package/dist/tools/list_services.js +0 -31
- package/dist/tools/scale_deployment.js +0 -50
- package/dist/tools/set_current_context.d.ts +0 -23
- package/dist/tools/set_current_context.js +0 -35
- package/dist/tools/update_configmap.d.ts +0 -33
- package/dist/tools/update_configmap.js +0 -71
- package/dist/tools/update_deployment.d.ts +0 -113
- package/dist/tools/update_deployment.js +0 -155
- package/dist/tools/update_service.d.ts +0 -72
- package/dist/tools/update_service.js +0 -125
package/dist/tools/list_nodes.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export const listNodesSchema = {
|
|
2
|
-
name: "list_nodes",
|
|
3
|
-
description: "List all nodes in the cluster",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {},
|
|
7
|
-
},
|
|
8
|
-
};
|
|
9
|
-
export async function listNodes(k8sManager) {
|
|
10
|
-
const { body } = await k8sManager.getCoreApi().listNode();
|
|
11
|
-
return {
|
|
12
|
-
content: [
|
|
13
|
-
{
|
|
14
|
-
type: "text",
|
|
15
|
-
text: JSON.stringify({
|
|
16
|
-
nodes: body.items,
|
|
17
|
-
}, null, 2),
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
};
|
|
21
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const listPodsSchema: {
|
|
3
|
-
readonly name: "list_pods";
|
|
4
|
-
readonly description: "List pods in a namespace";
|
|
5
|
-
readonly inputSchema: {
|
|
6
|
-
readonly type: "object";
|
|
7
|
-
readonly properties: {
|
|
8
|
-
readonly namespace: {
|
|
9
|
-
readonly type: "string";
|
|
10
|
-
readonly default: "default";
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
readonly required: readonly ["namespace"];
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export declare function listPods(k8sManager: KubernetesManager, input: {
|
|
17
|
-
namespace?: string;
|
|
18
|
-
}): Promise<{
|
|
19
|
-
content: {
|
|
20
|
-
type: string;
|
|
21
|
-
text: string;
|
|
22
|
-
}[];
|
|
23
|
-
}>;
|
package/dist/tools/list_pods.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export const listPodsSchema = {
|
|
2
|
-
name: "list_pods",
|
|
3
|
-
description: "List pods in a namespace",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
namespace: { type: "string", default: "default" },
|
|
8
|
-
},
|
|
9
|
-
required: ["namespace"],
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
export async function listPods(k8sManager, input) {
|
|
13
|
-
const namespace = input.namespace || "default";
|
|
14
|
-
const { body } = await k8sManager.getCoreApi().listNamespacedPod(namespace);
|
|
15
|
-
const pods = body.items.map((pod) => ({
|
|
16
|
-
name: pod.metadata?.name || "",
|
|
17
|
-
namespace: pod.metadata?.namespace || "",
|
|
18
|
-
phase: pod.status?.phase,
|
|
19
|
-
createdAt: pod.metadata?.creationTimestamp,
|
|
20
|
-
}));
|
|
21
|
-
return {
|
|
22
|
-
content: [
|
|
23
|
-
{
|
|
24
|
-
type: "text",
|
|
25
|
-
text: JSON.stringify({ pods }, null, 2),
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
};
|
|
29
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const listServicesSchema: {
|
|
3
|
-
readonly name: "list_services";
|
|
4
|
-
readonly description: "List services in a namespace";
|
|
5
|
-
readonly inputSchema: {
|
|
6
|
-
readonly type: "object";
|
|
7
|
-
readonly properties: {
|
|
8
|
-
readonly namespace: {
|
|
9
|
-
readonly type: "string";
|
|
10
|
-
readonly default: "default";
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
readonly required: readonly ["namespace"];
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export declare function listServices(k8sManager: KubernetesManager, input: {
|
|
17
|
-
namespace?: string;
|
|
18
|
-
}): Promise<{
|
|
19
|
-
content: {
|
|
20
|
-
type: string;
|
|
21
|
-
text: string;
|
|
22
|
-
}[];
|
|
23
|
-
}>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export const listServicesSchema = {
|
|
2
|
-
name: "list_services",
|
|
3
|
-
description: "List services in a namespace",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
namespace: { type: "string", default: "default" },
|
|
8
|
-
},
|
|
9
|
-
required: ["namespace"],
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
export async function listServices(k8sManager, input) {
|
|
13
|
-
const namespace = input.namespace || "default";
|
|
14
|
-
const { body } = await k8sManager.getCoreApi().listNamespacedService(namespace);
|
|
15
|
-
const services = body.items.map((service) => ({
|
|
16
|
-
name: service.metadata?.name || "",
|
|
17
|
-
namespace: service.metadata?.namespace || "",
|
|
18
|
-
type: service.spec?.type,
|
|
19
|
-
clusterIP: service.spec?.clusterIP,
|
|
20
|
-
ports: service.spec?.ports || [],
|
|
21
|
-
createdAt: service.metadata?.creationTimestamp,
|
|
22
|
-
}));
|
|
23
|
-
return {
|
|
24
|
-
content: [
|
|
25
|
-
{
|
|
26
|
-
type: "text",
|
|
27
|
-
text: JSON.stringify({ services }, null, 2),
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
};
|
|
31
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export const scaleDeploymentSchema = {
|
|
2
|
-
name: "scale_deployment",
|
|
3
|
-
description: "Scale a Kubernetes deployment",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
name: { type: "string" },
|
|
8
|
-
namespace: { type: "string" },
|
|
9
|
-
replicas: { type: "number" }
|
|
10
|
-
},
|
|
11
|
-
required: ["name", "namespace", "replicas"]
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
export async function scaleDeployment(k8sManager, input) {
|
|
15
|
-
try {
|
|
16
|
-
const scale = k8sManager.getAppsApi().readNamespacedDeploymentScale(input.name, input.namespace);
|
|
17
|
-
(await scale).body.spec.replicas = input.replicas;
|
|
18
|
-
const result = await k8sManager.getAppsApi().replaceNamespacedDeploymentScale(input.name, input.namespace, (await scale).body);
|
|
19
|
-
if (result.response?.statusCode !== undefined && result.response.statusCode >= 200 && result.response.statusCode < 300) {
|
|
20
|
-
return {
|
|
21
|
-
content: [
|
|
22
|
-
{
|
|
23
|
-
success: true,
|
|
24
|
-
message: `Scaled deployment ${input.name} to ${input.replicas} replicas`
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return {
|
|
31
|
-
content: [
|
|
32
|
-
{
|
|
33
|
-
success: false,
|
|
34
|
-
message: `Failed to scale deployment ${input.name} to ${input.replicas} replicas`
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
return {
|
|
42
|
-
content: [
|
|
43
|
-
{
|
|
44
|
-
success: false,
|
|
45
|
-
message: `Failed to scale deployment ${error.message}`
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const setCurrentContextSchema: {
|
|
3
|
-
readonly name: "set_current_context";
|
|
4
|
-
readonly description: "Set the current Kubernetes context";
|
|
5
|
-
readonly inputSchema: {
|
|
6
|
-
readonly type: "object";
|
|
7
|
-
readonly properties: {
|
|
8
|
-
readonly name: {
|
|
9
|
-
readonly type: "string";
|
|
10
|
-
readonly description: "Name of the context to set as current";
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
readonly required: readonly ["name"];
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export declare function setCurrentContext(k8sManager: KubernetesManager, input: {
|
|
17
|
-
name: string;
|
|
18
|
-
}): Promise<{
|
|
19
|
-
content: {
|
|
20
|
-
type: string;
|
|
21
|
-
text: string;
|
|
22
|
-
}[];
|
|
23
|
-
}>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export const setCurrentContextSchema = {
|
|
2
|
-
name: "set_current_context",
|
|
3
|
-
description: "Set the current Kubernetes context",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
name: {
|
|
8
|
-
type: "string",
|
|
9
|
-
description: "Name of the context to set as current"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
required: ["name"],
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
export async function setCurrentContext(k8sManager, input) {
|
|
16
|
-
try {
|
|
17
|
-
// Set the current context
|
|
18
|
-
k8sManager.setCurrentContext(input.name);
|
|
19
|
-
return {
|
|
20
|
-
content: [
|
|
21
|
-
{
|
|
22
|
-
type: "text",
|
|
23
|
-
text: JSON.stringify({
|
|
24
|
-
success: true,
|
|
25
|
-
message: `Current context set to '${input.name}'`,
|
|
26
|
-
context: input.name
|
|
27
|
-
}, null, 2),
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
throw new Error(`Failed to set current context: ${error.message}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const UpdateConfigMapSchema: {
|
|
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 updateConfigMap(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
|
-
}>;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
export const UpdateConfigMapSchema = {
|
|
2
|
-
name: "update_configmap",
|
|
3
|
-
description: "Update an existing 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 updateConfigMap(k8sManager, input) {
|
|
18
|
-
try {
|
|
19
|
-
// Fetch the existing ConfigMap
|
|
20
|
-
const existing = await k8sManager.getCoreApi().readNamespacedConfigMap(input.name, input.namespace);
|
|
21
|
-
if (!existing.body || !existing.body.metadata) {
|
|
22
|
-
return {
|
|
23
|
-
content: [
|
|
24
|
-
{
|
|
25
|
-
success: false,
|
|
26
|
-
message: `ConfigMap ${input.name} in namespace ${input.namespace} not found.`,
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// Update the data
|
|
32
|
-
const updatedConfigMap = {
|
|
33
|
-
...existing.body,
|
|
34
|
-
data: input.data,
|
|
35
|
-
};
|
|
36
|
-
const response = await k8sManager.getCoreApi().replaceNamespacedConfigMap(input.name, input.namespace, updatedConfigMap);
|
|
37
|
-
if (response.response?.statusCode !== undefined &&
|
|
38
|
-
(response.response.statusCode === 200 ||
|
|
39
|
-
response.response.statusCode === 201 ||
|
|
40
|
-
response.response.statusCode === 202)) {
|
|
41
|
-
return {
|
|
42
|
-
content: [
|
|
43
|
-
{
|
|
44
|
-
success: true,
|
|
45
|
-
message: `Updated ConfigMap ${input.name} in namespace ${input.namespace}`,
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
return {
|
|
52
|
-
content: [
|
|
53
|
-
{
|
|
54
|
-
success: false,
|
|
55
|
-
message: `Failed to update ConfigMap ${input.name} in namespace ${input.namespace}`,
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
return {
|
|
63
|
-
content: [
|
|
64
|
-
{
|
|
65
|
-
success: false,
|
|
66
|
-
message: `Failed to update ConfigMap ${input.name} in namespace ${input.namespace}. Error: ${error.message}`,
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
import { CustomContainerConfigType } from "../config/container-templates.js";
|
|
3
|
-
export declare const updateDeploymentSchema: {
|
|
4
|
-
name: string;
|
|
5
|
-
description: string;
|
|
6
|
-
inputSchema: {
|
|
7
|
-
type: string;
|
|
8
|
-
required: string[];
|
|
9
|
-
properties: {
|
|
10
|
-
name: {
|
|
11
|
-
type: string;
|
|
12
|
-
};
|
|
13
|
-
namespace: {
|
|
14
|
-
type: string;
|
|
15
|
-
};
|
|
16
|
-
template: {
|
|
17
|
-
type: string;
|
|
18
|
-
enum: ["ubuntu", "nginx", "busybox", "alpine", "custom"];
|
|
19
|
-
};
|
|
20
|
-
containerName: {
|
|
21
|
-
type: string;
|
|
22
|
-
description: string;
|
|
23
|
-
};
|
|
24
|
-
replicas: {
|
|
25
|
-
type: string;
|
|
26
|
-
};
|
|
27
|
-
customConfig: {
|
|
28
|
-
type: string;
|
|
29
|
-
properties: {
|
|
30
|
-
image: {
|
|
31
|
-
type: string;
|
|
32
|
-
};
|
|
33
|
-
command: {
|
|
34
|
-
type: string;
|
|
35
|
-
items: {
|
|
36
|
-
type: string;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
args: {
|
|
40
|
-
type: string;
|
|
41
|
-
items: {
|
|
42
|
-
type: string;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
ports: {
|
|
46
|
-
type: string;
|
|
47
|
-
items: {
|
|
48
|
-
type: string;
|
|
49
|
-
properties: {
|
|
50
|
-
containerPort: {
|
|
51
|
-
type: string;
|
|
52
|
-
};
|
|
53
|
-
name: {
|
|
54
|
-
type: string;
|
|
55
|
-
};
|
|
56
|
-
protocol: {
|
|
57
|
-
type: string;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
resources: {
|
|
63
|
-
type: string;
|
|
64
|
-
properties: {
|
|
65
|
-
limits: {
|
|
66
|
-
type: string;
|
|
67
|
-
additionalProperties: {
|
|
68
|
-
type: string;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
requests: {
|
|
72
|
-
type: string;
|
|
73
|
-
additionalProperties: {
|
|
74
|
-
type: string;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
env: {
|
|
80
|
-
type: string;
|
|
81
|
-
items: {
|
|
82
|
-
type: string;
|
|
83
|
-
properties: {
|
|
84
|
-
name: {
|
|
85
|
-
type: string;
|
|
86
|
-
};
|
|
87
|
-
value: {
|
|
88
|
-
type: string;
|
|
89
|
-
};
|
|
90
|
-
valueFrom: {
|
|
91
|
-
type: string;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
export declare function updateDeployment(k8sManager: KubernetesManager, params: {
|
|
102
|
-
name: string;
|
|
103
|
-
namespace: string;
|
|
104
|
-
template: string;
|
|
105
|
-
containerName?: string;
|
|
106
|
-
replicas?: number;
|
|
107
|
-
customConfig?: CustomContainerConfigType;
|
|
108
|
-
}): Promise<{
|
|
109
|
-
content: {
|
|
110
|
-
type: string;
|
|
111
|
-
text: string;
|
|
112
|
-
}[];
|
|
113
|
-
}>;
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
-
import { ContainerTemplate, containerTemplates, CustomContainerConfig, } from "../config/container-templates.js";
|
|
3
|
-
export const updateDeploymentSchema = {
|
|
4
|
-
name: "update_deployment",
|
|
5
|
-
description: "Update an existing kubernetes deployment in cluster",
|
|
6
|
-
inputSchema: {
|
|
7
|
-
type: "object",
|
|
8
|
-
required: ["name", "namespace", "template"],
|
|
9
|
-
properties: {
|
|
10
|
-
name: { type: "string" },
|
|
11
|
-
namespace: { type: "string" },
|
|
12
|
-
template: {
|
|
13
|
-
type: "string",
|
|
14
|
-
enum: ContainerTemplate.options,
|
|
15
|
-
},
|
|
16
|
-
containerName: {
|
|
17
|
-
type: "string",
|
|
18
|
-
description: "Name of the container to update",
|
|
19
|
-
},
|
|
20
|
-
replicas: { type: "number" },
|
|
21
|
-
customConfig: {
|
|
22
|
-
type: "object",
|
|
23
|
-
properties: {
|
|
24
|
-
image: { type: "string" },
|
|
25
|
-
command: { type: "array", items: { type: "string" } },
|
|
26
|
-
args: { type: "array", items: { type: "string" } },
|
|
27
|
-
ports: {
|
|
28
|
-
type: "array",
|
|
29
|
-
items: {
|
|
30
|
-
type: "object",
|
|
31
|
-
properties: {
|
|
32
|
-
containerPort: { type: "number" },
|
|
33
|
-
name: { type: "string" },
|
|
34
|
-
protocol: { type: "string" },
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
resources: {
|
|
39
|
-
type: "object",
|
|
40
|
-
properties: {
|
|
41
|
-
limits: {
|
|
42
|
-
type: "object",
|
|
43
|
-
additionalProperties: { type: "string" },
|
|
44
|
-
},
|
|
45
|
-
requests: {
|
|
46
|
-
type: "object",
|
|
47
|
-
additionalProperties: { type: "string" },
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
env: {
|
|
52
|
-
type: "array",
|
|
53
|
-
items: {
|
|
54
|
-
type: "object",
|
|
55
|
-
properties: {
|
|
56
|
-
name: { type: "string" },
|
|
57
|
-
value: { type: "string" },
|
|
58
|
-
valueFrom: { type: "object" },
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
export async function updateDeployment(k8sManager, params) {
|
|
68
|
-
// Get existing deployment
|
|
69
|
-
const { body: existingDeployment } = await k8sManager
|
|
70
|
-
.getAppsApi()
|
|
71
|
-
.readNamespacedDeployment(params.name, params.namespace)
|
|
72
|
-
.catch((error) => {
|
|
73
|
-
console.error("Deployment read error:", {
|
|
74
|
-
status: error.response?.statusCode,
|
|
75
|
-
message: error.response?.body?.message || error.message,
|
|
76
|
-
details: error.response?.body,
|
|
77
|
-
});
|
|
78
|
-
throw error;
|
|
79
|
-
});
|
|
80
|
-
// Find target container
|
|
81
|
-
const containers = existingDeployment.spec.template.spec.containers;
|
|
82
|
-
let targetContainerIndex = params.containerName
|
|
83
|
-
? containers.findIndex(c => c.name === params.containerName)
|
|
84
|
-
: 0;
|
|
85
|
-
if (targetContainerIndex === -1) {
|
|
86
|
-
throw new McpError(ErrorCode.InvalidRequest, `Container '${params.containerName}' not found in deployment`);
|
|
87
|
-
}
|
|
88
|
-
// Prepare container config
|
|
89
|
-
const templateConfig = containerTemplates[params.template];
|
|
90
|
-
let containerConfig;
|
|
91
|
-
if (params.template === "custom") {
|
|
92
|
-
if (!params.customConfig) {
|
|
93
|
-
throw new McpError(ErrorCode.InvalidRequest, "Custom container configuration is required when using 'custom' template");
|
|
94
|
-
}
|
|
95
|
-
const validatedConfig = CustomContainerConfig.parse(params.customConfig);
|
|
96
|
-
containerConfig = {
|
|
97
|
-
...containers[targetContainerIndex],
|
|
98
|
-
...templateConfig,
|
|
99
|
-
image: validatedConfig.image,
|
|
100
|
-
command: validatedConfig.command,
|
|
101
|
-
args: validatedConfig.args,
|
|
102
|
-
ports: validatedConfig.ports,
|
|
103
|
-
resources: validatedConfig.resources,
|
|
104
|
-
env: validatedConfig.env,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
containerConfig = {
|
|
109
|
-
...containers[targetContainerIndex],
|
|
110
|
-
...templateConfig,
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
// Update deployment
|
|
114
|
-
const updatedContainers = [...containers];
|
|
115
|
-
updatedContainers[targetContainerIndex] = containerConfig;
|
|
116
|
-
const updatedDeployment = {
|
|
117
|
-
...existingDeployment,
|
|
118
|
-
spec: {
|
|
119
|
-
...existingDeployment.spec,
|
|
120
|
-
replicas: params.replicas ?? existingDeployment.spec.replicas,
|
|
121
|
-
template: {
|
|
122
|
-
...existingDeployment.spec.template,
|
|
123
|
-
spec: {
|
|
124
|
-
...existingDeployment.spec.template.spec,
|
|
125
|
-
containers: updatedContainers,
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
const { body } = await k8sManager
|
|
131
|
-
.getAppsApi()
|
|
132
|
-
.replaceNamespacedDeployment(params.name, params.namespace, updatedDeployment)
|
|
133
|
-
.catch((error) => {
|
|
134
|
-
if (error instanceof McpError)
|
|
135
|
-
throw error;
|
|
136
|
-
throw new McpError(ErrorCode.InternalError, `Failed to update deployment: ${error}`);
|
|
137
|
-
});
|
|
138
|
-
return {
|
|
139
|
-
content: [
|
|
140
|
-
{
|
|
141
|
-
type: "text",
|
|
142
|
-
text: JSON.stringify({
|
|
143
|
-
message: "Deployment updated successfully",
|
|
144
|
-
deployment: {
|
|
145
|
-
name: body.metadata?.name,
|
|
146
|
-
namespace: body.metadata?.namespace,
|
|
147
|
-
replicas: body.spec?.replicas,
|
|
148
|
-
image: body.spec?.template.spec?.containers[targetContainerIndex].image,
|
|
149
|
-
containerName: body.spec?.template.spec?.containers[targetContainerIndex].name,
|
|
150
|
-
},
|
|
151
|
-
}, null, 2),
|
|
152
|
-
},
|
|
153
|
-
],
|
|
154
|
-
};
|
|
155
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const updateServiceSchema: {
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
inputSchema: {
|
|
6
|
-
type: string;
|
|
7
|
-
required: string[];
|
|
8
|
-
properties: {
|
|
9
|
-
name: {
|
|
10
|
-
type: string;
|
|
11
|
-
};
|
|
12
|
-
namespace: {
|
|
13
|
-
type: string;
|
|
14
|
-
default: string;
|
|
15
|
-
};
|
|
16
|
-
type: {
|
|
17
|
-
type: string;
|
|
18
|
-
enum: string[];
|
|
19
|
-
};
|
|
20
|
-
selector: {
|
|
21
|
-
type: string;
|
|
22
|
-
additionalProperties: {
|
|
23
|
-
type: string;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
ports: {
|
|
27
|
-
type: string;
|
|
28
|
-
items: {
|
|
29
|
-
type: string;
|
|
30
|
-
properties: {
|
|
31
|
-
port: {
|
|
32
|
-
type: string;
|
|
33
|
-
};
|
|
34
|
-
targetPort: {
|
|
35
|
-
type: string;
|
|
36
|
-
};
|
|
37
|
-
protocol: {
|
|
38
|
-
type: string;
|
|
39
|
-
enum: string[];
|
|
40
|
-
default: string;
|
|
41
|
-
};
|
|
42
|
-
name: {
|
|
43
|
-
type: string;
|
|
44
|
-
};
|
|
45
|
-
nodePort: {
|
|
46
|
-
type: string;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
required: string[];
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
export declare function updateService(k8sManager: KubernetesManager, params: {
|
|
56
|
-
name: string;
|
|
57
|
-
namespace: string;
|
|
58
|
-
type?: "ClusterIP" | "NodePort" | "LoadBalancer";
|
|
59
|
-
selector?: Record<string, string>;
|
|
60
|
-
ports?: Array<{
|
|
61
|
-
port: number;
|
|
62
|
-
targetPort?: number;
|
|
63
|
-
protocol?: string;
|
|
64
|
-
name?: string;
|
|
65
|
-
nodePort?: number;
|
|
66
|
-
}>;
|
|
67
|
-
}): Promise<{
|
|
68
|
-
content: {
|
|
69
|
-
type: string;
|
|
70
|
-
text: string;
|
|
71
|
-
}[];
|
|
72
|
-
}>;
|