Fixes #825. Companion to #822, which fixed the same blind spot in zero mcp check.
/mcp worked out each server's state from the config file — disabled if you turned it off, enabled otherwise. But MCP registration is best-effort: a server that can't be reached gets recorded and startup carries on. So a server that never connected showed up as enabled, its tools quietly missing, and nothing in the panel said why.
Startup does know — it prints a warning per skipped server to stderr. That's gone by the time you notice, and /mcp is exactly where you go afterwards to ask what's actually running.
So the skipped set now reaches the panel, and a server that failed renders as failed with the reason under it:
› docs · failed · stdio
exec: "docs-mcp": executable file not found in $PATHTwo details worth calling out:
The reason comes from the server, so it goes through redaction.ErrorMessage before it's rendered. A handshake error that echoes the Authorization header back would otherwise print the bearer token straight into the transcript. There's a test for that.
Disabled wins over failed. If you turned a server off it was never expected to connect, and calling it failed would be misleading.
The stderr warning is unchanged — non-interactive users still get it, and the panel is an addition rather than a replacement.
Still not fixed, and out of scope here: enabling a server from inside the TUI updates the config but doesn't reconnect anything, so it'll show as enabled while not actually running until you restart. That's pre-existing and a bigger change; happy to file it separately if you'd like.
Verified with mutation testing — eight mutations across the state builder, the renderer, and both wiring points, all killed. TestAltScreenTranscriptScrollKeepsFooterFixed and TestBuildServeScopeKeepsLexicalPaths fail on my Windows box on clean main too (the second needs symlink privilege).
Summary by CodeRabbit
-
New Features
- MCP servers that fail to start now appear as failed in the
/mcppanel. - Failure reasons are shown in the panel and server details when available.
- Startup failures remain visible while the affected configuration is unchanged.
- MCP servers that fail to start now appear as failed in the
-
Bug Fixes
- MCP status now reflects actual startup results, including disabled servers.
- Failure messages and server targets redact credentials, remove unsafe formatting, and limit excessively long text.
- Server names and status matching remain consistent across configuration updates.
Activity
98🧹 Nitpick comments (1)
internal/cli/app_mcp_skipped_test.go (1)
63-66: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert that the failure reason is forwarded.
The test only verifies the server name. Also assert
MCPSkipped[0].Errcontains"connection refused"so a regression that drops the recorded error cannot pass.Proposed test strengthening
if len(launchedOptions.MCPSkipped) != 1 || - launchedOptions.MCPSkipped[0].Name != "docs" { + launchedOptions.MCPSkipped[0].Name != "docs" || + launchedOptions.MCPSkipped[0].Err == nil || + launchedOptions.MCPSkipped[0].Err.Error() != "connection refused" { t.Fatalf("MCPSkipped = %#v, want the failure startup recorded", launchedOptions.MCPSkipped) }As per coding guidelines, add a regression test for behavior changes.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/cli/app_mcp_skipped_test.go` around lines 63 - 66, Strengthen the existing MCPSkipped assertion in the test by also verifying that MCPSkipped[0].Err contains “connection refused,” while preserving the current server-name check and failure-count validation.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/cli/app_mcp_skipped_test.go`:
- Around line 63-66: Strengthen the existing MCPSkipped assertion in the test by
also verifying that MCPSkipped[0].Err contains “connection refused,” while
preserving the current server-name check and failure-count validation.ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6847c24c-e809-446d-80a2-a6db7325507d
📥 Commits
Reviewing files that changed from the base of the PR and between 097c2652cba22d929c598347aacc6f95591c9031 and be580766672c50aaf7da294cca87511bfcafa88e.
📒 Files selected for processing (8)
internal/cli/app.gointernal/cli/app_mcp_skipped_test.gointernal/tui/command_views.gointernal/tui/mcp_failed_state_test.gointernal/tui/mcp_state.gointernal/tui/mcp_view.gointernal/tui/model.gointernal/tui/options.go
Zero automated PR review
Verdict: No blockers found
Blockers
- None found.
Validation
- [pass] Diff hygiene:
git diff --check - [pass] Tests:
go test ./... - [pass] Build:
go run ./cmd/zero-release build - [pass] Smoke build:
go run ./cmd/zero-release smoke
Scope
Head: 3ac64cf84078
Changed files (54): internal/cli/app.go, internal/cli/app_mcp_skipped_test.go, internal/cli/mcp_config.go, internal/cli/mcp_identity_operations_test.go, internal/cli/mcp_server_identity_test.go, internal/cli/mcp_startup.go, internal/cli/mcp_write_collision_test.go, internal/mcp/config.go, internal/mcp/credential_fingerprint.go, internal/mcp/network_client.go, internal/mcp/oauth_secret_values_test.go, internal/mcp/oauth_store.go, and 42 more
This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality.
The failed-state wiring and secret redaction look good, but the new failure-reason rendering needs terminal sanitization before merge.
BuildMCPViewState passes redaction.ErrorMessage(err, ...) into MCPServerView.Error, and mcpManagerServerLines inserts that value directly into the rendered lines. Redaction removes credentials but does not remove ANSI/OSC sequences, other control characters, or embedded newlines. I reproduced this with an MCP error containing connection refused\x1b[2J\n› forged · enabled; the resulting server line retained both the escape sequence and newline unchanged. A server-controlled handshake error can therefore manipulate the terminal or forge extra /mcp rows.
Please normalize the displayed reason to safe single-line terminal text: strip ANSI/OSC and control characters, flatten CR/LF, apply a reasonable length cap, and add a regression covering escape and newline injection.
Everything else in the change looks correct, and the focused tests and CI are green.
@anandh8x fixed in c7421d9. You were right, and the reproduction was exact.
Before the fix the panel rendered your payload as:
› evil · failed · http
connection refused\x1b[2J
› forged · enabled
actions: zero mcp check evil | ...Escape sequence intact, forged row on its own line.
sanitizeTerminalReason now consumes escape sequences whole rather than dropping ESC alone, since stripping just the ESC leaves "[2J" printing as visible junk and an abandoned OSC payload can still smuggle a title-set or hyperlink. CSI runs to its final byte, OSC to BEL or ST. Newlines and tabs collapse to spaces so the reason stays on the one row the panel counted for it, other control bytes go, and it caps at 400 runes. Truncation is by rune so a multi-byte character never gets cut in half.
Two regressions, both of which fail on the previous commit: one asserts no escape byte survives, no line carries its own newline, the forged text never starts a row, and the real reason still shows. The other pushes 5000 characters through and asserts the line stays bounded.
Re-requesting you and @kevincodex1, since the push dismissed his approval.
One thing worth flagging beyond this PR: the same class exists at sidebar.go:668, where a failed plan task's raw child error is rendered without sanitizing. I found it reviewing #829 and it is unrelated to this change, but it is the same fix.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/tui/mcp_view.go`:
- Around line 192-238: Bound MCPServerView.Error before processing in the
sanitizer around the visible rune conversion and strings.Builder accumulation.
Verify whether Runtime.Skipped() already imposes a strict size limit; if not,
limit the raw input before converting to []rune and stop accumulating once the
maxMCPReasonLen display budget is reached, while preserving ANSI stripping,
whitespace normalization, and truncation behavior.🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 63dc33b5-a906-45b6-b233-5fc22f09514c
📥 Commits
Reviewing files that changed from the base of the PR and between be580766672c50aaf7da294cca87511bfcafa88e and c7421d97955224a7e024efbfdabe6bb0db6686d0.
📒 Files selected for processing (2)
internal/tui/mcp_failed_state_test.gointernal/tui/mcp_view.go
Pushed one more commit for the bot's finding, which was real. The 400 rune cap ran at the end, so the sanitizer walked the whole server string first, and escape sequences get consumed without producing output. 64KB of \x1b[2J was walked in full and the text after it still rendered. Nothing upstream bounds the handshake error and the panel re-runs this every redraw, so the input is now capped at 16KB before the walk, with a trim so a split character never shows up as a replacement glyph.
The bot's other claim on #866 (duplicate alwaysPromptingTool declaration) is wrong, there is only one.
@jatmn this push dismissed your approval, sorry. #1193 landed with an overlapping change to httpStatusError, so main needed a real merge (a38336c1):
- I kept #1193's key-omitted branch and its 401 hint, plus this branch's truncation marking. The hint now goes before the body instead of after it, so the retained body stays at the end of the message, which is the only place the panel repairs a cut credential.
TestAnUnauthorizedHintKeepsTheCutBodyAtTheEndpins that order and fails if the hint moves back. - #1189 matches configured secrets across separator bytes now, so a credential split by a bare ESC is redacted with the reason kept rather than withheld. The escape test expects that, and its real-HTTP case now uses a CSI that eats a credential byte, which still withholds.
- #1193's
aimlapidefault is opt-in and disabled, and it sorts first, so the startup-split collision test skips disabled defaults.
One thing I noticed but left alone: the key #1193 injects never reaches config, so it isn't among the panel's candidates. The status path is covered because it drops the body, but a JSON-RPC error is returned as the server wrote it (network_client.go lines 226 and 281 on main), so a server that echoed the key there would show it in this panel and anywhere else that error is printed. I think the fix belongs at the source, scrubbing the exact injected value from errors built from that request, as a follow-up to #1193. Happy to fold it in here if you'd rather.
go test ./..., vet for windows, linux and darwin, the release build and smoke, govulncheck for linux and windows, and the lint over internal/mcp, internal/tui and internal/cli are clean. Could you take another look when you have a minute?
@jatmn I opened #1197 for the AI/ML API key gap I mentioned above, so it stays out of this PR. It covers tool results as well as JSON-RPC errors, since MCP returns a failed tool call as an isError result, which makes that the likelier place for an echoed key to land.
@jatmn merged current main (ef1ca39b: #1202, #1204, #1203, #1208, #1198 and the 0.13.0 release) in 57c8c2ff. It merged without conflicts; internal/cli/app.go and internal/tui/model.go auto-merged, and nothing on the branch changed.
go test ./... (89 packages), vet for windows, linux and darwin, the release build and smoke, and govulncheck for linux and windows are clean on the merge. Could you take another look?
@jatmn both test nits are in 280bdc12, and 73b445b8 merges current main (clean, nothing from main dropped).
TestRunPassesSkippedMCPServersToTheTUInow asserts thatMCPSkipped[0].Errcarries "connection refused". When I made startup pass the entries through withErrcleared, it fails withMCPSkipped[0].Err = <nil>.TestFailedServerIsMatchedByItsCanonicalNamenow also builds the view for a running server with one registereddocstool in each case, and asserts it is enabled with a count of 1. Looking the count up by the raw map key fails the padded cases withrendered as "enabled" with 0 tools.
Full go test ./..., vet, release build, smoke and git diff --check pass locally on 73b445b8.
@anandh8x your terminal sanitization request from be580766 is in this head (sanitizeTerminalReason and redactMCPFailureReason, covered by mcp_failed_state_test.go). When you have a minute, could you look again? Your earlier review is what GitHub is still holding against the PR.
Walkthrough
MCP startup failures now flow from the CLI runtime into TUI state. The
/mcppanel marks skipped servers as failed, displays sanitized reasons, and preserves stderr warnings.Changes
MCP failure visibility
internal/cli/app.go,internal/cli/app_mcp_skipped_test.go,internal/tui/options.go,internal/tui/model.gomcpRuntime.Skipped()throughtui.Options. The TUI stores it in model state. Tests verify propagation and stderr reporting.internal/tui/mcp_state.go,internal/tui/mcp_skipped_invalidation.go,internal/tui/command_views.go,internal/tui/mcp_add_wizard.go,internal/mcp/oauth_store.gointernal/tui/mcp_view.go,internal/tui/mcp_manager.go,internal/tui/mcp_failed_state_test.gointernal/redaction/overlapping_secrets_test.go,internal/mcp/oauth_secret_values_test.go,internal/tui/mcp_failure_redaction_test.go,internal/tui/mcp_redaction_ignorable_test.go,internal/tui/mcp_header_flag_redaction_test.go,internal/tui/mcp_raw_bound_test.go,internal/tui/mcp_target_redaction_test.go,internal/tui/mcp_url_credential_test.go,internal/tui/mcp_candidate_bound_test.go,internal/tui/mcp_oversized_secret_test.go,internal/tui/mcp_path_credential_test.go,internal/tui/mcp_state_entrypoint_test.goEstimated code review effort: 4 (Complex) | ~60 minutes
Sequence Diagram(s)
Possibly related PRs
Suggested reviewers:
anandh8x,kevincodex1Merge Risk: High · up to
dc886The change can display an MCP credential in the /mcp panel and hide the next argument instead, potentially persisting a secret in the transcript. This security issue makes the PR unsafe to merge until packed sensitive arguments are redacted correctly.
Pre-merge checks: 4
#825./mcpwith server-scoped state and credential-redacted errors.Finishing Touches
🧪 Generate unit tests (beta)
fix/825-mcp-panel-shows-failures