Skip to content

feat(mcp): rvt-rs-mcp, a stateless stdio MCP server over the decoded model (#1324) - #1330

Merged
DrunkOnJava merged 8 commits into
mainfrom
feat/mcp-server
Nov 4, 2026
Merged

DrunkOnJava merged 8 commits into
mainfrom
feat/mcp-server

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds rvt-rs-mcp, a local, read-only MCP server over stdio, as the new workspace crate rvt-mcp/. It links rvt in process, serves MCP 2026-07-28 (stateless) and the older initialize handshake, and answers an agent's questions about a Revit file from the same model the IFC exporter writes.

Closes #1324
Refs #1325 #1326 #1327 #1331

Motivation

The design is the body of #1324. In short: an agent should be able to open a .rvt, .rfa, .rte or .rft, ask about its elements, levels, rooms and diagnostics, and export it, with no Revit install and no network, and with every answer saying where it comes from and what was not read.

Changes

  • rvt-mcp/ (package rvt-rs-mcp, rust-version = "1.88", rmcp 3.8 with server, macros, transport-io, schemars; no HTTP feature). Nine tools: open_model, get_summary, list_elements (category, class, level), get_element (ElementId or GlobalId), list_rooms, list_levels, get_diagnostics, export_ifc, export_gltf. Each declares an outputSchema and returns structuredContent plus the same JSON as text; each element carries a provenance object. Source layout: pipeline.rs is rvt-ifc's decode (same steps and order as src/bin/rvt_ifc.rs), store.rs the LRU keyed by canonical path, size and mtime, views.rs the answers, exports.rs and output.rs the exports, server.rs the tools.
  • State: none per session. open_model returns an opaque model_id (hash of the identity, no path in it); every tool takes it or the path. An unknown, evicted or stale id is an isError result telling the model to call open_model again. The lifetime is in open_model's description and in docs/mcp.md. Two decoded models are kept by default (--max-open-models).
  • Long calls: progress notifications when the request carries a progress token, and notifications/cancelled cancels the walk through WalkerControl (nothing partial is written; the export is written beside its target and renamed). The server never asks the client for anything.
  • Exports: written to the path the caller names (.ifc / .glb, not the model, not existing unless overwrite, inside --output-dir when set), result is a summary with the SHA-256 plus a resource_link. Refuses when a resource limit left streams unread unless allow_partial (the CLIs' exit 3).
  • Wire discipline: #![deny(clippy::print_stdout, clippy::print_stderr)], logging through tracing to stderr, exit on stdin EOF, tools/list carries ttlMs for 2026-07-28 peers.
  • Core crate, two additive public functions and no change to any export: ifc::step_writer::element_global_ids (the loop the STEP writer already ran, now shared so a tool names an element by the GlobalId its IFC carries) and ifc::schedule_csv::room_rows (what rooms_csv renders; rooms_csv now renders from it).
  • CI: clippy for rvt-rs-mcp (including its test), the dependency-tree guard tools/ci/audit-mcp-network.sh (no HTTP, TLS or WebSocket crate), the end-to-end test in the test matrix on every OS and again in Corpus health on Einhoven, a cargo +1.88 check of the crate on the MSRV entry. tools/check-local.sh runs the guard and the test.
  • Release: release-binaries.yml builds -p rvt -p rvt-rs-mcp, packs rvt-rs-mcp into every archive (and so the image), checks its .dep-v0 section and smoke-tests it (--version, server/discover); publish.yml adds a source-install smoke and cargo publish -p rvt-rs-mcp after rvt, and checks both crates' versions against the tag. RELEASE.md, docs/maintaining.md, docs/install.md, docs/status.md and the README say so.
  • Review fixes: exports go through tempfile (a uniquely named, exclusively created temp file in the target's folder; persist_noclobber without overwrite, persist with it; removed on every error path), the write loop stops on cancellation, and bad arguments are isError tool errors (the tools read their arguments themselves, because rmcp's Parameters extractor answers a malformed object with a JSON-RPC error). The server serves (tokio::io::stdin(), tokio::io::stdout()) through transport-async-rw instead of transport-io, which turns tokio's net on; audit-mcp-network.sh asserts tokio has no net, process or signal feature and that mio and socket2 are absent.
  • Tool contract: the end-to-end test holds docs/mcp-tools.json (names, descriptions, input and output schemas, annotations) to what the built server reports for tools/list; tools/ci/render-mcp-tools.py renders docs/mcp-tools.md from it, and the PII guard job runs it with --check.
  • pipeline.rs is a copy of rvt-ifc's steps, as rvt-py and rvt-wasm carry their own; One export pipeline: rvt-ifc, Python, wasm and the MCP server run the same function #1331 replaces all four with one function (a comment says so). The byte-for-byte export comparison guards the copy meanwhile.
  • publish.yml publishes rvt-rs-mcp only when the repository variable PUBLISH_RVT_RS_MCP is true, so a missing first publish cannot leave a tag half published; the binary is in the archives either way (RELEASE.md, step 8).
  • Docs: docs/mcp.md (install, client configuration, tools, handle lifetime, provenance fields that exist today, what is not provided yet, limits, privacy), rvt-mcp/README.md, a changelog fragment.

Testing

Unit tests are banned and none were added. The end-to-end test is rvt-mcp/tests/mcp_stdio.rs:

  • starts the built rvt-rs-mcp and drives it over real stdio with rmcp's client: server/discover at 2026-07-28 and initialize pinned to 2025-11-25, on corpus/tier1/architectural-2024 (and on Einhoven when RVT_PROJECT_CORPUS_DIR is set);
  • checks the tool list (nine tools, outputSchema on each, ttlMs > 0 and resultType only for the 2026-07-28 peer), the opaque handle, id and path both accepted, an unknown id's error, every tool's structured and text content agreeing, an element looked up by ElementId and by GlobalId, and that GlobalId in the IFC the export wrote;
  • compares export_ifc (default and with saved_meshes: off, no_base_quantities) and export_gltf byte for byte with rvt-ifc and rvt-gltf on the same file, with SOURCE_DATE_EPOCH fixed (RVT_REQUIRE_CLI_PARITY=1 in CI makes their absence a failure);
  • raw JSON-RPC: server/discover lists 2026-07-28, an unsupported _meta protocol version is -32022 with the supported list, a call with a progress token gets notifications/progress before its result, every line on stdout is JSON, on Linux the server holds no TCP, UDP or raw socket, and the process exits when stdin closes; and --output-dir refuses a path outside it.

Where CI runs it: ci.yml, job build + real files, step MCP server end to end (ubuntu stable, windows, macos), and job Corpus health, step MCP server end to end on Einhoven; the msrv entry runs cargo +1.88 check -p rvt-rs-mcp --all-targets --locked.

  • tools/check-local.sh passes: not run locally (no local builds on the Mac); the same gates run in CI. Run here: cargo fmt --all, cargo deny check (passes), cargo audit (passes), tools/ci/audit-mcp-network.sh (passes), python3 tools/release/changelog.py check (passes).
  • Verified end to end on real Revit files: the committed synthetic fixture, and Einhoven (MIT, magnetar-io/revit-test-datasets) in Corpus health; the exports compared with the CLIs' byte for byte.
  • This touches the IFC exporter only by sharing the GlobalId loop; no export changes (the byte comparison above and the existing witness verdicts cover it), so no Measure run.
  • Performance change: N/A.

Audit-honesty checklist

Legal and contribution hygiene

  • Apache-2.0
  • No Autodesk proprietary source, decompiled internals or NDA content
  • Fixtures are the committed synthetic ones

Breaking changes

None. rvt gains two public functions (element_global_ids, room_rows with RoomRow); rvt keeps #![forbid(unsafe_code)], 1.87, and no tokio or rmcp dependency. Cargo.lock gains the MCP server's dependencies (66 packages, licences within deny.toml) and libc moves 0.2.185 to 0.2.191.

Release step for the maintainer session (not done here)

rvt-rs-mcp is a new crate on crates.io, and a trusted publisher can be added only to a crate that exists. Before the next tag:

  1. After rvt X.Y.Z is on crates.io, publish rvt-rs-mcp X.Y.Z by hand from the release commit (cargo publish -p rvt-rs-mcp), or reserve the name with the first version.

  2. On crates.io, add a trusted publisher to rvt-rs-mcp: repository DrunkOnJava/rvt-rs, workflow publish.yml, environment crates-io.

  3. Set the repository variable PUBLISH_RVT_RS_MCP to true. publish.yml's step Cargo publish the MCP server runs only then, so until it is set a release publishes rvt and the archives and skips rvt-rs-mcp instead of failing half way. RELEASE.md step 8 says so. The release pull request also bumps rvt-mcp/Cargo.toml (its version and its =X.Y.Z pin on rvt), which RELEASE.md now lists.

Output samples

The server's own descriptions state what is not read and point to docs/status.md; the end-to-end test asserts it for every tool.

Related issues

Closes #1324. Refs #1325, #1326, #1327, #1331.

…model (#1324)

A crate of its own (rvt-mcp, rust-version 1.88) that links rvt in process and serves MCP 2026-07-28 and the older initialize handshake over stdio. open_model runs the decode rvt-ifc runs and every tool reads that model, so an answer and the IFC export cannot disagree. Exports go to a caller-named path with progress and cancellation. The core crate gains two small public functions, element_global_ids and room_rows, and no export changes.
…ors, cancellation tested, no tokio net (#1324)

Exports go through tempfile (unique exclusive name, persist_noclobber without overwrite), the write loop stops on cancel, arguments are read by the tools so a malformed object is isError text, the server serves stdin and stdout without rmcp's transport-io (tokio net off, checked in audit-mcp-network.sh), Einhoven runs in both lifecycles, an E2E case cancels an export, the tool contract is dumped to docs/mcp-tools.json and rendered by tools/ci/render-mcp-tools.py, and publish.yml publishes rvt-rs-mcp only when PUBLISH_RVT_RS_MCP is true.
…ockets (#1324)

A Unix socketpair is tokio's signal driver, linked into the test build by the client's process feature; the check now fails only on a socket in a TCP, UDP, raw or packet table.
…ring (#1324)

docs/mcp-tools.json is the server's tools/list from CI run 41784311944 (the mcp-tools artifact), docs/mcp-tools.md is tools/ci/render-mcp-tools.py's rendering of it. The end-to-end test holds the JSON to the built server's, the PII guard job holds the Markdown to the JSON.
…ot a failed start (#1324)

server/discover and unsupported-version requests are answered before rmcp starts a session, so a probe that closes stdin after only discover reached ConnectionClosed from the bootstrap and the server exited 1, which failed the release-binaries smoke test on every target. That error is now a clean exit (info log); every other start failure stays an error. The raw-stdio tests cover discover then EOF, initialize then EOF, immediate EOF and a non-request first message (still exit 1).
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 4, 2026 07:07
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) November 4, 2026 07:07
@DrunkOnJava
DrunkOnJava merged commit 71c0677 into main Nov 4, 2026
62 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/mcp-server branch November 4, 2026 07:15
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.

MCP server: rvt-rs-mcp, a stateless stdio server over the decoded model (MCP 2026-07-28)

1 participant