Skip to content

Tell clients our version, and which tools are safe to run - #178

Merged
rajeeja merged 2 commits into
mainfrom
mcp-identity-and-annotations
Oct 13, 2026
Merged

rajeeja merged 2 commits into
mainfrom
mcp-identity-and-annotations

Conversation

@rajeeja

@rajeeja rajeeja commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Acts on the findings from #174's protocol harness. Two were real bugs and are fixed; the third turned out narrower than it looked and is documented instead.

1. serverInfo.version was ""

The identity carries the release and the SDK's Server accepts version=, but neither route_table_to_mcp_server nor MCPAdapter.__init__ upstream takes one — so nothing forwarded it. Every client was told this server has no version, which breaks the ordinary way a bug report establishes what was running.

_stamp_version sets it on both construction paths and collapses to nothing the day either constructor grows the parameter. Verified on the CLI serve_mcp path too, not just make_mcp_server.

2. No tool declared annotations

readOnlyHint and friends are how a client decides what to auto-approve. With none set, get_capabilities was indistinguishable from a tool that uploads to a cluster.

src/uxarray_mcp/annotations.py classifies the surface under three rules, written down because a wrong hint is worse than no hint — a tool falsely marked read-only gets auto-approved and the user never sees the prompt that would have caught it:

Rule Meaning
Read-only means no side effect anywhere Not "does not write the file it was given". Persisting a result artifact disqualifies it.
Silence beats a guess Unclassified ⇒ no annotation at all, which clients read as "unknown".
Destructive ≠ writes something Rendering a figure into the artifact store is a write; uploading over a cluster path is destructive.

Two implementation notes. Upstream's make_mcp_tool takes no annotations argument and builds every Tool inside a closure, so there is no seam at construction — the registered tools/list handler is wrapped instead. And mcp 2.x stores a HandlerEntry, not a bare callable: replacing it with a plain function makes every tools/list fail with 'function' object has no attribute 'params_type'. Hit that, so the wrapper is rebuilt as the same type.

3. outputSchema — not what it looked like

The harness reported 1 of 33, which I read as "machinery wired to almost nothing". Checking properly: five operations declare a contract and the registry attaches a schema to all five (asserted on the route table). Only run_analysis reaches tools/list because the other four are deferred — reached via call_deferred rather than listed.

So this is a property of the deferral design, not broken plumbing. Widening it means deciding which tools earn a place in the context window, which is a judgement call rather than a fix. Pinned as a test so the decision stays visible.

Tests

tests/test_tool_annotations.py checks the map directly rather than through the wire, because deferred-full publishes 35 of its 72 tools and the transfer tools — whose classification matters most — are never listed. It also fails on an entry naming a tool that no longer exists, since a stale name annotates nothing while still reading as a deliberate safety claim.

The two characterisation tests from #174 flipped red when fixed, exactly as intended, and are now rewritten as positive assertions.

core suite 1402 passed (1389 + 13)
hpc / yac 25 passed / 3 passed
pre-commit (ruff, mypy, zizmor) all passed

mypy caught a real "None" not callable in the handler rebuild during this work — fixed, not suppressed.

Note

SECURITY.md now records that these hints are advisory by specification and that enforcement remains the precondition layer and the endpoint's own remote_read_root/remote_write_root. They are a usability signal, not a control.

Two of the three findings from the protocol harness, fixed; the third
turned out to be narrower than it looked and is now documented instead.

**serverInfo.version was the empty string.** The identity carries the
release and the SDK's Server takes version=, but neither
route_table_to_mcp_server nor MCPAdapter.__init__ upstream accepts one,
so nothing forwarded it. Every client was told this server had no
version, which breaks the ordinary way a bug report establishes what was
running. _stamp_version sets it on both construction paths and collapses
to nothing the day either constructor grows the parameter.

**No tool declared annotations.** readOnlyHint and friends are how a
client decides what to auto-approve, and with none set a pure capability
query was indistinguishable from a tool that uploads to a cluster. The
map in annotations.py classifies the surface under three rules, written
down because a wrong hint is worse than no hint: read-only means no side
effect anywhere rather than "does not write the file it was given";
anything unclassified gets no annotation rather than a guess; destructive
means it can overwrite data the user cares about, not merely that it
writes something. Rendering a figure into the artifact store is a write;
uploading over a path on a cluster is destructive.

Upstream's make_mcp_tool takes no annotations argument and builds every
Tool inside a closure, so there is no seam at construction -- the
registered tools/list handler is wrapped instead. mcp 2.x stores a
HandlerEntry rather than a bare callable, and replacing it with a plain
function makes every tools/list fail with "'function' object has no
attribute 'params_type'"; the wrapper is rebuilt as the same type.

**outputSchema was not actually wired to one tool.** Five operations
declare a contract and the registry attaches a schema to all five --
asserted on the route table. Only run_analysis reaches tools/list,
because the other four are deferred and reached through call_deferred
rather than listed. That is a property of the deferral design, not of
the schema plumbing, and widening it means deciding which tools earn a
place in the context window. Pinned as a test so the decision stays
visible.

tests/test_tool_annotations.py checks the map directly rather than
through the wire, because deferred-full publishes 35 of its 72 tools and
the transfer tools -- the ones whose classification matters most -- are
never listed. It also fails on an entry naming a tool that no longer
exists, since a stale name annotates nothing while still reading as a
deliberate safety claim.

SECURITY.md records that these hints are advisory by specification and
that enforcement remains the precondition layer and the endpoint's own
read/write roots.
The formatter rewrote this file after it was staged on the previous
commit, so the committed copy was the pre-format one and CI's pre-commit
job failed on a diff that had already been applied locally.

Formatting only; no behaviour change.
@rajeeja
rajeeja merged commit d16dfc9 into main Oct 13, 2026
13 checks passed
@rajeeja
rajeeja deleted the mcp-identity-and-annotations branch October 13, 2026 01:21
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