mcp-server-kubernetes 3.9.2 → 4.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.
|
@@ -29,6 +29,11 @@ export declare const kubectlGenericSchema: {
|
|
|
29
29
|
description: string;
|
|
30
30
|
default: string;
|
|
31
31
|
};
|
|
32
|
+
allNamespaces: {
|
|
33
|
+
type: string;
|
|
34
|
+
description: string;
|
|
35
|
+
default: boolean;
|
|
36
|
+
};
|
|
32
37
|
outputFormat: {
|
|
33
38
|
type: string;
|
|
34
39
|
description: string;
|
|
@@ -61,6 +66,7 @@ export declare function kubectlGeneric(k8sManager: KubernetesManager, input: {
|
|
|
61
66
|
resourceType?: string;
|
|
62
67
|
name?: string;
|
|
63
68
|
namespace?: string;
|
|
69
|
+
allNamespaces?: boolean;
|
|
64
70
|
outputFormat?: string;
|
|
65
71
|
flags?: Record<string, any>;
|
|
66
72
|
args?: string[];
|
|
@@ -29,6 +29,11 @@ export const kubectlGenericSchema = {
|
|
|
29
29
|
description: "Resource name",
|
|
30
30
|
},
|
|
31
31
|
namespace: namespaceParameter,
|
|
32
|
+
allNamespaces: {
|
|
33
|
+
type: "boolean",
|
|
34
|
+
description: "If true, run the command across all namespaces",
|
|
35
|
+
default: false,
|
|
36
|
+
},
|
|
32
37
|
outputFormat: {
|
|
33
38
|
type: "string",
|
|
34
39
|
description: "Output format (e.g. json, yaml, wide)",
|
|
@@ -69,8 +74,12 @@ export async function kubectlGeneric(k8sManager, input) {
|
|
|
69
74
|
if (input.name) {
|
|
70
75
|
cmdArgs.push(input.name);
|
|
71
76
|
}
|
|
72
|
-
// Add namespace
|
|
73
|
-
|
|
77
|
+
// Add namespace scoping: --all-namespaces takes precedence over a
|
|
78
|
+
// specific namespace (kubectl rejects using both together)
|
|
79
|
+
if (input.allNamespaces) {
|
|
80
|
+
cmdArgs.push("--all-namespaces");
|
|
81
|
+
}
|
|
82
|
+
else if (input.namespace) {
|
|
74
83
|
cmdArgs.push(`--namespace=${input.namespace}`);
|
|
75
84
|
}
|
|
76
85
|
// Add output format if provided
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { spawn } from "child_process";
|
|
2
|
+
import { McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { assertSafeArgv } from "../security/kubectl-flags.js";
|
|
2
4
|
// Use spawn instead of exec because port-forward is a long-running process
|
|
3
5
|
async function executePortForward(args) {
|
|
6
|
+
// port_forward uses spawn (long-running process) rather than the shared
|
|
7
|
+
// execFileSyncSafe wrapper, so it must run the argv guard itself. Otherwise
|
|
8
|
+
// user-supplied values pushed into positional slots (e.g. resourceType) can
|
|
9
|
+
// smuggle credential/target-redirecting flags such as --server.
|
|
10
|
+
assertSafeArgv(args);
|
|
4
11
|
return new Promise((resolve, reject) => {
|
|
5
12
|
const process = spawn("kubectl", args);
|
|
6
13
|
let output = "";
|
|
@@ -92,6 +99,10 @@ export async function startPortForward(k8sManager, input) {
|
|
|
92
99
|
};
|
|
93
100
|
}
|
|
94
101
|
catch (error) {
|
|
102
|
+
// Preserve McpError (e.g. the argv safety guard's InvalidParams rejection)
|
|
103
|
+
// so the client sees the real reason instead of a generic InternalError.
|
|
104
|
+
if (error instanceof McpError)
|
|
105
|
+
throw error;
|
|
95
106
|
throw new Error(`Failed to execute port-forward: ${error.message}`);
|
|
96
107
|
}
|
|
97
108
|
}
|