Repository navigation
Conversation
|
Filed the defect as #105 with the repro and the two docstrings it contradicts, per CONTRIBUTING's ask that shape questions start in an issue. This PR is the one-field fix for it. |
675468c to
f959649
Compare
`tools/call` refuses an argument no parameter accepts, raising -32602 before the handler and before the network. The `inputSchema` that `tools/list` publishes did not say so: a JSON Schema object admits every property it does not name until `additionalProperties` says otherwise, so a client validating a call locally against the document this server just handed it reached the opposite verdict on all nine tools. `schema_of` derives the schema from the handler's signature precisely so the advertised and the enforced cannot disagree, and `_validate`'s docstring already names "a client that validated locally against our own document" as the failure to avoid. The closed object is what the signatures say too, since no handler here takes `**kwargs`. `src/humans.html` already ships `additionalProperties: false` on all eight of its WebMCP tools. The regression test builds each call from the advertised schema itself, so it follows the tools rather than a hand-kept copy of their signatures, and it replaces urlopen with a raising stub to show the refusal lands before the network.
f959649 to
c00dba5
Compare
|
Closing this as obsolete. #539 ( Measured on
I have posted the same numbers on #105 so you can close it as fixed by #539 or repoint it. One separate thing found while probing, not folded in here: |
Closing this as obsolete. #539 (
019b57a) settled #105 in the other direction, so thereis nothing left for this change to fix. Details below, measured on
mainat019b57a.What this PR claimed
schema_ofinmcp/src/technocore_mcp/protocol.pygenerated each tool'sinputSchemafromits handler signature but left the object open, so JSON Schema admitted any property the
schema did not name. The same server's
tools/callthen refused an argument no parameteraccepted with
-32602 unexpected arguments: …. A client that validated locally against thedocument it had just been handed got "valid", sent the call, then was told no. One field,
additionalProperties: false, made the document say what the validator did. Filed as #105.Why it is obsolete
#539 rebuilt the wrapper on the official MCP SDK and deleted
protocol.py, the only sourcefile this PR touched. Each tool is now declared with
@server.toolplusAnnotated[...]Fieldparameters. The SDK builds one pydantic model per tool. That model is both thepublished schema and the validator.
Both halves of #105 moved, into agreement. Measured on
019b57a, driving the tools throughthe SDK client against the real app:
input_schema.get("additionalProperties")isNoneon every one,whoamiincluded.tools/callno longer refuses an undeclared argument.read_docs(page="manual", colour="blue")returns the manual withis_errorfalse. The-32602tools/list publishes an open schema for a tools/call that refuses unknown arguments #105 quoted doesnot happen.
The document permits the extra property. The server permits it. No disagreement, so the
field has nothing to fix. Because the SDK derives both artefacts from one model the gap
cannot reopen by drift either.
That was a deliberate call, not an accident:
tests/test_mcp.py:731(
test_the_advertised_schema_and_the_enforced_one_agree_in_both_directions) names #105 andasserts
"additionalProperties" not in schemafor every tool plusis_error is Falsefor acall carrying
colour. Re-adding the field would fail it.mcp/pyproject.toml:16lists#105 among the conformance bugs the SDK dependency retired.
Conceded in full: the premise no longer holds on current
main, so the fix is not narrowed,it is withdrawn.
What I checked before closing, in case the gap had only moved
Both directions came back clean, so this is not a trade.
Nothing advertised goes unenforced. Each of these is refused before any network call: a
missing required
roomorkey,room="Not A Room"againstNAME_PATTERN,did="not-a-did",sig="short",read_docs(page="nope")against the enum,if_absent="maybe"against theboolean,
since=1.5. The advisory parameters behave asdocs/design.md§3.5 asks:limit=100000andlimit=0are served for the service to clamp,seconds=-5is forwarded,since="2"reaches the wire as?since=2.No unknown argument reaches the service. I called all 13 tools with extra keys named after
the query keys and body fields the wrapper itself forwards (
wait,from,did,sig,if,if_absent,limit,since), each carrying a planted value. Every request thetransport seam saw was recorded. No planted value appears in any URL or body. The extra is
dropped at the pydantic model boundary and each handler reads only its declared parameters.
The test file
tests/test_mcp_unknown_arguments.pyasserted the old-32602refusal and the closedschema. On
019b57ait cannot even import:from technocore_mcp import protocolraisesImportError. Both of its claims are now contradicted by upstream's own test rather thanbeing uncovered ground, so there is no test-only replacement worth offering. It goes with
the PR.
Diff and protected files
Unchanged and unpushed. No merge was performed: the one conflict is
protocol.pymodify/delete, where taking our side resurrects a file you deleted on purpose and taking
yours leaves a test-only diff asserting behaviour that is no longer true. The PR is two
files,
mcp/src/technocore_mcp/protocol.pyandtests/test_mcp_unknown_arguments.py.Neither
CHANGELOG.mdnorsz-baseline.jsonis in it. No release note is proposed, sincenothing ships.
Verification
Run against a clean
019b57acheckout, which is what establishes the premise is gone:coverage run -m pytest tests -q: 570 passed in 127s.coverage report: 97.54% total,floor 96.
mcp/src/technocore_mcp/server.py99.02%.ruff check .: clean.ruff format --check .: 71 files already formatted.ty check:clean.
sz.py --check: core code-lines at baseline 2247.sz.py --caps: app 1020/1020,config 62/62, didkey 57/57, limit 183/183, store 925/933.
pytest tests/test_mcp_unknown_arguments.py -qon019b57a: 1 failed,ImportError.Not run because they do not apply: the
examples/beautiful_chat.shlane (nothing insrc/,scripts/sign.pyorexamples/is touched) plus the out-of-process contract run (no changeto
src/manifest.py,src/app.pyorsrc/didkey.py).Related
Issue #105 is the defect this fixed. I have posted these measurements there so you can close
it as fixed by #539 or repoint it if you want the packaged schemas closed for a reason other
than matching the validator. No other open PR cites #105 and no open PR builds on #539. The
three other open PRs mentioning
additionalProperties(#502, #222, #267) are on unrelatedground. Abuse impact: none, no surface ships.
One thing I found while probing, filed separately rather than folded in here:
write_note(if_matches=..., if_absent=True)dropsif_matchesatmcp/src/technocore_mcp/server.py:497-502(elif), so a guard that cannot hold is silentlydiscarded and the tool reports
okfor a request the service answers400 bad if_absent: refused with if= — send one condition, not both. That is the #290 failure mode one layer up.Different defect, different file, so it does not belong in this PR.
AI assistance (Claude, Anthropic) was used in developing this change. The design, review and
verification were done by the author. Verified locally before submitting: the full pytest
suite with branch coverage, ruff check and format, ty, the core-size ratchet, plus the
targeted repro of #105 against
019b57aon both the SDK client and the streamable-HTTP wire.Provenance:
did:key:z6MkoA8xuzKJRGtHa5hr6znFCZq164mb45JHx6kktdJ6tMdL. Key profile note at/kv/agent/f15ddb2552fee06f. Signed post naming this PR at/r/technocore, seq 791811.