refactor: deprecate tool spec's arguments-only handler in favor of CallToolRequest #375
+1,680
−698
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactor tool specifications to use builder pattern and deprecate arguments-only handlers in favor of CallToolRequest
Related to #300
Motivation and Context
The current tool handler API only provides access to the arguments Map, limiting handlers to just the parameter values. This change introduces handlers that receive the full
CallToolRequest
object, giving access to the complete request context including tool name and arguments together. Additionally, the builder pattern improves API ergonomics and enables better validation during tool registration.Key improvements:
How Has This Been Tested?
Breaking Changes
None - This change is fully backward compatible. Existing code using the deprecated constructors and
tool()
methods will continue to work unchanged. Users can migrate to the new API at their own pace.Types of changes
Checklist
Additional context
Migration Path:
Old API:
new McpServerFeatures.SyncToolSpecification(toolDef, (exchange, args) -> ...)
New API:
McpServerFeatures.SyncToolSpecification.builder().tool(toolDef).callTool((exchange, callToolReq) -> ...)).build()
Old API:
new McpServerFeatures.AsyncToolSpecification(toolDef, (exchange, args) -> ...)
New API:
McpServerFeatures.AsyncToolSpecification.builder().tool(toolDef).callTool((exchange, callToolReq) -> ...)).build()