Table of Contents

Method RegisterAsync

Namespace
LMKit.Agents.Tools
Assembly
LM-Kit.NET.dll

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

mcpClient McpClient

Initialized MCP client.

overwrite bool

If true, replaces existing tools with the same name.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<int>

The number of tools successfully registered.

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

mcpClient McpClient

Initialized MCP client.

filter Func<McpTool, bool>

Optional predicate to include/exclude tools. Pass null to include all.

overwrite bool

If true, replaces existing tools with the same name.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<int>

The number of tools successfully registered.

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).