Sync& mcp tool callback addmethod #3894
Open
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.
Add filtered constructors for MCP Tool Callback Providers
This PR introduces new constructors for both
SyncMcpToolCallbackProvider
andAsyncMcpToolCallbackProvider
to allow initialization with a filtered subset of MCP clients based on allowed server names.Changes
Added a constructor to
SyncMcpToolCallbackProvider
that:McpSyncClient
instances and a set of allowed server namesAdded a similar constructor to
AsyncMcpToolCallbackProvider
forMcpAsyncClient
Ensured that both constructors validate non-null and non-empty input parameters
Motivation
When building large-scale AI workflows, users may want to initialize tool callback providers with only a subset of trusted or registered MCP servers. These new constructors provide a convenient way to restrict tool resolution to specific servers without affecting existing usage.
Compatibility
These additions are non-breaking and fully backward-compatible. Default constructors remain unchanged.
Why Add Server Filtering?
Before: Manual filtering + duplicate checks.
After: Single-line reactive filtering with validation.
// Cleaner, safer usage
Flux tools = asyncToolCallbacksByServer(clients, allowedServers);