Skip to main content
Glama

port-forward

Forward a Kubernetes service to a local port for direct access to cluster resources during development or debugging.

Instructions

Port forward a Kubernetes service to a local port

Input Schema

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

Implementation Reference

  • Handler implementation for the 'port-forward' tool. Extracts parameters, constructs and executes a 'kubectl port-forward' command for the specified service, and returns the output or a success message.
    case "port-forward": {
      const { service, namespace, localPort, targetPort } = args;
      const nsArg = namespace ? `-n ${namespace}` : "";
      const cmd = `kubectl port-forward svc/${service} ${localPort}:${targetPort} ${nsArg}`;
      const { stdout } = await execAsync(cmd);
      return {
        content: [{ 
          type: "text", 
          text: stdout || `Port-forwarding started for ${service}:${targetPort} -> localhost:${localPort}` 
        }]
      };
    }
  • Input schema definition for the 'port-forward' tool, specifying parameters for service name, namespace, local port, and target port.
      name: "port-forward",
      description: "Port forward a Kubernetes service to a local port",
      inputSchema: {
        type: "object",
        properties: {
          service: { 
            type: "string",
            description: "The name of the Kubernetes service to port-forward"
          },
          namespace: { 
            type: "string",
            description: "The namespace of the service (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 service"
          }
        },
        required: ["service", "localPort", "targetPort"]
      }
    },
  • server.js:1392-1394 (registration)
    Registration of the ListTools handler which returns the list of all tools including 'port-forward'.
    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 full burden for behavioral disclosure. It states what the tool does but doesn't explain important behavioral aspects: whether this creates a persistent or temporary connection, what happens when the command terminates, whether it requires specific permissions, if it blocks execution, or what side effects might occur. For a network operation tool, this leaves significant gaps in understanding its behavior.

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 states the core functionality without unnecessary words. It's appropriately sized for what it communicates and is front-loaded with the essential information. There's zero waste in the phrasing.

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 tool that performs network port forwarding (a potentially complex operation with side effects), the description is insufficiently complete. With no annotations, no output schema, and no behavioral context, users lack critical information about what the tool actually does beyond the basic concept. The presence of a sibling tool 'port-forward-pod' creates additional confusion that isn't addressed.

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 already documents all four parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema. It doesn't explain relationships between parameters (like how localPort and targetPort interact) or provide usage examples, so it meets the baseline but doesn't enhance parameter understanding.

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 ('port forward') and target ('a Kubernetes service to a local port'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from its sibling 'port-forward-pod', which appears to serve a similar function for pods rather than services, leaving some ambiguity about when to choose one over the other.

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. With a sibling tool named 'port-forward-pod' in the list, there's a clear need for differentiation that isn't addressed. No context about prerequisites, when-not-to-use scenarios, or comparison with other port-forwarding methods is provided.

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