feat: host a loopback viewer-control service for the Rerun MCP - #15
Merged
Conversation
The viewer hosts nothing since the pure-relay-client migration, so the Rerun MCP had no endpoint to drive it through. Spawn re_grpc_server's viewer-control service on 127.0.0.1:9878, falling back to an ephemeral port when taken, and drain its UI commands like any other receiver. Port 9876 stays free for the relay the viewer dials by default. The message proxy bundled with the spawn helper is loopback-bound and not a supported ingestion path.
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.
Summary
The Rerun MCP server (
rerun viewer-mcp) drives a viewer through theViewerControlServicegRPC endpoint. Stock Rerun hosts that service next to its message proxy, but rewire-viewer hosts nothing since the pure-relay-client migration, so the MCP had no way to reach it and agent-assisted debugging required opening recordings in a stock viewer instead. The viewer now spawns Rerun's control service on a loopback-only endpoint at startup. Control commands arrive as UI-command entries on the returned receiver, which the app drains like any other data source, so the integration is one spawned server plus one extra receiver.The endpoint defaults to
127.0.0.1:9878and falls back to an ephemeral port when taken, logging the resolved address at startup. Port 9876 belongs to the relay (whichrewire recordalso hosts embedded, so squatting on it would race the most common local flow) and 9877 is the legacyrewire.v1service port the bridge still probes during auto-detect. Theviewer-mcpCLI takes no flags, so clients pass the endpoint in the MCPconnectcall.Verified live against the built binary through the MCP itself with
connect,viewer_state,query_tree,screenshot,open_urlandset_time, including a full bug-hunting session on a flight recording.Changes
controlmodule with aControlServerthat spawnsre_grpc_server::spawn_with_recv_and_serviceson the loopback interface, preferring port 9878 with ephemeral fallbackmain.rswires the control receiver into the app next to the relay receiverChecklist
cargo fmt --checkis cleancargo clippy --all-targets -- -D warningsis clean (native)cargo build --lib --target wasm32-unknown-unknown --no-default-featuresbuilds (wasm)cargo testpasses///docs