Skip to main content
Glama

port-forward-pod

Forward a Kubernetes pod's port to your local machine for direct access to containerized applications during development or debugging.

Instructions

Port forward a Kubernetes pod to a local port

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
podYesThe name of the Kubernetes pod to port-forward
namespaceNoThe namespace of the pod (optional, defaults to current context namespace)
localPortYesThe local port to forward to
targetPortYesThe target port on the pod

Implementation Reference

  • The handler logic for the 'port-forward-pod' tool. It destructures the input arguments, constructs a kubectl port-forward command for the specified pod (with optional namespace), executes it using execAsync, and returns the stdout or a success message in the MCP content format.
    case "port-forward-pod": {
      const { pod, namespace, localPort, targetPort } = args;
      const nsArg = namespace ? `-n ${namespace}` : "";
      const cmd = `kubectl port-forward pod/${pod} ${localPort}:${targetPort} ${nsArg}`;
      const { stdout } = await execAsync(cmd);
      return {
        content: [{ 
          type: "text", 
          text: stdout || `Port-forwarding started for ${pod}:${targetPort} -> localhost:${localPort}` 
        }]
      };
    }
  • The tool definition object for 'port-forward-pod', including its name, description, and input schema for validation. This object is part of the 'tools' array returned by the ListTools handler, effectively registering the tool.
    {
      name: "port-forward-pod",
      description: "Port forward a Kubernetes pod to a local port",
      inputSchema: {
        type: "object",
        properties: {
          pod: { 
            type: "string",
            description: "The name of the Kubernetes pod to port-forward"
          },
          namespace: { 
            type: "string",
            description: "The namespace of the pod (optional, defaults to current context namespace)"
          },
          localPort: { 
            type: "number",
            description: "The local port to forward to"
          },
          targetPort: { 
            type: "number",
            description: "The target port on the pod"
          }
        },
        required: ["pod", "localPort", "targetPort"]
      }
    },
  • server.js:1392-1394 (registration)
    The request handler for ListToolsRequestSchema that returns the full list of tools (including 'port-forward-pod'), which registers all tools with the MCP server.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return { tools };
    });
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action but doesn't describe what happens during execution (e.g., establishes a persistent tunnel, runs until interrupted, requires network access), potential side effects, or error conditions. For a network operation tool, this leaves critical behavioral aspects unspecified.

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 operation and is front-loaded with the core functionality.

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?

Given the complexity of a network tunneling operation with no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., success confirmation, tunnel details, error messages), runtime behavior, or interaction patterns. For a tool that establishes persistent connections, more contextual information is needed.

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%, so the schema fully documents all four parameters (pod, namespace, localPort, targetPort) with clear descriptions. The description adds no additional parameter semantics beyond what's in the schema, which is acceptable given the high coverage, resulting in the baseline score of 3.

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

Purpose5/5

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

The description clearly states the specific action ('port forward') and resource ('a Kubernetes pod to a local port'), distinguishing it from the sibling 'port-forward' tool (which likely forwards services or other resources). It uses precise technical terminology that unambiguously defines the tool's 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 the sibling 'port-forward' tool, nor does it mention prerequisites (e.g., requiring kubectl access, cluster connectivity) or typical use cases (e.g., debugging, local development). It lacks any context about when this specific pod-forwarding tool is appropriate.

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