UNPKG

mcp-server-kubernetes

Version:

MCP server for interacting with Kubernetes clusters via kubectl

82 lines (81 loc) 2.32 kB
/** * Tool: exec_in_pod * Execute a command in a Kubernetes pod or container and return the output. * Uses kubectl exec for consistency with other kubectl-based tools. * * SECURITY: Only accepts commands as an array of strings. This prevents command * injection attacks by using execFileSync which executes 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; annotations: { destructiveHint: boolean; }; 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 kubectl exec. * Returns the stdout output as a text response. * Throws McpError on failure. * * SECURITY: Command must be an array of strings. execFileSync does not invoke * a shell, 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; }[]; }>;