mcp-server-kubernetes 3.4.0 → 3.5.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.
|
@@ -419,24 +419,24 @@ export declare const GetJobLogsResponseSchema: z.ZodObject<{
|
|
|
419
419
|
}>;
|
|
420
420
|
export declare const PortForwardResponseSchema: z.ZodObject<{
|
|
421
421
|
content: z.ZodArray<z.ZodObject<{
|
|
422
|
-
|
|
423
|
-
|
|
422
|
+
type: z.ZodLiteral<"text">;
|
|
423
|
+
text: z.ZodString;
|
|
424
424
|
}, "strip", z.ZodTypeAny, {
|
|
425
|
-
|
|
426
|
-
|
|
425
|
+
type: "text";
|
|
426
|
+
text: string;
|
|
427
427
|
}, {
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
type: "text";
|
|
429
|
+
text: string;
|
|
430
430
|
}>, "many">;
|
|
431
431
|
}, "strip", z.ZodTypeAny, {
|
|
432
432
|
content: {
|
|
433
|
-
|
|
434
|
-
|
|
433
|
+
type: "text";
|
|
434
|
+
text: string;
|
|
435
435
|
}[];
|
|
436
436
|
}, {
|
|
437
437
|
content: {
|
|
438
|
-
|
|
439
|
-
|
|
438
|
+
type: "text";
|
|
439
|
+
text: string;
|
|
440
440
|
}[];
|
|
441
441
|
}>;
|
|
442
442
|
export declare const ScaleDeploymentResponseSchema: z.ZodObject<{
|
|
@@ -62,10 +62,7 @@ export const GetJobLogsResponseSchema = z.object({
|
|
|
62
62
|
content: z.array(ToolResponseContent),
|
|
63
63
|
});
|
|
64
64
|
export const PortForwardResponseSchema = z.object({
|
|
65
|
-
content: z.array(
|
|
66
|
-
success: z.boolean(),
|
|
67
|
-
message: z.string(),
|
|
68
|
-
})),
|
|
65
|
+
content: z.array(ToolResponseContent),
|
|
69
66
|
});
|
|
70
67
|
export const ScaleDeploymentResponseSchema = z.object({
|
|
71
68
|
content: z.array(z.object({
|
|
@@ -35,8 +35,8 @@ export declare function startPortForward(k8sManager: KubernetesManager, input: {
|
|
|
35
35
|
namespace?: string;
|
|
36
36
|
}): Promise<{
|
|
37
37
|
content: {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
type: "text";
|
|
39
|
+
text: string;
|
|
40
40
|
}[];
|
|
41
41
|
}>;
|
|
42
42
|
export declare const StopPortForwardSchema: {
|
|
@@ -59,7 +59,7 @@ export declare function stopPortForward(k8sManager: KubernetesManager, input: {
|
|
|
59
59
|
id: string;
|
|
60
60
|
}): Promise<{
|
|
61
61
|
content: {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
type: "text";
|
|
63
|
+
text: string;
|
|
64
64
|
}[];
|
|
65
65
|
}>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { spawn } from "child_process";
|
|
2
2
|
// Use spawn instead of exec because port-forward is a long-running process
|
|
3
|
-
async function
|
|
3
|
+
async function executePortForward(args) {
|
|
4
4
|
return new Promise((resolve, reject) => {
|
|
5
|
-
const
|
|
6
|
-
const process = spawn(cmd, args);
|
|
5
|
+
const process = spawn("kubectl", args);
|
|
7
6
|
let output = "";
|
|
8
7
|
let errorOutput = "";
|
|
9
8
|
process.stdout.on("data", (data) => {
|
|
@@ -54,13 +53,14 @@ export const PortForwardSchema = {
|
|
|
54
53
|
},
|
|
55
54
|
};
|
|
56
55
|
export async function startPortForward(k8sManager, input) {
|
|
57
|
-
|
|
56
|
+
const args = ["port-forward"];
|
|
58
57
|
if (input.namespace) {
|
|
59
|
-
|
|
58
|
+
args.push("-n", input.namespace);
|
|
60
59
|
}
|
|
61
|
-
|
|
60
|
+
args.push(`${input.resourceType}/${input.resourceName}`);
|
|
61
|
+
args.push(`${input.localPort}:${input.targetPort}`);
|
|
62
62
|
try {
|
|
63
|
-
const result = await
|
|
63
|
+
const result = await executePortForward(args);
|
|
64
64
|
// Track the port-forward process
|
|
65
65
|
k8sManager.trackPortForward({
|
|
66
66
|
id: `${input.resourceType}-${input.resourceName}-${input.localPort}`,
|
|
@@ -80,7 +80,15 @@ export async function startPortForward(k8sManager, input) {
|
|
|
80
80
|
ports: [{ local: input.localPort, remote: input.targetPort }],
|
|
81
81
|
});
|
|
82
82
|
return {
|
|
83
|
-
content: [
|
|
83
|
+
content: [
|
|
84
|
+
{
|
|
85
|
+
type: "text",
|
|
86
|
+
text: JSON.stringify({
|
|
87
|
+
success: result.success,
|
|
88
|
+
message: result.message,
|
|
89
|
+
}),
|
|
90
|
+
},
|
|
91
|
+
],
|
|
84
92
|
};
|
|
85
93
|
}
|
|
86
94
|
catch (error) {
|
|
@@ -111,7 +119,13 @@ export async function stopPortForward(k8sManager, input) {
|
|
|
111
119
|
k8sManager.removePortForward(input.id);
|
|
112
120
|
return {
|
|
113
121
|
content: [
|
|
114
|
-
{
|
|
122
|
+
{
|
|
123
|
+
type: "text",
|
|
124
|
+
text: JSON.stringify({
|
|
125
|
+
success: true,
|
|
126
|
+
message: "port-forward stopped successfully",
|
|
127
|
+
}),
|
|
128
|
+
},
|
|
115
129
|
],
|
|
116
130
|
};
|
|
117
131
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-server-kubernetes",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.1",
|
|
4
4
|
"description": "MCP server for interacting with Kubernetes clusters via kubectl",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@opentelemetry/semantic-conventions": "^1.39.0",
|
|
48
48
|
"express": "4.21.2",
|
|
49
49
|
"js-yaml": "4.1.1",
|
|
50
|
-
"yaml": "2.
|
|
50
|
+
"yaml": "2.8.3",
|
|
51
51
|
"zod": "3.25.76"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|