-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Conversation
…not effective on the MCP server side. Signed-off-by: Sun Yuhan <[email protected]>
… unit tests. Signed-off-by: Sun Yuhan <[email protected]>
|
@sunyuhan1998 Thanks for the quick follow up on this! |
mcp/common/src/main/java/org/springframework/ai/mcp/SyncMcpToolCallback.java
Show resolved
Hide resolved
…ange false to true Signed-off-by: rlagyu0 <[email protected]>
# Conflicts: # mcp/common/src/main/java/org/springframework/ai/mcp/AsyncMcpToolCallback.java # mcp/common/src/main/java/org/springframework/ai/mcp/McpToolUtils.java # mcp/common/src/main/java/org/springframework/ai/mcp/SyncMcpToolCallback.java # mcp/common/src/test/java/org/springframework/ai/mcp/SyncMcpToolCallbackTests.java
Signed-off-by: Sun Yuhan <[email protected]>
Signed-off-by: Sun Yuhan <[email protected]>
Signed-off-by: Sun Yuhan <[email protected]>
Signed-off-by: Sun Yuhan <[email protected]>
|
Will this fix be added to the 1.1.0.M3 pre-release @markpollack ? |
|
Hi @sunyuhan1998 Sorry about the delay in getting to this. Having the |
You're right. At the time this PR was conceived and submitted, the mcp-annotations project hadn't yet introduced the |
|
@sunyuhan1998 We intend to use
I agree. This could be something in Spring AI 2.0 cc @tzolov |
Thank you for your explanation. I understand now. If that's the case, does it mean the issue we've been discussing in this PR no longer needs to be followed up on? Should I close this PR? |
|
@sunyuhan1998 Yes, please. Let's close this PR. |
|
Thank you for following up!
@sunyuhan1998 The audience annotation look like a right fit for the |
Background
Before this PR, when using the
@Toolannotation to define tools on the MCP server side and specifying thereturnDirectattribute, 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
returnDirectAttributeAdjusted the logic in the
McpToolUtilsclass that constructs tool declarations, ensuring that thereturnDirectattribute from the@Toolannotation is correctly retained and passed through.Implemented
getToolMetadataMethodAdded implementations of the
getToolMetadatamethod in bothAsyncMcpToolCallbackandSyncMcpToolCallbackclasses. This enables clients to retrieve tool metadata, including thereturnDirectflag.Added Unit Tests
Included corresponding unit tests to verify the correctness and stability of the above changes.
Fixes: #3481