Add /mcp server picker - #5
Merged
Merged
Conversation
Bare /mcp forwarded to the headless subprocess did nothing useful — the interactive server modal is a real-terminal feature the print-mode CLI can't render, so it just replied with a one-line text status. Reconstruct the modal from the mcp_servers list that rides system:init: parse and cache it (events.go/stream.go), and add an in-process /mcp command that opens a picker of servers + status, with a per-server action menu (reconnect / enable / disable) forwarded as the CLI's own subcommands. The list only arrives with the first turn's init, so the very first /mcp (before any turn) has nothing cached. Silently prime it with a free, 0-turn /mcp fetch, swallow the text echo, and auto-open the picker when the list lands. OAuth login for needs-auth servers stays terminal-only.
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.
Problem
/mcpdid nothing useful. It fell through to the headlessclaudesubprocess, whose print-mode has no interactive modal to render — so it just replied with a one-line text status. The rich server picker is a real-terminal feature.What this does
Reconstructs the modal on cathode's side from the
mcp_serverslist that ridessystem:init(which cathode was discarding):events.go/stream.go— newMCPServerInfo{name,status}, parsed offsystem:initand cached (last non-empty snapshot, like commands/agents).commands.go/mcp.go— in-process/mcpopens a picker of servers + status; selecting one opens a per-server action menu (reconnect / enable / disable), forwarded as the CLI's own/mcp <sub> <server>subcommands./mcp(before any turn) has nothing cached. It silently primes with a free, 0-turn/mcpfetch, swallows the text echo (mcpPriming), and auto-opens the picker when the list lands.Limitation
OAuth login for a
needs-authserver can't be driven headlessly — that stays terminal-only (claude mcp). The picker calls this out in the status line and offers reconnect, not login.Tests
mcp_test.gocovers: parsing the real init shape, picker-opens-when-known, the prime→open flow (echo swallowed, no— done —line), no-servers fallback, contextual actions, and the auth hint. Full suite +go vetgreen.