Skip to content

Require Tool inputSchema during deserialization#1600

Open
DragonFSKY wants to merge 1 commit into
modelcontextprotocol:mainfrom
DragonFSKY:fix/1575-required-input-schema
Open

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

Conversation

@DragonFSKY
Copy link
Copy Markdown

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"

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.

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

1 participant