feat(mcp-client): add support for server-provided returnDirect, with … #4246
+108
−16
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
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