MCPcopy Index your code
hub / github.com/codeaashu/claude-code / send

Method send

src/utils/mcpWebSocketTransport.ts:173–199  ·  view source on GitHub ↗

* Sends a JSON-RPC message over the WebSocket connection.

(message: JSONRPCMessage)

Source from the content-addressed store, hash-verified

171 * Sends a JSON-RPC message over the WebSocket connection.
172 */
173 async send(message: JSONRPCMessage): Promise<void> {
174 if (this.ws.readyState !== WS_OPEN) {
175 logForDiagnosticsNoPII('error', 'mcp_websocket_send_not_opened')
176 throw new Error('WebSocket is not open. Cannot send message.')
177 }
178 const json = jsonStringify(message)
179
180 try {
181 if (this.isBun) {
182 // Native WebSocket.send() is synchronous (no callback)
183 this.ws.send(json)
184 } else {
185 await new Promise<void>((resolve, reject) => {
186 ;(this.ws as unknown as WsWebSocket).send(json, error => {
187 if (error) {
188 reject(error)
189 } else {
190 resolve()
191 }
192 })
193 })
194 }
195 } catch (error) {
196 this.handleError(error)
197 throw error
198 }
199 }
200}
201

Callers

nothing calls this directly

Calls 5

handleErrorMethod · 0.95
logForDiagnosticsNoPIIFunction · 0.85
jsonStringifyFunction · 0.85
resolveFunction · 0.70
sendMethod · 0.65

Tested by

no test coverage detected