containers / containers/kubernetes-mcp-server

Added port forwarding tool for any resource type

Open
#41 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.1k
Forks
437
Avg merge
2d 9h
Merged PRs (30d)
27

Description

The tool should accept the resource, but it should do port forwarding for the pod associated with that particular resource (finds pod name using resource_get , resource_list, pod_list_in_namespace etc)

## MCP tool:
`create_port_forward`: Creates a new port forwarding session
`cancel_port_forward`: Cancels an existing port forwarding session

## Creating a Port Forward
Input Parameters:
namespace: Kubernetes namespace (optional, uses default if not provided)
resource_name: Name of the resource to forward ports to (required)
api_version: API version of the resource (optional, auto-detected)
kind: Kind of the resource (required, currently only Pod supported)
ports: Port mapping in format "localPort[:remotePort]" (optional)

## Canceling a Port Forward
Input Parameters:
namespace: Kubernetes namespace
resource_name: Name of the resource

## Implementation
Use the `k8s.io/client-go/tools/portforward` package
Communicates with the Kubernetes API server using SPDY protocol

Example:
![Image](https://github.com/user-attachments/assets/c5c730a5-8d3a-45da-a797-b76c7154fa06)

![Image](https://github.com/user-attachments/assets/d9058b80-0762-4807-9252-3218b81c1958)

Contributor guide

Open the contributing guide

Research direction

Start by tracing the existing resource_get, resource_list, and pod_list_in_namespace entry points, then read the k8s.io/client-go/tools/portforward package and the current MCP tool registrations. Done means create_port_forward resolves the requested resource to its associated pod, supports the documented inputs, and cancel_port_forward reliably ends the session.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
api, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.