Skip to content

fix: Fixed the issue where the returnDirect attribute was not effective on the MCP server side. #3787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sunyuhan1998
Copy link
Contributor

Background

Before this PR, when using the @Tool annotation to define tools on the MCP server side and specifying the returnDirect 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

  1. Preserve the returnDirect Attribute
    Adjusted the logic in the McpToolUtils class that constructs tool declarations, ensuring that the returnDirect attribute from the @Tool annotation is correctly retained and passed through.

  2. Implemented getToolMetadata Method
    Added implementations of the getToolMetadata method in both AsyncMcpToolCallback and SyncMcpToolCallback classes. This enables clients to retrieve tool metadata, including the returnDirect flag.

  3. Added Unit Tests
    Included corresponding unit tests to verify the correctness and stability of the above changes.

Fixes: #3481

@ilayaperumalg ilayaperumalg added this to the 1.1.x milestone Jul 11, 2025
@ilayaperumalg
Copy link
Member

@sunyuhan1998 Thanks for the quick follow up on this!

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

Successfully merging this pull request may close these issues.

@Tool returnDirect Attribute Ignored
2 participants