mcp-server-kubernetes 2.6.0 → 2.8.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.d.ts +86 -29
- package/dist/index.js +6 -0
- package/dist/models/common-parameters.d.ts +15 -0
- package/dist/models/common-parameters.js +15 -0
- package/dist/models/kubectl-models.d.ts +2 -0
- package/dist/tools/exec_in_pod.d.ts +7 -1
- package/dist/tools/exec_in_pod.js +7 -5
- package/dist/tools/helm-operations.d.ts +21 -3
- package/dist/tools/helm-operations.js +7 -12
- package/dist/tools/kubectl-apply.d.ts +12 -6
- package/dist/tools/kubectl-apply.js +9 -10
- package/dist/tools/kubectl-create.d.ts +12 -6
- package/dist/tools/kubectl-create.js +9 -10
- package/dist/tools/kubectl-delete.d.ts +9 -3
- package/dist/tools/kubectl-delete.js +8 -5
- package/dist/tools/kubectl-describe.d.ts +9 -3
- package/dist/tools/kubectl-describe.js +7 -5
- package/dist/tools/kubectl-generic.d.ts +7 -1
- package/dist/tools/kubectl-generic.js +7 -5
- package/dist/tools/kubectl-get.d.ts +9 -3
- package/dist/tools/kubectl-get.js +7 -5
- package/dist/tools/kubectl-logs.d.ts +9 -3
- package/dist/tools/kubectl-logs.js +11 -5
- package/dist/tools/kubectl-operations.d.ts +10 -0
- package/dist/tools/kubectl-operations.js +13 -0
- package/dist/tools/kubectl-patch.d.ts +8 -2
- package/dist/tools/kubectl-patch.js +9 -10
- package/dist/tools/kubectl-rollout.d.ts +7 -1
- package/dist/tools/kubectl-rollout.js +8 -5
- package/dist/tools/kubectl-scale.d.ts +7 -1
- package/dist/tools/kubectl-scale.js +8 -5
- package/dist/utils/streamable-http.d.ts +3 -0
- package/dist/utils/streamable-http.js +79 -0
- package/package.json +2 -2
|
@@ -14,9 +14,9 @@ export declare const kubectlDeleteSchema: {
|
|
|
14
14
|
readonly description: "Name of the resource to delete";
|
|
15
15
|
};
|
|
16
16
|
readonly namespace: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
type: "string";
|
|
18
|
+
description: string;
|
|
19
|
+
default: string;
|
|
20
20
|
};
|
|
21
21
|
readonly labelSelector: {
|
|
22
22
|
readonly type: "string";
|
|
@@ -44,6 +44,11 @@ export declare const kubectlDeleteSchema: {
|
|
|
44
44
|
readonly type: "number";
|
|
45
45
|
readonly description: "Period of time in seconds given to the resource to terminate gracefully";
|
|
46
46
|
};
|
|
47
|
+
readonly context: {
|
|
48
|
+
type: "string";
|
|
49
|
+
description: string;
|
|
50
|
+
default: string;
|
|
51
|
+
};
|
|
47
52
|
};
|
|
48
53
|
readonly required: readonly ["resourceType", "name", "namespace"];
|
|
49
54
|
};
|
|
@@ -58,6 +63,7 @@ export declare function kubectlDelete(k8sManager: KubernetesManager, input: {
|
|
|
58
63
|
allNamespaces?: boolean;
|
|
59
64
|
force?: boolean;
|
|
60
65
|
gracePeriodSeconds?: number;
|
|
66
|
+
context?: string;
|
|
61
67
|
}): Promise<{
|
|
62
68
|
content: {
|
|
63
69
|
type: string;
|
|
@@ -4,6 +4,7 @@ import * as fs from "fs";
|
|
|
4
4
|
import * as path from "path";
|
|
5
5
|
import * as os from "os";
|
|
6
6
|
import { getSpawnMaxBuffer } from "../config/max-buffer.js";
|
|
7
|
+
import { contextParameter, namespaceParameter } from "../models/common-parameters.js";
|
|
7
8
|
export const kubectlDeleteSchema = {
|
|
8
9
|
name: "kubectl_delete",
|
|
9
10
|
description: "Delete Kubernetes resources by resource type, name, labels, or from a manifest file",
|
|
@@ -18,11 +19,7 @@ export const kubectlDeleteSchema = {
|
|
|
18
19
|
type: "string",
|
|
19
20
|
description: "Name of the resource to delete",
|
|
20
21
|
},
|
|
21
|
-
namespace:
|
|
22
|
-
type: "string",
|
|
23
|
-
description: "Namespace of the resource (optional - defaults to 'default' for namespaced resources)",
|
|
24
|
-
default: "default",
|
|
25
|
-
},
|
|
22
|
+
namespace: namespaceParameter,
|
|
26
23
|
labelSelector: {
|
|
27
24
|
type: "string",
|
|
28
25
|
description: "Delete resources matching this label selector (e.g. 'app=nginx')",
|
|
@@ -49,6 +46,7 @@ export const kubectlDeleteSchema = {
|
|
|
49
46
|
type: "number",
|
|
50
47
|
description: "Period of time in seconds given to the resource to terminate gracefully",
|
|
51
48
|
},
|
|
49
|
+
context: contextParameter,
|
|
52
50
|
},
|
|
53
51
|
required: ["resourceType", "name", "namespace"],
|
|
54
52
|
},
|
|
@@ -66,6 +64,7 @@ export async function kubectlDelete(k8sManager, input) {
|
|
|
66
64
|
const namespace = input.namespace || "default";
|
|
67
65
|
const allNamespaces = input.allNamespaces || false;
|
|
68
66
|
const force = input.force || false;
|
|
67
|
+
const context = input.context || "";
|
|
69
68
|
const command = "kubectl";
|
|
70
69
|
const args = ["delete"];
|
|
71
70
|
let tempFile = null;
|
|
@@ -107,6 +106,10 @@ export async function kubectlDelete(k8sManager, input) {
|
|
|
107
106
|
if (input.gracePeriodSeconds !== undefined) {
|
|
108
107
|
args.push(`--grace-period=${input.gracePeriodSeconds}`);
|
|
109
108
|
}
|
|
109
|
+
// Add context if provided
|
|
110
|
+
if (context) {
|
|
111
|
+
args.push("--context", context);
|
|
112
|
+
}
|
|
110
113
|
// Execute the command
|
|
111
114
|
try {
|
|
112
115
|
const result = execFileSync(command, args, {
|
|
@@ -14,9 +14,14 @@ export declare const kubectlDescribeSchema: {
|
|
|
14
14
|
readonly description: "Name of the resource to describe";
|
|
15
15
|
};
|
|
16
16
|
readonly namespace: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
type: "string";
|
|
18
|
+
description: string;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
21
|
+
readonly context: {
|
|
22
|
+
type: "string";
|
|
23
|
+
description: string;
|
|
24
|
+
default: string;
|
|
20
25
|
};
|
|
21
26
|
readonly allNamespaces: {
|
|
22
27
|
readonly type: "boolean";
|
|
@@ -32,6 +37,7 @@ export declare function kubectlDescribe(k8sManager: KubernetesManager, input: {
|
|
|
32
37
|
name: string;
|
|
33
38
|
namespace?: string;
|
|
34
39
|
allNamespaces?: boolean;
|
|
40
|
+
context?: string;
|
|
35
41
|
}): Promise<{
|
|
36
42
|
content: {
|
|
37
43
|
type: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { execFileSync } from "child_process";
|
|
2
2
|
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
|
|
3
3
|
import { getSpawnMaxBuffer } from "../config/max-buffer.js";
|
|
4
|
+
import { namespaceParameter, contextParameter } from "../models/common-parameters.js";
|
|
4
5
|
export const kubectlDescribeSchema = {
|
|
5
6
|
name: "kubectl_describe",
|
|
6
7
|
description: "Describe Kubernetes resources by resource type, name, and optionally namespace",
|
|
@@ -15,11 +16,8 @@ export const kubectlDescribeSchema = {
|
|
|
15
16
|
type: "string",
|
|
16
17
|
description: "Name of the resource to describe",
|
|
17
18
|
},
|
|
18
|
-
namespace:
|
|
19
|
-
|
|
20
|
-
description: "Namespace of the resource (optional - defaults to 'default' for namespaced resources)",
|
|
21
|
-
default: "default",
|
|
22
|
-
},
|
|
19
|
+
namespace: namespaceParameter,
|
|
20
|
+
context: contextParameter,
|
|
23
21
|
allNamespaces: {
|
|
24
22
|
type: "boolean",
|
|
25
23
|
description: "If true, describe resources across all namespaces",
|
|
@@ -35,6 +33,7 @@ export async function kubectlDescribe(k8sManager, input) {
|
|
|
35
33
|
const name = input.name;
|
|
36
34
|
const namespace = input.namespace || "default";
|
|
37
35
|
const allNamespaces = input.allNamespaces || false;
|
|
36
|
+
const context = input.context || "";
|
|
38
37
|
// Build the kubectl command
|
|
39
38
|
const command = "kubectl";
|
|
40
39
|
const args = ["describe", resourceType, name];
|
|
@@ -45,6 +44,9 @@ export async function kubectlDescribe(k8sManager, input) {
|
|
|
45
44
|
else if (namespace && !isNonNamespacedResource(resourceType)) {
|
|
46
45
|
args.push("-n", namespace);
|
|
47
46
|
}
|
|
47
|
+
if (context) {
|
|
48
|
+
args.push("--context", context);
|
|
49
|
+
}
|
|
48
50
|
// Execute the command
|
|
49
51
|
try {
|
|
50
52
|
const result = execFileSync(command, args, {
|
|
@@ -22,7 +22,7 @@ export declare const kubectlGenericSchema: {
|
|
|
22
22
|
description: string;
|
|
23
23
|
};
|
|
24
24
|
namespace: {
|
|
25
|
-
type: string;
|
|
25
|
+
type: "string";
|
|
26
26
|
description: string;
|
|
27
27
|
default: string;
|
|
28
28
|
};
|
|
@@ -43,6 +43,11 @@ export declare const kubectlGenericSchema: {
|
|
|
43
43
|
};
|
|
44
44
|
description: string;
|
|
45
45
|
};
|
|
46
|
+
context: {
|
|
47
|
+
type: "string";
|
|
48
|
+
description: string;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
46
51
|
};
|
|
47
52
|
required: string[];
|
|
48
53
|
};
|
|
@@ -56,6 +61,7 @@ export declare function kubectlGeneric(k8sManager: KubernetesManager, input: {
|
|
|
56
61
|
outputFormat?: string;
|
|
57
62
|
flags?: Record<string, any>;
|
|
58
63
|
args?: string[];
|
|
64
|
+
context?: string;
|
|
59
65
|
}): Promise<{
|
|
60
66
|
content: {
|
|
61
67
|
type: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { execFileSync } from "child_process";
|
|
2
2
|
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
|
|
3
3
|
import { getSpawnMaxBuffer } from "../config/max-buffer.js";
|
|
4
|
+
import { contextParameter, namespaceParameter } from "../models/common-parameters.js";
|
|
4
5
|
export const kubectlGenericSchema = {
|
|
5
6
|
name: "kubectl_generic",
|
|
6
7
|
description: "Execute any kubectl command with the provided arguments and flags",
|
|
@@ -23,11 +24,7 @@ export const kubectlGenericSchema = {
|
|
|
23
24
|
type: "string",
|
|
24
25
|
description: "Resource name",
|
|
25
26
|
},
|
|
26
|
-
namespace:
|
|
27
|
-
type: "string",
|
|
28
|
-
description: "Namespace",
|
|
29
|
-
default: "default",
|
|
30
|
-
},
|
|
27
|
+
namespace: namespaceParameter,
|
|
31
28
|
outputFormat: {
|
|
32
29
|
type: "string",
|
|
33
30
|
description: "Output format (e.g. json, yaml, wide)",
|
|
@@ -43,6 +40,7 @@ export const kubectlGenericSchema = {
|
|
|
43
40
|
items: { type: "string" },
|
|
44
41
|
description: "Additional command arguments",
|
|
45
42
|
},
|
|
43
|
+
context: contextParameter,
|
|
46
44
|
},
|
|
47
45
|
required: ["command"],
|
|
48
46
|
},
|
|
@@ -89,6 +87,10 @@ export async function kubectlGeneric(k8sManager, input) {
|
|
|
89
87
|
if (input.args && input.args.length > 0) {
|
|
90
88
|
cmdArgs.push(...input.args);
|
|
91
89
|
}
|
|
90
|
+
// Add context if provided
|
|
91
|
+
if (input.context) {
|
|
92
|
+
cmdArgs.push("--context", input.context);
|
|
93
|
+
}
|
|
92
94
|
// Execute the command
|
|
93
95
|
try {
|
|
94
96
|
console.error(`Executing: kubectl ${cmdArgs.join(" ")}`);
|
|
@@ -14,9 +14,9 @@ export declare const kubectlGetSchema: {
|
|
|
14
14
|
readonly description: "Name of the resource (optional - if not provided, lists all resources of the specified type)";
|
|
15
15
|
};
|
|
16
16
|
readonly namespace: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
type: "string";
|
|
18
|
+
description: string;
|
|
19
|
+
default: string;
|
|
20
20
|
};
|
|
21
21
|
readonly output: {
|
|
22
22
|
readonly type: "string";
|
|
@@ -41,6 +41,11 @@ export declare const kubectlGetSchema: {
|
|
|
41
41
|
readonly type: "string";
|
|
42
42
|
readonly description: "Sort events by a field (default: lastTimestamp). Only applicable for events.";
|
|
43
43
|
};
|
|
44
|
+
readonly context: {
|
|
45
|
+
type: "string";
|
|
46
|
+
description: string;
|
|
47
|
+
default: string;
|
|
48
|
+
};
|
|
44
49
|
};
|
|
45
50
|
readonly required: readonly ["resourceType", "name", "namespace"];
|
|
46
51
|
};
|
|
@@ -54,6 +59,7 @@ export declare function kubectlGet(k8sManager: KubernetesManager, input: {
|
|
|
54
59
|
labelSelector?: string;
|
|
55
60
|
fieldSelector?: string;
|
|
56
61
|
sortBy?: string;
|
|
62
|
+
context?: string;
|
|
57
63
|
}): Promise<{
|
|
58
64
|
content: {
|
|
59
65
|
type: string;
|
|
@@ -2,6 +2,7 @@ import { execFileSync } from "child_process";
|
|
|
2
2
|
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
|
|
3
3
|
import { getSpawnMaxBuffer } from "../config/max-buffer.js";
|
|
4
4
|
import * as yaml from "js-yaml";
|
|
5
|
+
import { contextParameter, namespaceParameter } from "../models/common-parameters.js";
|
|
5
6
|
export const kubectlGetSchema = {
|
|
6
7
|
name: "kubectl_get",
|
|
7
8
|
description: "Get or list Kubernetes resources by resource type, name, and optionally namespace",
|
|
@@ -16,11 +17,7 @@ export const kubectlGetSchema = {
|
|
|
16
17
|
type: "string",
|
|
17
18
|
description: "Name of the resource (optional - if not provided, lists all resources of the specified type)",
|
|
18
19
|
},
|
|
19
|
-
namespace:
|
|
20
|
-
type: "string",
|
|
21
|
-
description: "Namespace of the resource (optional - defaults to 'default' for namespaced resources)",
|
|
22
|
-
default: "default",
|
|
23
|
-
},
|
|
20
|
+
namespace: namespaceParameter,
|
|
24
21
|
output: {
|
|
25
22
|
type: "string",
|
|
26
23
|
enum: ["json", "yaml", "wide", "name", "custom"],
|
|
@@ -44,6 +41,7 @@ export const kubectlGetSchema = {
|
|
|
44
41
|
type: "string",
|
|
45
42
|
description: "Sort events by a field (default: lastTimestamp). Only applicable for events.",
|
|
46
43
|
},
|
|
44
|
+
context: contextParameter
|
|
47
45
|
},
|
|
48
46
|
required: ["resourceType", "name", "namespace"],
|
|
49
47
|
},
|
|
@@ -58,6 +56,7 @@ export async function kubectlGet(k8sManager, input) {
|
|
|
58
56
|
const labelSelector = input.labelSelector || "";
|
|
59
57
|
const fieldSelector = input.fieldSelector || "";
|
|
60
58
|
const sortBy = input.sortBy;
|
|
59
|
+
const context = input.context || "";
|
|
61
60
|
// Build the kubectl command
|
|
62
61
|
const command = "kubectl";
|
|
63
62
|
const args = ["get", resourceType];
|
|
@@ -78,6 +77,9 @@ export async function kubectlGet(k8sManager, input) {
|
|
|
78
77
|
else if (namespace && !isNonNamespacedResource(resourceType)) {
|
|
79
78
|
args.push("-n", namespace);
|
|
80
79
|
}
|
|
80
|
+
if (context) {
|
|
81
|
+
args.push("--context", context);
|
|
82
|
+
}
|
|
81
83
|
// Add label selector if provided
|
|
82
84
|
if (labelSelector) {
|
|
83
85
|
args.push("-l", labelSelector);
|
|
@@ -15,9 +15,9 @@ export declare const kubectlLogsSchema: {
|
|
|
15
15
|
readonly description: "Name of the resource";
|
|
16
16
|
};
|
|
17
17
|
readonly namespace: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
type: "string";
|
|
19
|
+
description: string;
|
|
20
|
+
default: string;
|
|
21
21
|
};
|
|
22
22
|
readonly container: {
|
|
23
23
|
readonly type: "string";
|
|
@@ -54,6 +54,11 @@ export declare const kubectlLogsSchema: {
|
|
|
54
54
|
readonly type: "string";
|
|
55
55
|
readonly description: "Filter resources by label selector";
|
|
56
56
|
};
|
|
57
|
+
readonly context: {
|
|
58
|
+
type: "string";
|
|
59
|
+
description: string;
|
|
60
|
+
default: string;
|
|
61
|
+
};
|
|
57
62
|
};
|
|
58
63
|
readonly required: readonly ["resourceType", "name", "namespace"];
|
|
59
64
|
};
|
|
@@ -70,6 +75,7 @@ export declare function kubectlLogs(k8sManager: KubernetesManager, input: {
|
|
|
70
75
|
previous?: boolean;
|
|
71
76
|
follow?: boolean;
|
|
72
77
|
labelSelector?: string;
|
|
78
|
+
context?: string;
|
|
73
79
|
}): Promise<{
|
|
74
80
|
content: {
|
|
75
81
|
type: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { execFileSync } from "child_process";
|
|
2
2
|
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
|
|
3
3
|
import { getSpawnMaxBuffer } from "../config/max-buffer.js";
|
|
4
|
+
import { contextParameter, namespaceParameter } from "../models/common-parameters.js";
|
|
4
5
|
export const kubectlLogsSchema = {
|
|
5
6
|
name: "kubectl_logs",
|
|
6
7
|
description: "Get logs from Kubernetes resources like pods, deployments, or jobs",
|
|
@@ -16,11 +17,7 @@ export const kubectlLogsSchema = {
|
|
|
16
17
|
type: "string",
|
|
17
18
|
description: "Name of the resource",
|
|
18
19
|
},
|
|
19
|
-
namespace:
|
|
20
|
-
type: "string",
|
|
21
|
-
description: "Namespace of the resource",
|
|
22
|
-
default: "default",
|
|
23
|
-
},
|
|
20
|
+
namespace: namespaceParameter,
|
|
24
21
|
container: {
|
|
25
22
|
type: "string",
|
|
26
23
|
description: "Container name (required when pod has multiple containers)",
|
|
@@ -56,6 +53,7 @@ export const kubectlLogsSchema = {
|
|
|
56
53
|
type: "string",
|
|
57
54
|
description: "Filter resources by label selector",
|
|
58
55
|
},
|
|
56
|
+
context: contextParameter,
|
|
59
57
|
},
|
|
60
58
|
required: ["resourceType", "name", "namespace"],
|
|
61
59
|
},
|
|
@@ -65,6 +63,7 @@ export async function kubectlLogs(k8sManager, input) {
|
|
|
65
63
|
const resourceType = input.resourceType.toLowerCase();
|
|
66
64
|
const name = input.name;
|
|
67
65
|
const namespace = input.namespace || "default";
|
|
66
|
+
const context = input.context || "";
|
|
68
67
|
const command = "kubectl";
|
|
69
68
|
// Handle different resource types
|
|
70
69
|
if (resourceType === "pod") {
|
|
@@ -76,6 +75,10 @@ export async function kubectlLogs(k8sManager, input) {
|
|
|
76
75
|
}
|
|
77
76
|
// Add options
|
|
78
77
|
args = addLogOptions(args, input);
|
|
78
|
+
// Add context if provided
|
|
79
|
+
if (context) {
|
|
80
|
+
args.push("--context", context);
|
|
81
|
+
}
|
|
79
82
|
// Execute the command
|
|
80
83
|
try {
|
|
81
84
|
const result = execFileSync(command, args, {
|
|
@@ -235,6 +238,9 @@ function addLogOptions(args, input) {
|
|
|
235
238
|
if (input.follow) {
|
|
236
239
|
args.push(`--follow`);
|
|
237
240
|
}
|
|
241
|
+
if (input.context) {
|
|
242
|
+
args.push("--context", input.context);
|
|
243
|
+
}
|
|
238
244
|
return args;
|
|
239
245
|
}
|
|
240
246
|
// Helper function to get logs for resources selected by labels
|
|
@@ -18,6 +18,11 @@ export declare const explainResourceSchema: {
|
|
|
18
18
|
description: string;
|
|
19
19
|
default: boolean;
|
|
20
20
|
};
|
|
21
|
+
context: {
|
|
22
|
+
type: "string";
|
|
23
|
+
description: string;
|
|
24
|
+
default: string;
|
|
25
|
+
};
|
|
21
26
|
output: {
|
|
22
27
|
type: string;
|
|
23
28
|
description: string;
|
|
@@ -42,6 +47,11 @@ export declare const listApiResourcesSchema: {
|
|
|
42
47
|
type: string;
|
|
43
48
|
description: string;
|
|
44
49
|
};
|
|
50
|
+
context: {
|
|
51
|
+
type: string;
|
|
52
|
+
description: string;
|
|
53
|
+
default: string;
|
|
54
|
+
};
|
|
45
55
|
verbs: {
|
|
46
56
|
type: string;
|
|
47
57
|
items: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execFileSync } from "child_process";
|
|
2
2
|
import { getSpawnMaxBuffer } from "../config/max-buffer.js";
|
|
3
|
+
import { contextParameter } from "../models/common-parameters.js";
|
|
3
4
|
export const explainResourceSchema = {
|
|
4
5
|
name: "explain_resource",
|
|
5
6
|
description: "Get documentation for a Kubernetes resource or field",
|
|
@@ -19,6 +20,7 @@ export const explainResourceSchema = {
|
|
|
19
20
|
description: "Print the fields of fields recursively",
|
|
20
21
|
default: false,
|
|
21
22
|
},
|
|
23
|
+
context: contextParameter,
|
|
22
24
|
output: {
|
|
23
25
|
type: "string",
|
|
24
26
|
description: "Output format (plaintext or plaintext-openapiv2)",
|
|
@@ -43,6 +45,11 @@ export const listApiResourcesSchema = {
|
|
|
43
45
|
type: "boolean",
|
|
44
46
|
description: "If true, only show namespaced resources",
|
|
45
47
|
},
|
|
48
|
+
context: {
|
|
49
|
+
type: "string",
|
|
50
|
+
description: "Kubeconfig Context to use for the command (optional - defaults to null)",
|
|
51
|
+
default: "",
|
|
52
|
+
},
|
|
46
53
|
verbs: {
|
|
47
54
|
type: "array",
|
|
48
55
|
items: {
|
|
@@ -81,6 +88,9 @@ export async function explainResource(params) {
|
|
|
81
88
|
if (params.recursive) {
|
|
82
89
|
args.push("--recursive");
|
|
83
90
|
}
|
|
91
|
+
if (params.context) {
|
|
92
|
+
args.push("--context", params.context);
|
|
93
|
+
}
|
|
84
94
|
if (params.output) {
|
|
85
95
|
args.push(`--output=${params.output}`);
|
|
86
96
|
}
|
|
@@ -115,6 +125,9 @@ export async function listApiResources(params) {
|
|
|
115
125
|
if (params.output) {
|
|
116
126
|
args.push(`-o`, params.output);
|
|
117
127
|
}
|
|
128
|
+
if (params.context) {
|
|
129
|
+
args.push("--context", params.context);
|
|
130
|
+
}
|
|
118
131
|
const result = executeKubectlCommand(command, args);
|
|
119
132
|
return {
|
|
120
133
|
content: [
|
|
@@ -14,7 +14,7 @@ export declare const kubectlPatchSchema: {
|
|
|
14
14
|
description: string;
|
|
15
15
|
};
|
|
16
16
|
namespace: {
|
|
17
|
-
type: string;
|
|
17
|
+
type: "string";
|
|
18
18
|
description: string;
|
|
19
19
|
default: string;
|
|
20
20
|
};
|
|
@@ -33,10 +33,15 @@ export declare const kubectlPatchSchema: {
|
|
|
33
33
|
description: string;
|
|
34
34
|
};
|
|
35
35
|
dryRun: {
|
|
36
|
-
type:
|
|
36
|
+
type: "boolean";
|
|
37
37
|
description: string;
|
|
38
38
|
default: boolean;
|
|
39
39
|
};
|
|
40
|
+
context: {
|
|
41
|
+
type: "string";
|
|
42
|
+
description: string;
|
|
43
|
+
default: string;
|
|
44
|
+
};
|
|
40
45
|
};
|
|
41
46
|
required: string[];
|
|
42
47
|
};
|
|
@@ -49,6 +54,7 @@ export declare function kubectlPatch(k8sManager: KubernetesManager, input: {
|
|
|
49
54
|
patchData?: object;
|
|
50
55
|
patchFile?: string;
|
|
51
56
|
dryRun?: boolean;
|
|
57
|
+
context?: string;
|
|
52
58
|
}): Promise<{
|
|
53
59
|
content: {
|
|
54
60
|
type: string;
|
|
@@ -4,6 +4,7 @@ import * as fs from "fs";
|
|
|
4
4
|
import * as path from "path";
|
|
5
5
|
import * as os from "os";
|
|
6
6
|
import { getSpawnMaxBuffer } from "../config/max-buffer.js";
|
|
7
|
+
import { contextParameter, dryRunParameter, namespaceParameter } from "../models/common-parameters.js";
|
|
7
8
|
export const kubectlPatchSchema = {
|
|
8
9
|
name: "kubectl_patch",
|
|
9
10
|
description: "Update field(s) of a resource using strategic merge patch, JSON merge patch, or JSON patch",
|
|
@@ -18,11 +19,7 @@ export const kubectlPatchSchema = {
|
|
|
18
19
|
type: "string",
|
|
19
20
|
description: "Name of the resource to patch",
|
|
20
21
|
},
|
|
21
|
-
namespace:
|
|
22
|
-
type: "string",
|
|
23
|
-
description: "Namespace of the resource",
|
|
24
|
-
default: "default",
|
|
25
|
-
},
|
|
22
|
+
namespace: namespaceParameter,
|
|
26
23
|
patchType: {
|
|
27
24
|
type: "string",
|
|
28
25
|
description: "Type of patch to apply",
|
|
@@ -37,11 +34,8 @@ export const kubectlPatchSchema = {
|
|
|
37
34
|
type: "string",
|
|
38
35
|
description: "Path to a file containing the patch data (alternative to patchData)",
|
|
39
36
|
},
|
|
40
|
-
dryRun:
|
|
41
|
-
|
|
42
|
-
description: "If true, only print the object that would be sent, without sending it",
|
|
43
|
-
default: false,
|
|
44
|
-
},
|
|
37
|
+
dryRun: dryRunParameter,
|
|
38
|
+
context: contextParameter,
|
|
45
39
|
},
|
|
46
40
|
required: ["resourceType", "name"],
|
|
47
41
|
},
|
|
@@ -54,6 +48,7 @@ export async function kubectlPatch(k8sManager, input) {
|
|
|
54
48
|
const namespace = input.namespace || "default";
|
|
55
49
|
const patchType = input.patchType || "strategic";
|
|
56
50
|
const dryRun = input.dryRun || false;
|
|
51
|
+
const context = input.context || "";
|
|
57
52
|
let tempFile = null;
|
|
58
53
|
const command = "kubectl";
|
|
59
54
|
const args = ["patch", input.resourceType, input.name, "-n", namespace];
|
|
@@ -86,6 +81,10 @@ export async function kubectlPatch(k8sManager, input) {
|
|
|
86
81
|
if (dryRun) {
|
|
87
82
|
args.push("--dry-run=client");
|
|
88
83
|
}
|
|
84
|
+
// Add context if provided
|
|
85
|
+
if (context) {
|
|
86
|
+
args.push("--context", context);
|
|
87
|
+
}
|
|
89
88
|
// Execute the command
|
|
90
89
|
try {
|
|
91
90
|
const result = execFileSync(command, args, {
|
|
@@ -22,7 +22,7 @@ export declare const kubectlRolloutSchema: {
|
|
|
22
22
|
description: string;
|
|
23
23
|
};
|
|
24
24
|
namespace: {
|
|
25
|
-
type: string;
|
|
25
|
+
type: "string";
|
|
26
26
|
description: string;
|
|
27
27
|
default: string;
|
|
28
28
|
};
|
|
@@ -43,6 +43,11 @@ export declare const kubectlRolloutSchema: {
|
|
|
43
43
|
description: string;
|
|
44
44
|
default: boolean;
|
|
45
45
|
};
|
|
46
|
+
context: {
|
|
47
|
+
type: "string";
|
|
48
|
+
description: string;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
46
51
|
};
|
|
47
52
|
required: string[];
|
|
48
53
|
};
|
|
@@ -56,6 +61,7 @@ export declare function kubectlRollout(k8sManager: KubernetesManager, input: {
|
|
|
56
61
|
toRevision?: number;
|
|
57
62
|
timeout?: string;
|
|
58
63
|
watch?: boolean;
|
|
64
|
+
context?: string;
|
|
59
65
|
}): Promise<{
|
|
60
66
|
content: {
|
|
61
67
|
type: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { execFileSync } from "child_process";
|
|
2
2
|
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
|
|
3
3
|
import { getSpawnMaxBuffer } from "../config/max-buffer.js";
|
|
4
|
+
import { contextParameter, namespaceParameter } from "../models/common-parameters.js";
|
|
4
5
|
export const kubectlRolloutSchema = {
|
|
5
6
|
name: "kubectl_rollout",
|
|
6
7
|
description: "Manage the rollout of a resource (e.g., deployment, daemonset, statefulset)",
|
|
@@ -23,11 +24,7 @@ export const kubectlRolloutSchema = {
|
|
|
23
24
|
type: "string",
|
|
24
25
|
description: "Name of the resource",
|
|
25
26
|
},
|
|
26
|
-
namespace:
|
|
27
|
-
type: "string",
|
|
28
|
-
description: "Namespace of the resource",
|
|
29
|
-
default: "default",
|
|
30
|
-
},
|
|
27
|
+
namespace: namespaceParameter,
|
|
31
28
|
revision: {
|
|
32
29
|
type: "number",
|
|
33
30
|
description: "Revision to rollback to (for undo subcommand)",
|
|
@@ -45,6 +42,7 @@ export const kubectlRolloutSchema = {
|
|
|
45
42
|
description: "Watch the rollout status in real-time until completion",
|
|
46
43
|
default: false,
|
|
47
44
|
},
|
|
45
|
+
context: contextParameter,
|
|
48
46
|
},
|
|
49
47
|
required: ["subCommand", "resourceType", "name", "namespace"],
|
|
50
48
|
},
|
|
@@ -53,6 +51,7 @@ export async function kubectlRollout(k8sManager, input) {
|
|
|
53
51
|
try {
|
|
54
52
|
const namespace = input.namespace || "default";
|
|
55
53
|
const watch = input.watch || false;
|
|
54
|
+
const context = input.context || "";
|
|
56
55
|
const command = "kubectl";
|
|
57
56
|
const args = [
|
|
58
57
|
"rollout",
|
|
@@ -73,6 +72,10 @@ export async function kubectlRollout(k8sManager, input) {
|
|
|
73
72
|
if (input.timeout) {
|
|
74
73
|
args.push(`--timeout=${input.timeout}`);
|
|
75
74
|
}
|
|
75
|
+
// Add context if provided
|
|
76
|
+
if (context) {
|
|
77
|
+
args.push("--context", context);
|
|
78
|
+
}
|
|
76
79
|
// Execute the command
|
|
77
80
|
try {
|
|
78
81
|
// For status command with watch flag, we need to handle it differently
|
|
@@ -10,7 +10,7 @@ export declare const kubectlScaleSchema: {
|
|
|
10
10
|
description: string;
|
|
11
11
|
};
|
|
12
12
|
namespace: {
|
|
13
|
-
type: string;
|
|
13
|
+
type: "string";
|
|
14
14
|
description: string;
|
|
15
15
|
default: string;
|
|
16
16
|
};
|
|
@@ -23,6 +23,11 @@ export declare const kubectlScaleSchema: {
|
|
|
23
23
|
description: string;
|
|
24
24
|
default: string;
|
|
25
25
|
};
|
|
26
|
+
context: {
|
|
27
|
+
type: "string";
|
|
28
|
+
description: string;
|
|
29
|
+
default: string;
|
|
30
|
+
};
|
|
26
31
|
};
|
|
27
32
|
required: string[];
|
|
28
33
|
};
|
|
@@ -32,6 +37,7 @@ export declare function kubectlScale(k8sManager: KubernetesManager, input: {
|
|
|
32
37
|
namespace?: string;
|
|
33
38
|
replicas: number;
|
|
34
39
|
resourceType?: string;
|
|
40
|
+
context?: string;
|
|
35
41
|
}): Promise<{
|
|
36
42
|
content: {
|
|
37
43
|
success: boolean;
|