LSP client returns MethodNotFound (-32601) for optional requests (client/registerCapability , workspace/workspaceFolders), causing issues with matlab-language-server #2643

Closed
opened 2026-02-16 17:36:35 -05:00 by yindo · 0 comments
Owner

Originally created by @csacca on GitHub (Nov 6, 2025).

Description

Connecting OpenCode’s LSP client to the MATLAB Language Server results in server-initiated requests for optional methods that OpenCode does not currently handle. The client replies with MethodNotFound (-32601) to client/registerCapability and workspace/workspaceFolders. In practice this produces noisy logs and, with matlab-language-server, can trigger the LSP server to crash. While this is largely an LSP server robustness issue (see MATLAB-language-server #70, MATLAB-language-server #72), OpenCode should handle these optional requests gracefully to ensure interoperability.

Affected methods:

  • client/registerCapability
  • client/unregisterCapability
  • workspace/workspaceFolders

Impact:

  • Error noise in logs from MethodNotFound responses
  • matlab-language-server crash following these errors

OpenCode version

v1.0.35

Steps to reproduce

  1. Configure OpenCode to launch matlab-language-server over stdio (example opencode.json below).
  2. Start OpenCode and open a .m file within a project root.
  3. Observe inbound server requests for client/registerCapability and workspace/workspaceFolders.
  4. OpenCode replies MethodNotFound (-32601) for unhandled methods
  5. matlab-language-server crashes, OpenCode does not receive LSP Diagnostics.

Example opencode.json

{
  "$schema": "https://opencode.ai/config.json",
  "lsp": {
    "matlab": {
      "command": ["matlab-language-server", "--stdio"],
      "extensions": [".m"],
      "env": { "MLM_LICENSE_FILE": "{env:MLM_LICENSE_FILE}" },
      "initialization": {
        "MATLAB": {
          "installPath": "/opt/matlab/R2025b",
          "indexWorkspace": false,
          "matlabConnectionTiming": "onStart",
          "telemetry": false,
          "signIn": true,
          "prewarmGraphics": false
        }
      }
    }
  }
}

Screenshot and/or share link

Example traffic between opencode and matlab-langauge-server:

stdin:

Content-Length: 608

{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"rootUri":"file:///workspaces/agentic-matlab-example","processId":27266,"workspaceFolders":[{"name":"workspace","uri":"file:///workspaces/agentic-matlab-example"}],"initializationOptions":{"MATLAB":{"installPath":"/opt/matlab/R2025b","indexWorkspace":false,"matlabConnectionTiming":"onStart","telemetry":false,"signIn":true,"prewarmGraphics":false}},"capabilities":{"window":{"workDoneProgress":true},"workspace":{"configuration":true},"textDocument":{"synchronization":{"didOpen":true,"didChange":true},"publishDiagnostics":{"versionSupport":true}}}}}Content-Length: 52

{"jsonrpc":"2.0","method":"initialized","params":{}}Content-Length: 245

{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"MATLAB":{"installPath":"/opt/matlab/R2025b","indexWorkspace":false,"matlabConnectionTiming":"onStart","telemetry":false,"signIn":true,"prewarmGraphics":false}}}}Content-Length: 9598

