Repository navigation
feat: node shell + pod exec tools, k8s_raw safe defaults; drop runtime server add/remove - #1
Merged
Merged
Conversation
…r add/remove
US1: remove rancher_servers_add/rancher_servers_remove (env-only config).
US2: rancher_node_shell — one-shot command on a node via Rancher Steve shell
(links.shell on CAPI Machine; WS base64.channel.k8s.io; START/RC markers;
subshell + PTY echo/banner stripping). Gated by ENABLE_NODE_SHELL.
US3: k8s_raw safe defaults — mutating methods blocked unless allowWrite: true;
Secret data/stringData masked unless showSensitiveData: true (per-call,
no restart; handles SecretList items without kind).
US4: k8s_exec — one-shot pod exec via Rancher WS proxy (v5/v4 channel
protocol; exit code from channel-3 metav1.Status). Gated by
ENABLE_CONTAINER_EXEC.
Tests: +55 (254 total) — frames/markers/security/flags; live-verified on
dandelion (node shell, pod exec, k8s_raw security 7/7).
- README: tools overview (no add/remove; node shell + k8s_exec opt-in via ENABLE_NODE_SHELL / ENABLE_CONTAINER_EXEC), k8s_raw per-call allowWrite / showSensitiveData defaults. - env.example: the two opt-in flags with usage notes. - package.json: 0.1.16 -> 0.1.17 (patch).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four changes to the MCP server:
rancher_servers_add/rancher_servers_removeare removed: servers are configured via environment variables only (RANCHER_SERVER_<ID>_<PROP>/RANCHER_SERVERS), and the in-memory store was never persisted.rancher_servers_liststays.rancher_node_shell(opt-in:ENABLE_NODE_SHELL=true): run one non-interactive command on a node provisioned via a Rancher node driver. The Rancher server dials SSH to the node and proxies the session over a WebSocket (Stevelinks.shellon the CAPI Machine); the MCP host needs no network path to the node and no SSH keys. Returns stdout + exit code.k8s_raw(per-call opt-in, no restart):POST/PUT/PATCH/DELETE) are blocked unless the call passesallowWrite: true;Secretdata/stringDatavalues are masked as***(single objects and lists) unless the call passesshowSensitiveData: true.k8s_exec(opt-in:ENABLE_CONTAINER_EXEC=true): run one non-interactive command in a pod container through the Rancher Kubernetes proxy (WebSocket exec,v5.channel.k8s.io→v4); no kubeconfig or externalkubectlneeded. Returns stdout, stderr and exit code.Why
k8s_rawwas "DANGEROUS" with no floor: accidental mutations and Secret leakage were one typo away.rancher_clusters_kubeconfig+ a localkubectl.Safety
tools/listunless explicitly enabled (restart required).k8s_rawwrite access and Secret masking are per-call (allowWrite/showSensitiveData), so no restart is needed to opt in for a single call.Authorizationheader on the WS handshake; error messages never include tokens.Testing
SecretListshape without itemkind), and flag gating.npm run lint+npm run buildclean.dandelion):tools/list: 17 tools by default, 19 with both flags;servers_add/removegone.rancher_node_shell:hostname→ exit 0, correct stdout, 0.3–0.9 s; negatives (unknown node, no-shell node, timeout) return clear errors.k8s_exec:hostname→ exit 0;sh -c 'exit 3'→ 3; distroless container/404/missing container → clear errors; timeout works.k8s_raw: masked by default, unmasked per-call, mutation blocked (object unchanged), server stays healthy.Notes
0.1.16 → 0.1.17(patch). Publishing to npm is intentionally not part of this PR.stderris merged into stdout (PTY). Pod exec has separate stdout/stderr channels.rancher/rancher#52003(WS ping-pong with very large streams) — negligible for one-shot commands.