fix: Fixed the issue where the returnDirect attribute was not effective on the MCP server side.#3787
fix: Fixed the issue where the returnDirect attribute was not effective on the MCP server side.#3787sunyuhan1998 wants to merge 7 commits intospring-projects:mainfrom
Conversation
…not effective on the MCP server side. Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
… unit tests. Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
|
@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 <01086055223@hanmail.net>
# 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 <sunyuhan1998@users.noreply.github.com>
Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
|
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