containers / containers/kubernetes-mcp-server
Added port forwarding tool for any resource type
- 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:


Contributor 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