Skip to content

fix(mcp): fields the server leaves out when empty are optional in the output schema - #1414

Merged
DrunkOnJava merged 3 commits into
mainfrom
fix/mcp-optional-schema
Nov 5, 2026
Merged

DrunkOnJava merged 3 commits into
mainfrom
fix/mcp-optional-schema

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

The release review of #1399 found that four output fields of rvt-rs-mcp are left out of the JSON when empty but listed as required in the tool output schema:

  • ElementProvenance.value_sources (skip_serializing_if = "Vec::is_empty"; list_elements never carries it);
  • ValueSourceOut.partitions and parts (Vec::is_empty);
  • ValueSourceOut.parts_left_out (is_zero).

schemars marks a non-Option field required, so the shipped docs/mcp-tools.json has ElementProvenance.required = ["value_sources", ...], and a client that validates structuredContent against the output schema rejects every list_elements row. All four fields are new since 0.14.0, so no released version has the defect.

Each now carries #[schemars(default)], so the schema lists it as optional. No default key is added, since schemars leaves it out when skip_serializing_if would skip the default. What the server writes is unchanged. The contract (docs/mcp-tools.json, .md) is committed from this PR's CI artifact, not by hand.

Also, the --element-provenance help text quoted the table's size from before the value sources (7.4 MB, "about 140 times"; the measured figure is now 11.1 MB and about 210 times), and the store's doc comment said 4.5 MB. Both now point to "Provenance table size" in docs/export-diagnostics.md, the one place the sizes are kept current.

Testing

  • No local build (policy). CI builds the server and uploads its contract. The synced docs/mcp-tools.json diff (a807027, from CI run 41956710864) is 24 deletions and no additions: these four fields leave required in the four tool schemas that carry them, and nothing else changes.
  • rvt-mcp/tests/mcp_stdio.rs runs the server over stdio on Einhoven. No output bytes change.

Audit-honesty checklist

  • No changelog fragment. The defect exists only on main since 0.14.0 and is fixed before 0.15.0 ships.

Legal and contribution hygiene

  • Apache-2.0; no Autodesk proprietary source, decompiled internals or NDA'd SDK content.

Breaking changes

None. The schema becomes more permissive, and the output is unchanged.

Related issues

Refs #1325, #1360.

@DrunkOnJava DrunkOnJava added the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 5, 2026
@DrunkOnJava DrunkOnJava mentioned this pull request Nov 5, 2026
3 tasks done
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 5, 2026 02:54
@DrunkOnJava DrunkOnJava removed the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 5, 2026
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) November 5, 2026 03:14
@DrunkOnJava
DrunkOnJava merged commit 06c8297 into main Nov 5, 2026
33 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/mcp-optional-schema branch November 5, 2026 03:30
DrunkOnJava added a commit that referenced this pull request Nov 5, 2026
## Summary

