mcp-server-kubernetes 3.9.3 → 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.
|
@@ -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
|
}
|