Skip to content

Add /mcp server picker - #5

Merged
tdwd merged 1 commit into
mainfrom
feat/mcp-server-picker
Aug 4, 2026
Merged

Add /mcp server picker#5
tdwd merged 1 commit into
mainfrom
feat/mcp-server-picker

Conversation

@tdwd

@tdwd tdwd commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Problem

/mcp did nothing useful. It fell through to the headless claude subprocess, 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_servers list that rides system:init (which cathode was discarding):

  • events.go / stream.go — new MCPServerInfo{name,status}, parsed off system:init and cached (last non-empty snapshot, like commands/agents).
  • commands.go / mcp.go — in-process /mcp opens 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.
  • First-invocation fix — the list only arrives with the first turn's init, so the very first /mcp (before any turn) has nothing cached. It silently primes with a free, 0-turn /mcp fetch, swallows the text echo (mcpPriming), and auto-opens the picker when the list lands.

Limitation

OAuth login for a needs-auth server 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.go covers: 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 vet green.

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.
@tdwd
tdwd merged commit 0196379 into main Aug 4, 2026
1 check passed
@tdwd
tdwd deleted the feat/mcp-server-picker branch August 4, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant