Method RegisterAsync
RegisterAsync(McpClient, bool, CancellationToken)
Registers all tools returned by the given McpClient using their original names.
public Task<int> RegisterAsync(McpClient mcpClient, bool overwrite = false, CancellationToken cancellationToken = default)
Parameters
mcpClientMcpClientInitialized MCP client.
overwriteboolIf true, replaces existing tools with the same name.
cancellationTokenCancellationTokenCancellation token.
Returns
Remarks
This method does not rename tools. If a tool name already exists in the registry and overwrite is false,
Register(ITool, bool) will throw an InvalidOperationException.
The registration pipeline obtains tools via GetToolsAsync(CancellationToken) and delegates per-tool validation to Register(ITool, bool).
RegisterAsync(McpClient, Func<McpTool, bool>, bool, CancellationToken)
Registers all tools returned by the given McpClient using their original names, with an optional filter and overwrite behavior.
public Task<int> RegisterAsync(McpClient mcpClient, Func<McpTool, bool> filter = null, bool overwrite = false, CancellationToken cancellationToken = default)
Parameters
mcpClientMcpClientInitialized MCP client.
filterFunc<McpTool, bool>Optional predicate to include/exclude tools. Pass
nullto include all.overwriteboolIf true, replaces existing tools with the same name.
cancellationTokenCancellationTokenCancellation token.
Returns
Remarks
Retrieves tools via GetToolsAsync(CancellationToken),
applies filter (when provided), and registers each tool through Register(ITool, bool).
Invalid or unnamed tools are ignored. Schema validation and name uniqueness are enforced by Register(ITool, bool).