Table of Contents

Interface IMcpTransport

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

Defines the transport layer abstraction for MCP (Model Context Protocol) communication.

public interface IMcpTransport : IDisposable
Inherited Members

Remarks

Implementations handle the low-level message exchange with MCP servers using different transport mechanisms. The MCP specification supports multiple transport types:

  • HTTP + SSE: HTTP POST for requests, Server-Sent Events for notifications
  • Stdio: Process-based communication via stdin/stdout (JSONL format)
  • Custom: WebSocket, Unix sockets, or other mechanisms

All transport implementations must be thread-safe for concurrent request/notification operations.

Properties

IsConnected

Gets whether the transport connection is currently established and ready for communication.

TransportType

Gets the transport type identifier for logging and diagnostics.

Methods

CloseAsync(CancellationToken)

Closes the transport connection gracefully.

ConnectAsync(CancellationToken)

Establishes the transport connection asynchronously.

SendNotificationAsync(string, object, CancellationToken)

Sends a JSON-RPC notification (fire-and-forget, no response expected).

SendRequestAsync(long, string, object, CancellationToken)

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

Events

Disconnected

Raised when the transport connection is unexpectedly lost.

ServerNotificationReceived

Raised when a server-initiated notification is received.