Function: claude-code-ide-mcp--on-message
claude-code-ide-mcp--on-message is a natively compiled function
defined in claude-code-ide-mcp.el.
Signature
(claude-code-ide-mcp--on-message SESSION WS FRAME)
Documentation
Handle incoming WebSocket message from WS in FRAME for SESSION.
Source Code
;; Defined in /nix/store/yjvbhwl7p6zrbw9xlnni7y4hra8sa3pl-emacs-packages-deps/share/emacs/site-lisp/claude-code-ide-mcp.el
(defun claude-code-ide-mcp--on-message (session ws frame)
"Handle incoming WebSocket message from WS in FRAME for SESSION."
(claude-code-ide-debug "=== Received WebSocket frame ===")
;; Check if frame is actually a frame struct
;; In some edge cases, the websocket library might pass something else
(condition-case err
(progn
;; Try to get the opcode - this will fail if frame is not a proper struct
(claude-code-ide-debug "Frame opcode: %s" (websocket-frame-opcode frame))
;; Ignore traffic from a socket this session no longer owns
;; (it was replaced by a reconnect and is about to close)
(if (eq ws (claude-code-ide-mcp-session-client session))
(let* ((text (websocket-frame-text frame))
(message (condition-case err
(json-read-from-string text)
(error
(claude-code-ide-debug "JSON parse error: %s" err)
(claude-code-ide-debug "Raw text: %s" text)
(claude-code-ide-debug "Failed to parse JSON: %s" err)
nil))))
(claude-code-ide-debug "Received: %s" text)
(claude-code-ide-debug "MCP received: %s" text)
(when message
(claude-code-ide-mcp--handle-message message session ws)))
(claude-code-ide-debug "Ignoring message from replaced WebSocket client")))
(error
;; If we get an error accessing frame properties, log it and continue
(claude-code-ide-debug "Error processing WebSocket frame: %s" err)
(claude-code-ide-debug "Frame type: %s, Frame value: %S" (type-of frame) frame)
;; If frame is a string, it might be raw text data
(when (stringp frame)
(claude-code-ide-debug "Received raw string instead of frame: %s" frame))
;; Don't crash the connection, just skip this message
nil)))