@nogoo9/mcp-server-cloud-fs / WebSocketServerTransport
Class: WebSocketServerTransport
Defined in: transports/ws.ts:33
WebSocket server transport adapter. Wraps a Bun WebSocket connection to implement the MCP SDK Transport interface.
Implements
Transport
Constructors
Constructor
new WebSocketServerTransport(
sessionId):WebSocketServerTransport
Defined in: transports/ws.ts:48
Parameters
sessionId
string
Returns
WebSocketServerTransport
Properties
onclose?
optionalonclose?: () =>void
Defined in: transports/ws.ts:35
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?
optionalonerror?: (error) =>void
Defined in: transports/ws.ts:36
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?
optionalonmessage?: <T>(message,extra?) =>void
Defined in: transports/ws.ts:37
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?
optionalsessionId?:string
Defined in: transports/ws.ts:34
The session ID generated for this connection.
Implementation of
Transport.sessionId
Methods
attachSocket()
attachSocket(
ws):void
Defined in: transports/ws.ts:53
Attach the underlying WebSocket. Called internally when WS is upgraded.
Parameters
ws
readyState
number
close
send
Returns
void
close()
close():
Promise<void>
Defined in: transports/ws.ts:91
Closes the connection.
Returns
Promise<void>
Implementation of
Transport.close
handleClose()
handleClose():
void
Defined in: transports/ws.ts:72
Called when the WebSocket is closed.
Returns
void
handleMessage()
handleMessage(
data):void
Defined in: transports/ws.ts:62
Process an incoming text message from the WebSocket.
Parameters
data
string
Returns
void
send()
send(
message,_options?):Promise<void>
Defined in: transports/ws.ts:81
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: transports/ws.ts:77
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