{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///workspaces/agentic-matlab-example/pronav_intercept.m","languageId":"objective-c","version":0,"text":"%% pronav_intercept.m\n%\n% This script simulates and visualizes ..."}}}Content-Length: 103

{"jsonrpc":"2.0","id":0,"error":{"code":-32601,"message":"Unhandled method client/registerCapability"}}Content-Length: 197

{"jsonrpc":"2.0","id":1,"result":[{"MATLAB":{"installPath":"/opt/matlab/R2025b","indexWorkspace":false,"matlabConnectionTiming":"onStart","telemetry":false,"signIn":true,"prewarmGraphics":false}}]}Content-Length: 197

{"jsonrpc":"2.0","id":2,"result":[{"MATLAB":{"installPath":"/opt/matlab/R2025b","indexWorkspace":false,"matlabConnectionTiming":"onStart","telemetry":false,"signIn":true,"prewarmGraphics":false}}]}Content-Length: 197

{"jsonrpc":"2.0","id":3,"result":[{"MATLAB":{"installPath":"/opt/matlab/R2025b","indexWorkspace":false,"matlabConnectionTiming":"onStart","telemetry":false,"signIn":true,"prewarmGraphics":false}}]}

stdout:

Content-Length: 134

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":4,"message":"(02:41:58) matlabls: Log Directory: /tmp/matlabls_27270"}}Content-Length: 583

{"jsonrpc":"2.0","id":0,"result":{"capabilities":{"codeActionProvider":true,"completionProvider":{"triggerCharacters":[".","("," ",",","/","\\"]},"definitionProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"executeCommandProvider":{"commands":["matlabls.lint.suppress.line","matlabls.lint.suppress.file"]},"foldingRangeProvider":true,"referencesProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"documentSymbolProvider":true,"renameProvider":{"prepareProvider":true},"documentHighlightProvider":true,"textDocumentSync":2}}}Content-Length: 201

{"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"id":"aca83dcb-6596-4cd0-b267-0526a0f33060","method":"workspace/didChangeConfiguration","registerOptions":{}}]}}Content-Length: 101

{"jsonrpc":"2.0","id":1,"method":"workspace/configuration","params":{"items":[{"section":"MATLAB"}]}}Content-Length: 101

{"jsonrpc":"2.0","id":2,"method":"workspace/configuration","params":{"items":[{"section":"MATLAB"}]}}Content-Length: 125

{"jsonrpc":"2.0","method":"telemetry/logdata","params":{"eventKey":"ACTIONS","data":{"action_type":"openFile","result":"9"}}}Content-Length: 101

{"jsonrpc":"2.0","id":3,"method":"workspace/configuration","params":{"items":[{"section":"MATLAB"}]}}

stderr:

(node:27270) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
webpack://matlab-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:565
                        responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
^

ResponseError: Unhandled method client/registerCapability
    at handleResponse (webpack://matlab-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:565:1)
    at handleMessage (webpack://matlab-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:345:1)
    at processMessageQueue (webpack://matlab-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:362:1)
    at Immediate.<anonymous> (webpack://matlab-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:334:1)
    at process.processImmediate (node:internal/timers:485:21) {
  code: -32601,
  data: undefined
}
Thrown at:
    at handleResponse (/opt/matlab-language-server/out/index.js:43412:48)
    at handleMessage (/opt/matlab-language-server/out/index.js:43192:13)
    at processMessageQueue (/opt/matlab-language-server/out/index.js:43209:17)
    at /opt/matlab-language-server/out/index.js:43181:13
    at processImmediate (node:internal/timers:485:21)


Node.js v22.21.1

Operating System

Ubuntu 24.04.3 LTS as devcontainer (mcr.microsoft.com/devcontainers/base:ubuntu-24.04) with MATLAB feature (ghcr.io/mathworks/devcontainer-features/matlab)

Terminal

No response

Originally created by @csacca on GitHub (Nov 6, 2025). ### Description Connecting OpenCode’s LSP client to the [MATLAB Language Server](https://github.com/mathworks/MATLAB-language-server) results in server-initiated requests for optional methods that OpenCode does not currently handle. The client replies with `MethodNotFound` (-32601) to `client/registerCapability` and `workspace/workspaceFolders`. In practice this produces noisy logs and, with `matlab-language-server`, can trigger the LSP server to crash. While this is largely an LSP server robustness issue (see [MATLAB-language-server #70](https://github.com/mathworks/MATLAB-language-server/issues/70), [MATLAB-language-server #72](https://github.com/mathworks/MATLAB-language-server/issues/72)), OpenCode should handle these optional requests gracefully to ensure interoperability. Affected methods: - `client/registerCapability` - `client/unregisterCapability` - `workspace/workspaceFolders` Impact: - Error noise in logs from `MethodNotFound` responses - `matlab-language-server` crash following these errors ### OpenCode version v1.0.35 ### Steps to reproduce 1. Configure OpenCode to launch `matlab-language-server` over stdio (example `opencode.json` below). 2. Start OpenCode and open a `.m` file within a project root. 3. Observe inbound server requests for `client/registerCapability` and `workspace/workspaceFolders`. 4. OpenCode replies `MethodNotFound` (-32601) for unhandled methods 5. `matlab-language-server` crashes, OpenCode does not receive LSP Diagnostics. ### Example `opencode.json` ```json { "$schema": "https://opencode.ai/config.json", "lsp": { "matlab": { "command": ["matlab-language-server", "--stdio"], "extensions": [".m"], "env": { "MLM_LICENSE_FILE": "{env:MLM_LICENSE_FILE}" }, "initialization": { "MATLAB": { "installPath": "/opt/matlab/R2025b", "indexWorkspace": false, "matlabConnectionTiming": "onStart", "telemetry": false, "signIn": true, "prewarmGraphics": false } } } } } ``` ### Screenshot and/or share link ### Example traffic between `opencode` and `matlab-langauge-server`: `stdin`: ```plaintext Content-Length: 608 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"rootUri":"file:///workspaces/agentic-matlab-example","processId":27266,"workspaceFolders":[{"name":"workspace","uri":"file:///workspaces/agentic-matlab-example"}],"initializationOptions":{"MATLAB":{"installPath":"/opt/matlab/R2025b","indexWorkspace":false,"matlabConnectionTiming":"onStart","telemetry":false,"signIn":true,"prewarmGraphics":false}},"capabilities":{"window":{"workDoneProgress":true},"workspace":{"configuration":true},"textDocument":{"synchronization":{"didOpen":true,"didChange":true},"publishDiagnostics":{"versionSupport":true}}}}}Content-Length: 52 {"jsonrpc":"2.0","method":"initialized","params":{}}Content-Length: 245 {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"MATLAB":{"installPath":"/opt/matlab/R2025b","indexWorkspace":false,"matlabConnectionTiming":"onStart","telemetry":false,"signIn":true,"prewarmGraphics":false}}}}Content-Length: 9598 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///workspaces/agentic-matlab-example/pronav_intercept.m","languageId":"objective-c","version":0,"text":"%% pronav_intercept.m\n%\n% This script simulates and visualizes ..."}}}Content-Length: 103 {"jsonrpc":"2.0","id":0,"error":{"code":-32601,"message":"Unhandled method client/registerCapability"}}Content-Length: 197 {"jsonrpc":"2.0","id":1,"result":[{"MATLAB":{"installPath":"/opt/matlab/R2025b","indexWorkspace":false,"matlabConnectionTiming":"onStart","telemetry":false,"signIn":true,"prewarmGraphics":false}}]}Content-Length: 197 {"jsonrpc":"2.0","id":2,"result":[{"MATLAB":{"installPath":"/opt/matlab/R2025b","indexWorkspace":false,"matlabConnectionTiming":"onStart","telemetry":false,"signIn":true,"prewarmGraphics":false}}]}Content-Length: 197 {"jsonrpc":"2.0","id":3,"result":[{"MATLAB":{"installPath":"/opt/matlab/R2025b","indexWorkspace":false,"matlabConnectionTiming":"onStart","telemetry":false,"signIn":true,"prewarmGraphics":false}}]} ``` `stdout`: ```plaintext Content-Length: 134 {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":4,"message":"(02:41:58) matlabls: Log Directory: /tmp/matlabls_27270"}}Content-Length: 583 {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"codeActionProvider":true,"completionProvider":{"triggerCharacters":[".","("," ",",","/","\\"]},"definitionProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"executeCommandProvider":{"commands":["matlabls.lint.suppress.line","matlabls.lint.suppress.file"]},"foldingRangeProvider":true,"referencesProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"documentSymbolProvider":true,"renameProvider":{"prepareProvider":true},"documentHighlightProvider":true,"textDocumentSync":2}}}Content-Length: 201 {"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"id":"aca83dcb-6596-4cd0-b267-0526a0f33060","method":"workspace/didChangeConfiguration","registerOptions":{}}]}}Content-Length: 101 {"jsonrpc":"2.0","id":1,"method":"workspace/configuration","params":{"items":[{"section":"MATLAB"}]}}Content-Length: 101 {"jsonrpc":"2.0","id":2,"method":"workspace/configuration","params":{"items":[{"section":"MATLAB"}]}}Content-Length: 125 {"jsonrpc":"2.0","method":"telemetry/logdata","params":{"eventKey":"ACTIONS","data":{"action_type":"openFile","result":"9"}}}Content-Length: 101 {"jsonrpc":"2.0","id":3,"method":"workspace/configuration","params":{"items":[{"section":"MATLAB"}]}} ``` `stderr`: ```plaintext (node:27270) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead. (Use `node --trace-deprecation ...` to show where the warning was created) webpack://matlab-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:565 responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data)); ^ ResponseError: Unhandled method client/registerCapability at handleResponse (webpack://matlab-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:565:1) at handleMessage (webpack://matlab-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:345:1) at processMessageQueue (webpack://matlab-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:362:1) at Immediate.<anonymous> (webpack://matlab-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:334:1) at process.processImmediate (node:internal/timers:485:21) { code: -32601, data: undefined } Thrown at: at handleResponse (/opt/matlab-language-server/out/index.js:43412:48) at handleMessage (/opt/matlab-language-server/out/index.js:43192:13) at processMessageQueue (/opt/matlab-language-server/out/index.js:43209:17) at /opt/matlab-language-server/out/index.js:43181:13 at processImmediate (node:internal/timers:485:21) Node.js v22.21.1 ``` ### Operating System Ubuntu 24.04.3 LTS as devcontainer (mcr.microsoft.com/devcontainers/base:ubuntu-24.04) with MATLAB feature (ghcr.io/mathworks/devcontainer-features/matlab) ### Terminal _No response_
yindo added the opentuibug labels 2026-02-16 17:36:35 -05:00
yindo closed this issue 2026-02-16 17:36:35 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2643