fix: Fixed the issue where the returnDirect attribute was not effective on the MCP server side. #3787
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.
Background
Before this PR, when using the
@Tool
annotation to define tools on the MCP server side and specifying thereturnDirect
attribute, the attribute would not be properly propagated. As a result, the client was unable to retrieve this information. For a detailed discussion and root cause analysis of this issue, please refer to: #3481 .Thanks to the merge of PR #3781 , we now have the foundation to fix this problem.
Changes in This PR
Preserve the
returnDirect
AttributeAdjusted the logic in the
McpToolUtils
class that constructs tool declarations, ensuring that thereturnDirect
attribute from the@Tool
annotation is correctly retained and passed through.Implemented
getToolMetadata
MethodAdded implementations of the
getToolMetadata
method in bothAsyncMcpToolCallback
andSyncMcpToolCallback
classes. This enables clients to retrieve tool metadata, including thereturnDirect
flag.Added Unit Tests
Included corresponding unit tests to verify the correctness and stability of the above changes.
Fixes: #3481