Skip to content

Documentation / @agentick/mcp / InMemoryTransport

Class: InMemoryTransport ​

Defined in: transport/in-memory.ts:28

Implements ​

  • Transport

Constructors ​

Constructor ​

new InMemoryTransport(): InMemoryTransport

Returns ​

InMemoryTransport

Properties ​

onclose()? ​

optional onclose: () => void

Defined in: transport/in-memory.ts:33

Callback for when the connection is closed for any reason.

This should be invoked when close() is called as well.

Returns ​

void

Implementation of ​

Transport.onclose


onerror()? ​

optional onerror: (error) => void

Defined in: transport/in-memory.ts:34

Callback for when an error occurs.

Note that errors are not necessarily fatal; they are used for reporting any kind of exceptional condition out of band.

Parameters ​

error ​

Error

Returns ​

void

Implementation of ​

Transport.onerror


onmessage()? ​

optional onmessage: <T>(message, extra?) => void

Defined in: transport/in-memory.ts:32

Callback for when a message (request or response) is received over the connection.

Includes the requestInfo and authInfo if the transport is authenticated.

The requestInfo can be used to get the original request information (headers, etc.)

Type Parameters ​

T ​

T extends JSONRPCMessage

Parameters ​

message ​

T

extra? ​

MessageExtraInfo

Returns ​

void

Implementation of ​

Transport.onmessage


sessionId? ​

optional sessionId: string

Defined in: transport/in-memory.ts:35

The session ID generated for this connection.

Implementation of ​

Transport.sessionId


setProtocolVersion()? ​

optional setProtocolVersion: (version) => void

Defined in: transport/in-memory.ts:36

Sets the protocol version used for the connection (called when the initialize response is received).

Parameters ​

version ​

string

Returns ​

void

Implementation of ​

Transport.setProtocolVersion

Methods ​

close() ​

close(): Promise<void>

Defined in: transport/in-memory.ts:57

Closes the connection.

Returns ​

Promise<void>

Implementation of ​

Transport.close


createLinkedPair() ​

static createLinkedPair(): [InMemoryTransport, InMemoryTransport]

Defined in: transport/in-memory.ts:42

Creates a linked pair of transports. One goes to the Client, the other to the Server. Messages sent on one are delivered to the other.

Returns ​

[InMemoryTransport, InMemoryTransport]


send() ​

send(message, _options?): Promise<void>

Defined in: transport/in-memory.ts:64

Sends a JSON-RPC message (request or response).

If present, relatedRequestId is used to indicate to the transport which incoming request to associate this outgoing message with.

Parameters ​

message ​

JSONRPCMessage

_options? ​

TransportSendOptions

Returns ​

Promise<void>

Implementation of ​

Transport.send


start() ​

start(): Promise<void>

Defined in: transport/in-memory.ts:50

Starts processing messages on the transport, including any connection steps that might need to be taken.

This method should only be called after callbacks are installed, or else messages may be lost.

NOTE: This method should not be called explicitly when using Client, Server, or Protocol classes, as they will implicitly call start().

Returns ​

Promise<void>

Implementation of ​

Transport.start

Released under the ISC License.