Skip to content

feat: host a loopback viewer-control service for the Rerun MCP - #15

Merged
alvgaona merged 1 commit into
mainfrom
feature/rew-210
Jul 25, 2026
Merged

feat: host a loopback viewer-control service for the Rerun MCP#15
alvgaona merged 1 commit into
mainfrom
feature/rew-210

Conversation

@alvgaona

@alvgaona alvgaona commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

The Rerun MCP server (rerun viewer-mcp) drives a viewer through the ViewerControlService gRPC 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:9878 and falls back to an ephemeral port when taken, logging the resolved address at startup. Port 9876 belongs to the relay (which rewire record also hosts embedded, so squatting on it would race the most common local flow) and 9877 is the legacy rewire.v1 service port the bridge still probes during auto-detect. The viewer-mcp CLI takes no flags, so clients pass the endpoint in the MCP connect call.

Verified live against the built binary through the MCP itself with connect, viewer_state, query_tree, screenshot, open_url and set_time, including a full bug-hunting session on a flight recording.

Changes

  • control module with a ControlServer that spawns re_grpc_server::spawn_with_recv_and_services on the loopback interface, preferring port 9878 with ephemeral fallback
  • main.rs wires the control receiver into the app next to the relay receiver
  • the viewer remains a pure data client of the relay, and the message proxy bundled with the spawn helper is loopback-bound and not a supported ingestion path

Checklist

  • PR title follows Conventional Commits
  • cargo fmt --check is clean
  • cargo clippy --all-targets -- -D warnings is clean (native)
  • cargo build --lib --target wasm32-unknown-unknown --no-default-features builds (wasm)
  • cargo test passes
  • Public items have /// docs

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.
@alvgaona
alvgaona merged commit 3352ff8 into main Jul 25, 2026
4 checks passed
@alvgaona
alvgaona deleted the feature/rew-210 branch July 25, 2026 11:44
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