Release 0.15.0:
- Where each decoded element was read from, down to the byte, on
request: `rvt-ifc --element-provenance` (#1325), with the copy each
body, profile and outline reader took its value from (#1360, #1368).
- Why an element, body, opening or outline was left out, one entry per
element, on request: `rvt-ifc --export-decisions` (#1326), and the MCP
server's `explain_element`.
- Where a Revit 2008 to 2023 project's element records stop, in every
export's diagnostics (#1389, for #421).
- Rooms take off the round columns their stored solid holds (#1354,
RE-334).
- Areas whose boundary lines name each other are drawn to their joins
(#1261, RE-330).
- Shape-edited floors drawn along their sloped top, and the walls on
them cut at it (#1384, RE-336).
- `rvt-ifc --family-extrusions`, opt-in, draws a family instance from
its family's own extrusions, arcs as true arcs (#156, RE-327, #1366).
- Partition streams in number order (#1356); the viewer's browser tests
in `CI passed` (#1394).
- Value sources for Areas and shaped floors (#1403), the shaped floors'
slab quantities and the GLB layer colour kept (#1405), floor voids
tagged as Revit tags them (#1402), Measure's scorer for the MCP server's
answers (#1404), and the MCP server's element names and type objects
taken from the IFC writer (#1406).

## Changes

- Version 0.14.0 -> 0.15.0 in:
  - Cargo.toml;
  - rvt-py/Cargo.toml and its `=` pin;
  - rvt-mcp/Cargo.toml and its `=` pin;
  - rvt-wasm/Cargo.toml;
  - tools/stream_evidence/Cargo.toml;
  - viewer/package.json;
  - CITATION.cff (version and date);
  - Cargo.lock and fuzz/Cargo.lock.
- `python3 tools/release/changelog.py assemble`: 23 fragments go into
`[0.15.0]`, with an introduction, a "Not measured" list, credits and
"Upgrading from 0.14". The 21 from the first assembly come in first,
then #1403's and #1405's after `main` was merged. #1405's fix is folded
into #1384's entry, since the slab quantities it restores never left a
release.
- README: the latest release and the "Upgrading from" pointer.

## Testing

- **Measure 41944962415.** It ran `main` at 77d71cb against v0.14.0
with timing, on the reference models, the samples, the held-out models
and Revit 2025, with no families.
- It found two losses from #1388 on the offices: 16 slab quantities went
from equal to missing on each file, and 14 (16) walls lost their GLB
layers.
- #1405 restores both. Measure 41949652150 shows them back to v0.14.0's
values, with 32 other models byte-identical.
  - The intro's timing figures come from this run.
- **Final Measure 41965523134.** It ran this branch at 1e56972 (with
#1402 to #1406, #1413 and #1414) against v0.14.0, with the reference
models, Revit 2025, the samples, the held-out models and the families.
  - Every figure in the introduction comes from it.
- Apart from the MCP scorer #1404 adds, every scorer output on every
model is identical to run 41963115180 (5b1a371): the held-out counts
only gain `mcp answers:` lines. #1406's writer refactor therefore moves
no export, on the samples and held-out models too.
  - Since 1e56972 the branch adds only changelog text.
- **Witness and fixtures.** The Core Interior witness observations and
verdicts (both artifacts) and the two synthetic fixtures are taken from
this PR's CI run 41954452074 on ce0b2d8. Only `witness_version`, the
verdict hashes and the version strings changed.
- **Release review.** A second read found these, all fixed on the
branch:
  - a false "and the families" for the first run;
  - #1405's missing entry;
  - an offsets claim that overreached for the decisions log;
  - stale sentences in three entries;
  - missing caveats, credits and upgrade notes;
- an MCP output schema that listed four optional fields as required.
#1414 fixes that and lands first.

## Audit-honesty checklist

- [x] The introduction keeps each entry's caveats, and adds a "Not
measured" list:
- the offsets unmeasured on Revit 2008 to 2022, and the decisions log's
before 2024;
  - the values with no recorded source;
  - the in-sample Area join rule (#1261);
- the refusal markers on Snowdon and `rac_advanced` with no IFC4 export
to score them;
  - the family-extrusions release range.
- [x] No emojis, private paths or internal jargon.

## Legal and contribution hygiene

- [x] Apache-2.0; no Autodesk proprietary source, decompiled internals
or NDA'd SDK content.

## Breaking changes

None in the stable API: `ExportOptions`, `ExportNote`,
`ExportDiagnostics`, `DecodedExportDiagnostics` and
`ExportedModelDiagnostics` gain fields and variants, and all are
`#[non_exhaustive]`; the provenance, decisions and stage types are new.
`--family-extrusions` is new in this release (the `arcs` field #1366
removed never shipped). Behaviour changes are listed under "Upgrading
from 0.14".

The `rvt-rs-mcp` tool output changes, as #1406 states and "Upgrading
from 0.14" lists:
- an element's `name` can be absent, where it would be a room's
`<class>-<ElementId>` placeholder;
- `element_type` is absent where the IFC export writes no type object;
- `element_type`'s `element_id` is the type object's `Tag`.

The output schemas in `docs/mcp-tools.json` say so.

## Related issues

Refs #1325, #1326, #1360, #1368, #1389, #421, #1354, #1261, #1384, #156,
#1366, #1356, #1394, #1374, #1402, #1403, #1404, #1405, #1406, #1413,
#1414.
DrunkOnJava added a commit that referenced this pull request Nov 5, 2026
…gainst its tool's output schema (#1415) (#1416)

## Summary

Closes #1415. The release review of 0.15.0 found MCP output fields that
the server leaves out when empty but its output schema listed as
required (#1414). Nothing caught it: `rvt-mcp/tests/mcp_stdio.rs`
checked only that each tool has an `outputSchema` and that the contract
is committed.

Now, when `RVT_MCP_ANSWERS_DIR` is set, the end-to-end test keeps:
- each tool's `outputSchema`, from every session's `tools/list`;
- every successful structured answer it is given, written as
`<dir>/{schemas,answers}/<tool>/<pid>-<n>.json`.

Every call the rmcp client makes goes through the test's `call()`
helper, and every raw JSON-RPC request goes through the `Raw` helper,
which records each `tools/call` request's tool by id and keeps its
successful structured answer in `recv`. So every tool answer the test is
given is kept: `open_model`, `get_summary` and `export_ifc` in the raw
tests (`wire_discipline_on_raw_stdio`,
`a_path_outside_output_dir_is_refused`, `cancel_an_export`), and every
tool through the client. Schemas are kept from each session `drive`
runs.

`tools/ci/validate-mcp-answers.py` then checks four things, and fails CI
if any of them fails:
- each tool's schema is the same in every session;
- every tool that answered declared a schema;
- the schema is valid JSON Schema;
- every answer validates against it.

It prints a per-tool count, and up to 5 errors per invalid answer,
naming the deepest reason inside an `anyOf` (an optional object), with a
count of the rest. With `--require-all`, as CI runs it, a tool that
declared a schema and gave no answer fails too. A model the test skipped
therefore cannot leave tools unchecked: `get_element` and
`explain_element` answer only on Einhoven. An empty answer folder also
fails. The test clears the directory once a run before writing, so a
local rerun never mixes runs. CI's "MCP server on Einhoven" job sets the
variable, runs the check after the test (fixture and Einhoven, both
lifecycles), and uploads the directory as `mcp-answers`. It uses
`jsonschema`, already pinned by hash in
`tools/ci/requirements-test.txt`. No Rust dependency is added.

## Testing

- **Locally, without a build.** I ran the validator on main's
`get_element` schema (from `docs/mcp-tools.json`) with an empty answer.
It reports each missing required property and exits 1. I also gave it an
empty schema folder; it now reports that instead of crashing.
- **First CI run, at 6a2aadb on main without #1414** (job 127024735756,
"MCP server on Einhoven"). The stdio tests passed (15 of 15), and the
check failed on exactly the four fields #1414 fixes. Every tool
answered: 59 answers in all, across the synthetic fixture and Einhoven
in both lifecycles.
- `list_elements` (2 of 6 valid): each row's `provenance` lacks
`value_sources`.
- `get_element` (0 of 6) and `explain_element` (0 of 6): each
`value_sources` entry lacks `partitions`, `parts` and `parts_left_out`.
  - The other 7 tools' 47 answers are valid.
- **After #1414 landed**, at 1c32d1b (main merged in, job
127034039581), all 59 answers of all 10 tools validate against their
tools' schemas.
- **Final head 509a968** (job 127062380667), with the raw JSON-RPC
tests' answers kept as well: all 65 answers of all 10 tools validate in
`--require-all` mode. The 6 raw answers add 3 `export_ifc`, 2
`get_summary` and 1 `open_model`.
- `cargo fmt --check`, `actionlint` (no finding beyond the known `$/`
syntax) and `py_compile` pass.

## Audit-honesty checklist

- [x] The check validates what the server actually sends, against what
it declares. It does not judge whether the values are right; Measure's
`mcp_answers_vs_ifc` (#1404) does that.

## Legal and contribution hygiene

- [x] Apache-2.0; no Autodesk proprietary source, decompiled internals
or NDA'd SDK content.

## Breaking changes

None. Test and CI only.

## Related issues

Closes #1415. Refs #1414, #1327.
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