core-agent-ide/codex-rs/tui_app_server
Felipe Coury 43ee72a9b9
fix(tui): implement /mcp inventory for tui_app_server (#14931)
## Problem

The `/mcp` command did not work in the app-server TUI (remote mode). On
`main`, `add_mcp_output()` called `McpManager::effective_servers()`
in-process, which only sees locally configured servers, and then emitted
a generic stub message for the app-server to handle. In remote usage,
that left `/mcp` without a real inventory view.

## Solution

Implement `/mcp` for the app-server TUI by fetching MCP server inventory
directly from the app-server via the paginated `mcpServerStatus/list`
RPC and rendering the results into chat history.

The command now follows a three-phase lifecycle:

1. Loading: `ChatWidget::add_mcp_output()` inserts a transient
`McpInventoryLoadingCell` and emits `AppEvent::FetchMcpInventory`. This
gives immediate feedback that the command registered.
2. Fetch: `App::fetch_mcp_inventory()` spawns a background task that
calls `fetch_all_mcp_server_statuses()` over an app-server request
handle. When the RPC completes, it sends `AppEvent::McpInventoryLoaded {
result }`.
3. Resolve: `App::handle_mcp_inventory_result()` clears the loading cell
and renders either `new_mcp_tools_output_from_statuses(...)` or an error
message.

This keeps the main app event loop responsive, so the TUI can repaint
before the remote RPC finishes.

## Notes

- No `app-server` changes were required.
- The rendered inventory includes auth, tools, resources, and resource
templates, plus transport details when they are available from local
config for display enrichment.
- The app-server RPC does not expose authoritative `enabled` or
`disabled_reason` state for MCP servers, so the remote `/mcp` view no
longer renders a `Status:` row rather than guessing from local config.
- RPC failures surface in history as `Failed to load MCP inventory:
...`.

## Tests

- `slash_mcp_requests_inventory_via_app_server`
- `mcp_inventory_maps_prefix_tool_names_by_server`
- `handle_mcp_inventory_result_clears_committed_loading_cell`
- `mcp_tools_output_from_statuses_renders_status_only_servers`
- `mcp_inventory_loading_snapshot`
2026-03-17 16:11:27 -06:00
..
frames Move TUI on top of app server (parallel code) (#14717) 2026-03-16 10:49:19 -06:00
src fix(tui): implement /mcp inventory for tui_app_server (#14931) 2026-03-17 16:11:27 -06:00
tests Move TUI on top of app server (parallel code) (#14717) 2026-03-16 10:49:19 -06:00
BUILD.bazel Move TUI on top of app server (parallel code) (#14717) 2026-03-16 10:49:19 -06:00
Cargo.toml Move TUI on top of app server (parallel code) (#14717) 2026-03-16 10:49:19 -06:00
prompt_for_init_command.md Move TUI on top of app server (parallel code) (#14717) 2026-03-16 10:49:19 -06:00
styles.md Move TUI on top of app server (parallel code) (#14717) 2026-03-16 10:49:19 -06:00
tooltips.txt Move TUI on top of app server (parallel code) (#14717) 2026-03-16 10:49:19 -06:00