
K8s Port Forward Mcp
io.github.oijusti由 GitHub 账号 oijusti 发布v0.0.8更新于 Oct 24, 2026
Kubernetes Port Forward — MCP Server: port-forward Kubernetes services with terminal integration
发布方自己的服务:Port
概览
本地 MCP 服务器,让助手发现 Kubernetes 服务并启动或停止 kubectl 端口转发会话,可选打开日志窗口。
- 可以做什么
- 列出命名空间与服务,按短名称和环境分组,可按命名空间过滤
- 一次调用为单个或多个服务启动端口转发,各自指定命名空间、环境、本地与远程端口
- 可选为每个服务打开跟随模式的 kubectl 日志窗口
- 停止由该服务器启动的所有端口转发
- 返回本地访问地址和实际执行的 kubectl 命令
- 适用场景
- 适合需要面向 Kubernetes 集群工作时,让助手自动找到正确的服务并打开本地端口,而不必手写 kubectl port-forward 命令。同时运行多个服务或在 dev、qa、stg、prod 环境间切换时尤其方便。
- 运行要求
- 以 stdio 方式在本地运行,通常通过 npx 启动。需要 Node.js 18 或更高版本、已安装并配置好集群访问权限的 kubectl,以及 VS Code、Cursor、Windsurf、Claude Desktop 或 Cline 等 MCP 客户端。未声明任何 API 密钥或环境变量。
安装
在 SourceWeft 中
- 打开 控制台中的 K8s Port Forward Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Kubernetes Port Forward MCP
A Model Context Protocol (MCP) server that provides tools for discovering Kubernetes services and running kubectl port-forward sessions (optionally with separate log windows). It is designed for MCP clients/LLMs that translate natural language into structured tool calls.
Kubernetes Port Forward MCP vs kubectl port-forward
This package provides an MCP interface on top of the standard kubectl workflow.
kubectl: Best when you already know exact namespace/pod/ports and prefer manual control.- MCP: Best when an agent should discover services and run one or many port-forwards via tool calls.
Key Features
- Service discovery: list namespaces and infer services (short name → environments → namespace) from running pods.
- Multi-service in one session: start multiple port-forwards with one tool call.
- LLM-friendly API:
start_k8s_port_forwardaccepts an array so each service can use differentnamespace,environment,localPort, andremotePort. - Optional logs: open
kubectl logs -fin a separate OS-level terminal window per service.
Table of Contents
- Requirements
- Quick Start
- Getting Started
- Examples
- Tools
- Output and Logs
- Configuration
- Validation and Debugging
Requirements
- Node.js 18 or newer
kubectlinstalled and configured with access to your cluster- VS Code, Cursor, Windsurf, Claude Desktop, Cline, or any other MCP client
Quick Start
- Add this server to your MCP client (use the config in Getting Started below).
- Ask your assistant: "List available Kubernetes services."
- Ask your assistant: "Run api service on local port 3002."
- Open the returned URL (for example
http://localhost:3002). - When finished, ask: "Stop all port-forwards."
Getting Started
First, install the Kubernetes Port Forward MCP server with your client.
Standard config works in most MCP clients:
[Install in VS Code] [Install in VS Code Insiders]
Amp
Add via the Amp VS Code extension settings screen or by updating your settings.json file:
Amp CLI Setup:
Add via the amp mcp add command below:
Antigravity
Add via the Antigravity settings or by updating your configuration file:
Claude Code
Use the Claude Code CLI to add the Kubernetes Port Forward MCP server:
Claude Desktop
Follow the MCP install guide, use the standard config above.
Cline
Follow the instruction in the section Configuring MCP Servers
Example: Local Setup
Add the following to your cline_mcp_settings.json file:
Codex
Use the Codex CLI to add the Kubernetes Port Forward MCP server:
Alternatively, create or edit the configuration file ~/.codex/config.toml and add:
For more information, see the Codex MCP documentation.
Copilot
Use the Copilot CLI to interactively add the Kubernetes Port Forward MCP server:
Alternatively, create or edit the configuration file ~/.copilot/mcp-config.json and add:
For more information, see the Copilot CLI documentation.
Cursor
Click the button to install:
Or install manually:
Go to Cursor Settings -> MCP -> Add new MCP Server. Name to your liking, use command type with the command npx -y k8s-port-forward-mcp@latest. You can also verify config or add command arguments via clicking Edit.
Factory
Use the Factory CLI to add the Kubernetes Port Forward MCP server:
Alternatively, type /mcp within Factory droid to open an interactive UI for managing MCP servers.
For more information, see the Factory MCP documentation.
Gemini CLI
Follow the MCP install guide, use the standard config above.
Goose
Click the button to install:
Or install manually:
Go to Advanced settings -> Extensions -> Add custom extension. Name to your liking, use type STDIO, and set the command to npx -y k8s-port-forward-mcp@latest. Click "Add Extension".
Kiro
Follow the MCP Servers documentation. For example in .kiro/settings/mcp.json:
LM Studio
Click the button to install:
[Add MCP Server k8s-port-forward to LM Studio]
Or install manually:
Go to Program in the right sidebar -> Install -> Edit mcp.json. Use the standard config above.
opencode
Follow the MCP Servers documentation. For example in ~/.config/opencode/opencode.json:
Qodo Gen
Open Qodo Gen chat panel in VSCode or IntelliJ -> Connect more tools -> + Add new MCP -> Paste the standard config above.
Click Save.
VS Code
Click the button to install:
[Install in VS Code] [Install in VS Code Insiders]
Or install manually:
Follow the MCP install guide, use the standard config above. You can also install the Kubernetes Port Forward MCP server using the VS Code CLI:
After installation, the Kubernetes Port Forward MCP server will be available for use with your GitHub Copilot agent in VS Code.
Warp
Go to Settings -> AI -> Manage MCP Servers -> + Add to add an MCP Server. Use the standard config above.
Alternatively, use the slash command /add-mcp in the Warp prompt and paste the standard config from above:
Windsurf
Follow Windsurf MCP documentation. Use the standard config above.
Examples
Quick reference (natural language → tool calls)
-
"Run api and auth services on local ports 3002, 3003"
→list_k8s_services({})thenstart_k8s_port_forward({ services: [{ serviceName: "api", localPort: 3002 }, { serviceName: "auth", localPort: 3003 }] }) -
"Run order service from shared services namespace in local port 3000"
→start_k8s_port_forward({ services: [{ serviceName: "order", namespace: "shared-services", localPort: 3000 }] }) -
"Run order service from shared services namespace and remote port 3000 in local port 3000"
→start_k8s_port_forward({ services: [{ serviceName: "order", namespace: "shared-services", localPort: 3000, remotePort: 3000 }] }) -
"Run api service in qa environment on local port 3001"
→start_k8s_port_forward({ services: [{ serviceName: "api", environment: "qa", localPort: 3001 }] }) -
"Run auth service in prod environment from production namespace on local port 3002"
→start_k8s_port_forward({ services: [{ serviceName: "auth", environment: "prod", namespace: "production", localPort: 3002 }] }) -
"Stop all port-forwards"
→stop_k8s_port_forward({})
Detailed workflow example
User: "Run the frontend service in qa on port 3001"
AI workflow:
- Call
list_k8s_services({})to find the exact service name. - Receive list containing e.g.
frontend: qa (ns: ...), dev (ns: ...). - Call
start_k8s_port_forward({ services: [{ serviceName: "frontend", environment: "qa", localPort: 3001 }] }). - Result: port-forwards run in the MCP server process; if
includeLogsis true, logs open in a separate window. The tool result includeshttp://localhost:3001and the exact kubectl commands.
Tools
Service discovery
-
list_k8s_namespaces
- Title: List namespaces
- Description: List all available Kubernetes namespaces.
- Parameters: None
- Read-only: true
-
list_k8s_services
- Title: List services
- Description: List available services grouped by short name and environment.
- Parameters:
namespace(string, optional): Filter results to a namespace.
- Read-only: true
Port forwarding
-
start_k8s_port_forward
- Title: Start port-forward
- Description: Start port-forwarding for one or more services.
- Parameters:
services(array, required): List of service configs.serviceName(string, required): Short name of the service. (Calllist_k8s_servicesfirst.)localPort(number, required): Local port to bind (1-65535).namespace(string, optional): Namespace to target.remotePort(number, optional): Remote (cluster) port.environment(string, optional):dev|qa|stg|prod.includeLogs(boolean, optional): Whether to open logs in a separate window (default: true).
- Read-only: false
-
stop_k8s_port_forward
- Title: Stop port-forward
- Description: Stop all active port-forward processes started by this MCP server.
- Parameters: None
- Read-only: false
Validation and Debugging
Since the MCP server spawns actual kubectl processes in the background, you may want to verify what's running and see the exact commands being executed.
Checking running kubectl processes
Windows (PowerShell):
Linux/macOS:
This helps you:
- Verify port-forwards are actually running
- See the exact namespaces and ports being used
- Identify stuck processes that might need manual termination
- Debug connectivity issues by examining the actual commands
Common failures and fixes
- Port already in use: choose another local port or stop the conflicting process.
- Connection refused: verify service name, namespace, and selected environment.
- No logs window: set
includeLogs: truein the port-forward request. - Stuck process: terminate by PID (
taskkill /PID <pid>on Windows,kill <pid>on Linux/macOS).
来源:README.md,提交 6e3529b
工具
0版本历史
1- v0.0.8最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
其他 Port 集成

Port
io.port官方发布者
Port 的远程 MCP 服务器将 Port.io 连接到 IDE、LLM 或智能体平台,让助手通过 OAuth 认证访问你的 Port.io 环境。

GravityPort
由 GitHub 账号 fengseekling-coder 发布
随 GravityPort 桌面应用附带的 MCP 服务器,让 Claude、Codex 等客户端搜索并记录本地的 AI 生成图片、视频与提示词库。

Worktrack Port
由 GitHub 账号 CloudCorpRecords 发布
通过 REST API 以 MCP 工具的形式访问 Jira 问题和 Confluence 页面。AI 翻译

Videohub Port
由 GitHub 账号 CloudCorpRecords 发布
将YouTube视频、频道、播放列表、评论和文字记录作为MCP工具。AI 翻译

Tasklist Port
由 GitHub 账号 CloudCorpRecords 发布
将Todoist的任务、项目、标签和分区作为MCP工具。AI 翻译