Table of Contents

Method SendRequestAsync

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

SendRequestAsync(long, string, object, CancellationToken)

Sends a JSON-RPC request and waits for the corresponding response.

Task<JsonDocument> SendRequestAsync(long id, string method, object parameters, CancellationToken cancellationToken = default)

Parameters

id long

The unique request identifier for response correlation.

method string

The JSON-RPC method name (e.g., "initialize", "tools/list").

parameters object

The method parameters, or null if none.

cancellationToken CancellationToken

A token to cancel the request.

Returns

Task<JsonDocument>

A task that completes with the JSON-RPC response document. The caller is responsible for disposing the returned JsonDocument.

Exceptions

McpTransportException

Thrown on transport-level failures.

TimeoutException

Thrown when the request times out waiting for a response.

OperationCanceledException

Thrown when the operation is canceled.

InvalidOperationException

Thrown when the transport is not connected.