Skip to content

feat(tui): expose open_terminal over client MCP (experimental) - #57506

Merged
jlongster merged 5 commits into
devfrom
client-mcp-tui
Oct 22, 2026
Merged

jlongster merged 5 commits into
devfrom
client-mcp-tui

Conversation

@jlongster

@jlongster jlongster commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Stack 5/5, based on client-mcp-endpoint. Merge in order.

Part of the client MCP stack (experimental): a client (TUI/desktop/web) opens a WebSocket to the server, and the server treats that incoming socket as an internal MCP server scoped to a location. Tool calls carry _meta["ai.opencode/sessionID"] so the client acts on the calling session. MCP has no official WebSocket transport, so this is a custom transport, which the spec allows.

This PR

The TUI connects as client MCP server tui (behind the client-mcp experiment, off by default) and exposes open_terminal and write_terminal.

  • Opens or reuses the calling session's terminal without taking keyboard focus
  • Errors if the session is unknown or not open in this TUI
  • write_terminal({ text }) types text as-is into the same terminal open_terminal would use (selected, else newest, else a new one); no newline is appended, so include \n to run a command. Input written before the pane attaches is queued and sent once it does
  • Headless <ClientMcp />; reconnects when the endpoint, credentials or directory change

Tests run the real TUI against a fake WebSocket peer (connection count, flag off, errors, create/reuse, no focus, written input reaches the PTY).

Two TUIs in the same directory both stay connected as tui: the most recently attached one serves the tools, and the earlier one takes over when it closes (connection stacking, #57503), so they don't keep replacing each other and reconnecting.

Stack

  1. feat(core): add MCP transport over incoming client sockets #57502 feat(core): add MCP transport over incoming client sockets
  2. feat(core): attach client-hosted MCP servers #57503 feat(core): attach client-hosted MCP servers
  3. feat(client): add connectClientMcp helper for client-hosted MCP tools #57504 feat(client): add connectClientMcp helper for client-hosted MCP tools
  4. feat(server): add client MCP websocket endpoint (experimental) #57505 feat(server): add client MCP websocket endpoint (experimental)
    → 5. feat(tui): expose open_terminal over client MCP (experimental) #57506 feat(tui): expose open_terminal over client MCP (experimental)

@jlongster
jlongster merged commit 0b93f0b into dev Oct 22, 2026
14 checks passed
@jlongster
jlongster deleted the client-mcp-tui branch October 22, 2026 20:16
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