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);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states the action without disclosing critical behavioral traits. It doesn't mention that this executes commands directly in running containers (potentially destructive), requires appropriate permissions, may have security implications, or what output to expect (e.g., stdout/stderr). The description is minimal and misses important operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose with zero wasted words. It's appropriately sized for a straightforward execution tool and front-loads the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a command execution tool with no annotations and no output schema, the description is insufficient. It doesn't address the mutation nature of the operation, security requirements, expected output format, or error conditions. Given the complexity of executing commands in containers and the lack of structured metadata, more context is needed for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with all parameters clearly documented in the schema itself. The description adds no additional parameter semantics beyond what's already in the schema (e.g., it doesn't explain command syntax, namespace defaults, or container selection logic). This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Execute a command') and target ('in a pod container'), which is specific and unambiguous. It doesn't explicitly differentiate from sibling tools like 'run' or 'debug-pod', but the verb+resource combination is clear enough to understand the core function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'run' (for creating pods), 'debug-pod' (for troubleshooting), or 'get-logs' (for viewing output). There's no mention of prerequisites, typical use cases, or exclusions, leaving the agent to infer usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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