Skip to content

feat!: #697 added tool input arguments validation#873

Open
ashakirin wants to merge 5 commits intomodelcontextprotocol:mainfrom
ashakirin:feature/697-tools-input-validation
Open

feat!: #697 added tool input arguments validation#873
ashakirin wants to merge 5 commits intomodelcontextprotocol:mainfrom
ashakirin:feature/697-tools-input-validation

Conversation

@ashakirin
Copy link
Copy Markdown
Contributor

Added tool input arguments validation causes Tool Execution Error accordingly SEP-1303.
It is breaking change, because tool input validation is activated by default

… causes tool execution error. Breaking change, because validation is activated by default
@Kehrlann Kehrlann self-assigned this Mar 26, 2026
@Kehrlann Kehrlann added area/server P1 Significant bug affecting many users, highly requested feature v2 labels Mar 26, 2026
Copy link
Copy Markdown
Contributor

@Kehrlann Kehrlann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I'm revisiting this, I'm wondering whether we really want this system property to toggle this on or off.

We're going to ship this in 2.0, let it be a breaking change - after all, servers MUST validate tool inputs.

(And we should probably revisit tool name validation too, then)

@@ -0,0 +1,270 @@
/*
* Copyright 2024-2024 the original author or authors.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Copyright 2024-2024 the original author or authors.
* Copyright 2026-2026 the original author or authors.

}
Map<String, Object> inputSchema = jsonMapper.convertValue(tool.inputSchema(),
new TypeRef<Map<String, Object>>() {
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should leave this marshalling on the hot path. Look at what we've done in DefaultJsonSchemaValidator, there's a schema cache to avoid specifically doing to much of these operations.

Maybe we should have something similar here? Or maybe we should update the JsonSchemaValidator to also validate JsonSchema objects?

Copy link
Copy Markdown
Contributor

@Kehrlann Kehrlann Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#886 points out similar issues ; there are open PRs about it #749

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pointing it, I will wait until #749 is merged

@Kehrlann Kehrlann added waiting for user Waiting for user feedback or more details breaking-change labels Apr 1, 2026
ashakirin and others added 3 commits April 3, 2026 16:09
…alidator.java

Co-authored-by: Daniel Garnier-Moiroux <daniel.garnier-moiroux@broadcom.com>
…tValidationIntegrationTests.java

Co-authored-by: Daniel Garnier-Moiroux <daniel.garnier-moiroux@broadcom.com>
@ashakirin
Copy link
Copy Markdown
Contributor Author

@Kehrlann regarding toggling:

  • I think toggling makes sense for tool names, because validation is specified as SHOULD/SHOULD NOT in the spec;
  • For server tool input schema validation, I'm not sure about toggling. The spec says MUST, so without validation the implementation would be non-spec-compliant. On the other hand, toggling could make SDK 2.0 adoption easier for some use cases. I agree to remove it.

@Kehrlann
Copy link
Copy Markdown
Contributor

Kehrlann commented Apr 3, 2026

For toggling, I'm in favor of leaving an option to turn it off. But let's get rid of the system property - we don't use that pattern anywhere else in the codebase.
If users don't want validation, they should indicate that in the client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/server breaking-change P1 Significant bug affecting many users, highly requested feature v2 waiting for user Waiting for user feedback or more details

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants