MCP Server Framework - v1.0.0
    Preparing search index...

    Interface HeartbeatCapableTransport

    Transport that optionally supports heartbeat (keep-alive).

    Some transports (like StreamableHTTPServerTransport) support sendHeartbeat but it's not in the public SDK types.

    interface HeartbeatCapableTransport {
        onclose?: () => void;
        onerror?: (error: Error) => void;
        onmessage?: <T extends JSONRPCMessage>(
            message: T,
            extra?: MessageExtraInfo,
        ) => void;
        sendHeartbeat: () => boolean;
        sessionId?: string;
        setProtocolVersion?: (version: string) => void;
        close(): Promise<void>;
        send(
            message: JSONRPCMessage,
            options?: TransportSendOptions,
        ): Promise<void>;
        start(): Promise<void>;
    }

    Hierarchy

    • Transport
      • HeartbeatCapableTransport
    Index

    Properties

    onclose?: () => void

    Callback for when the connection is closed for any reason.

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

    onerror?: (error: Error) => void

    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.

    onmessage?: <T extends JSONRPCMessage>(
        message: T,
        extra?: MessageExtraInfo,
    ) => void

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

    sendHeartbeat: () => boolean

    Sends a heartbeat to check if the connection is still alive.

    Type Declaration

      • (): boolean
      • Returns boolean

        true if heartbeat was sent successfully

    sessionId?: string

    The session ID generated for this connection.

    setProtocolVersion?: (version: string) => void

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

    Methods

    • Closes the connection.

      Returns Promise<void>

    • 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
      • Optionaloptions: TransportSendOptions

      Returns Promise<void>

    • 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>