Skip to main content
Glama

exec

Execute commands directly in Kubernetes pod containers to run diagnostics, perform maintenance, or troubleshoot applications within your cluster.

Instructions

Execute a command in a pod container

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
podYesThe name of the pod to execute in
commandYesThe command to execute
namespaceNoThe namespace of the pod (optional, defaults to current context namespace)
containerNoThe container name to execute in (if pod has multiple containers)

Implementation Reference

  • The handler for the 'exec' tool. It destructures the input arguments, builds a kubectl exec command with optional namespace and container flags, executes it using execAsync (promisified child_process.exec), and returns the stdout in the MCP response format.
    case "exec": { const { pod, command, namespace, container } = args; const nsArg = namespace ? `-n ${namespace}` : ""; const containerArg = container ? `-c ${container}` : ""; const cmd = `kubectl exec ${pod} ${nsArg} ${containerArg} -- ${command}`; const { stdout } = await execAsync(cmd); return { content: [{ type: "text", text: stdout || "Command executed" }] }; }
  • The JSON schema definition for the 'exec' tool, including name, description, and inputSchema with properties for pod, command, optional namespace and container, requiring pod and command.
    { name: "exec", description: "Execute a command in a pod container", inputSchema: { type: "object", properties: { pod: { type: "string", description: "The name of the pod to execute in" }, command: { type: "string", description: "The command to execute" }, namespace: { type: "string", description: "The namespace of the pod (optional, defaults to current context namespace)" }, container: { type: "string", description: "The container name to execute in (if pod has multiple containers)" } }, required: ["pod", "command"] } },
  • server.js:1392-1394 (registration)
    Registration via the ListToolsRequestHandler which returns the full list of tools including the 'exec' tool schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
  • server.js:7-7 (helper)
    Helper function execAsync created by promisifying Node.js child_process.exec, used by all tool handlers including 'exec' to run kubectl commands.
    const execAsync = promisify(exec);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/thekaranpargaie/kube-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server