mcp-server-kubernetes
Version:
MCP server for interacting with Kubernetes clusters via kubectl
78 lines (77 loc) • 2.31 kB
TypeScript
/**
* Tool: exec_in_pod
* Execute a command in a Kubernetes pod or container and return the output.
* Uses the official Kubernetes client-node Exec API for native execution.
*
* SECURITY: Only accepts commands as an array of strings. This prevents command
* injection attacks by executing directly without shell interpretation.
* Shell operators (pipes, redirects, etc.) are intentionally not supported.
*/
import { KubernetesManager } from "../types.js";
/**
* Schema for exec_in_pod tool.
* - name: Pod name
* - namespace: Namespace (default: "default")
* - command: Command to execute as array of strings (e.g. ["ls", "-la"])
* - container: (Optional) Container name
*/
export declare const execInPodSchema: {
name: string;
description: string;
inputSchema: {
type: string;
properties: {
name: {
type: string;
description: string;
};
namespace: {
type: "string";
description: string;
default: string;
};
command: {
type: string;
items: {
type: string;
};
description: string;
};
container: {
type: string;
description: string;
};
timeout: {
type: string;
description: string;
};
context: {
type: "string";
description: string;
default: string;
};
};
required: string[];
};
};
/**
* Execute a command in a Kubernetes pod or container using the Kubernetes client-node Exec API.
* Returns the stdout output as a text response.
* Throws McpError on failure.
*
* SECURITY: Command must be an array of strings. This executes directly via the
* Kubernetes exec API without shell interpretation, preventing command injection.
*/
export declare function execInPod(k8sManager: KubernetesManager, input: {
name: string;
namespace?: string;
command: string[];
container?: string;
timeout?: number;
context?: string;
}): Promise<{
content: {
type: string;
text: string;
}[];
}>;