Table of Contents

Method InitializeAsync

Namespace
LMKit.Mcp.Client
Assembly
LM-Kit.NET.dll

InitializeAsync(CancellationToken)

Ensures the MCP session is initialized. If already initialized, returns a clone of the cached initialize response. If not, performs initialize and then notifications/initialized, caching the session id and payload. All concurrent callers await the same initialization task.

public Task<JsonDocument> InitializeAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task<JsonDocument>

A clone of the JSON-RPC initialize response document.

Exceptions

ObjectDisposedException

If the client has been disposed.

HttpRequestException

On HTTP or JSON-RPC errors.