feat(mcp-client): add support for server-provided returnDirect, with … - #4246
feat(mcp-client): add support for server-provided returnDirect, with …#4246eeaters wants to merge 1 commit into
Conversation
…client-level default - Add `returnDirect` configuration to client properties - Set default toolAnnotations in client by merging server and client values - Add returnDirect handling to MCPToolBack Signed-off-by: eeaters <870905780@qq.com>
|
Thank you for your contribution! I was wondering if this PR addresses the same issue as the previous one: #3787? |
Yes, I saw this PR. However, I think it's somewhat risky to have this parameter entirely controlled by the server side. Therefore, I tried to extend the MCP SDK to also give the client-side the ability to control this parameter simultaneously. |
I understand now, thank you for the explanation, it looks great! |
Background
When migrating local Tools to a standalone service, the returnDirect property stopped working because ToolMetadata in the MCP client currently ignores client-side attributes. Although the MCP SDK schema already defines this field, its logic has not yet been implemented. I previously submitted PR #513
to address this gap, and this change builds on top of that work.
Change Summary
This update allows the client to apply a global configuration for a specific server. The final returnDirect value is computed by merging client and server settings, requiring both sides to be true for the property to take effect.
Because client-side attributes are spread across multiple configuration sources, I introduced a composite class to unify the logic. This is an initial approach; I haven't yet found a cleaner solution. If there are better implementation ideas, I would greatly appreciate suggestions.
This PR addresses and fixes the issues described in ISSUE #3481