[v1.x] Resolve tool output-schema references within the schema document only
Backport of #3394 to v1.x.
Passes an explicit empty referencing.Registry to the client's output-schema validation (ClientSession._validate_tool_result), so $refs in a tool's outputSchema resolve within that schema and the bundled metaschemas, per the spec's $ref resolution section. A reference that doesn't resolve there surfaces from call_tool as RuntimeError("Invalid schema for tool …"), the same shape the method already uses for an invalid schema.
Motivation and Context
Same change as on main; see #3394. jsonschema merges its bundled metaschemas into any registry it is given, so #/$defs/…, #/definitions/…, $anchor, embedded $id resources and $refs to the standard metaschema URIs resolve as before.
How Has This Been Tested?
New test in tests/client/test_output_schema_validation.py through the in-memory client session; the existing recursive-$defs server test covers in-document references. Full suite, coverage, pyright and ruff clean locally.
Breaking Changes
No API changes. A result whose validation reaches a $ref outside the schema document now fails with RuntimeError: Invalid schema for tool <name>: …, and a dangling in-document $ref surfaces as that same RuntimeError rather than a referencing exception.
Types of changes
- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing functionality to change)
- Documentation update
Checklist
- I have read the MCP Documentation
- My code follows the repository's style guidelines
- New and existing tests pass locally
- I have added appropriate error handling
- I have added or updated documentation as needed
Additional context
referencing is jsonschema's own dependency and the type of its registry= parameter; it is imported directly, as on main. The new test uses the file's existing bypass_server_output_validation() helper like its neighbours, and is a plain top-level function per the current test guidelines.