Skip to content

Require Tool inputSchema during deserialization#1600

Merged
halter73 merged 1 commit into
modelcontextprotocol:mainfrom
DragonFSKY:fix/1575-required-input-schema
Jun 5, 2026
Merged

Require Tool inputSchema during deserialization#1600
halter73 merged 1 commit into
modelcontextprotocol:mainfrom
DragonFSKY:fix/1575-required-input-schema

Conversation

@DragonFSKY
Copy link
Copy Markdown
Contributor

Motivation and Context

Fixes #1575.

Tool.InputSchema defaults to {"type":"object"} for code-created Tool instances. During JSON deserialization, that same default currently masks payloads that omit the required inputSchema property, allowing invalid tool definitions to deserialize successfully.

Changes

  • Mark Tool.InputSchema as JSON-required so missing inputSchema fails during deserialization.
  • Add a regression test covering deserialization of a tool payload without inputSchema.
  • Preserve the existing default schema behavior for code-created Tool instances.

How Has This Been Tested?

  • PATH=/home/dragonfsky/.dotnet:$PATH /home/dragonfsky/.dotnet/dotnet build
  • PATH=/home/dragonfsky/.dotnet:$PATH /home/dragonfsky/.dotnet/dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj -f net10.0 --filter FullyQualifiedName~ModelContextProtocol.Tests.Protocol.ToolTests
  • PATH=/home/dragonfsky/.dotnet:$PATH /home/dragonfsky/.dotnet/dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj -f net10.0 --filter "FullyQualifiedName~ExperimentalPropertySerializationTests|FullyQualifiedName~ExperimentalInternalPropertyTests"
  • PATH=/home/dragonfsky/.dotnet:$PATH /home/dragonfsky/.dotnet/dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj -f net10.0 --filter "FullyQualifiedName!~DockerEverythingServerTests"

@halter73 halter73 added the breaking-change This issue or PR introduces a breaking change label Jun 5, 2026
@halter73
Copy link
Copy Markdown
Contributor

halter73 commented Jun 5, 2026

Thanks for the PR. I agree that aligning with TS and Python (which both reject missing inputSchema) is the right call, and we just cut 2.0 so the timing works for a clean break. Two small bookkeeping requests before merge:

  1. Update the PR description's "Breaking Changes" section. It currently says "None"; it should explicitly call out that tools/list responses from servers that omit inputSchema will now throw JsonException during deserialization, where previously they were silently accepted with a null/empty schema.
  2. Note in the changelog entry that no backport to the 2.0.x patch series is planned -- this only ships in the next minor.

I've added the breaking-change label.

@halter73 halter73 merged commit df0c102 into modelcontextprotocol:main Jun 5, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change This issue or PR introduces a breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool.InputSchema silently defaults to {"type":"object"} when absent from JSON, masking missing required field

3 participants