claude-code-lsps icon indicating copy to clipboard operation
claude-code-lsps copied to clipboard

[kotlin-lsp] Server hangs at 'starting' — missing --stdio flag

Open Ganon-M opened this issue 6 months ago • 1 comments

Plugin Information

Plugin name: kotlin-lsp Plugin version: 1.0.0

Environment

Claude Code version: 2.1.152 Operating System: macOS 26.3 (arm64) LSP server version: kotlin-lsp LS-262.4739.0 (installed via brew install JetBrains/utils/kotlin-lsp)

Description

After installing the kotlin-lsp plugin via /plugin and reloading, any LSP operation against a .kt file hangs indefinitely. Claude Code reports server is starting for the LSP MCP server and never recovers — I waited ~5 minutes before investigating.

Root cause

The plugin's .lsp.json invokes kotlin-lsp with no arguments. Per kotlin-lsp --help:

--stdio Whether the Kotlin LSP server is used in stdio mode. If not set, server mode will be used with a port specified by socket (default 127.0.0.1:9999)

So without --stdio, the binary launches in TCP socket mode and never reads from stdin. Claude Code's LSP bridge speaks stdio LSP (stdin/stdout are wired as unix sockets to the child), so the initialize request goes into a black hole and the bridge sits in a starting state forever.

Evidence from a hung session:

  • kotlin-lsp process at 0% CPU, sleeping, with LISTEN on 127.0.0.1:9876 (intellij-server's default TCP port).
  • The LSP's own log (<tmp>/idea-system.../system/log/intellij-server.log) ends right after Server extensions loaded + system info dump — no initialize, no workspace open, no indexing. Confirms the server received nothing over stdin.
  • Adding --stdio resolves the hang and the LSP starts indexing the workspace as expected.

Steps to Reproduce

  1. Install the kotlin-lsp plugin from the marketplace.
  2. Restart Claude Code so the LSP MCP bridge spawns kotlin-lsp.
  3. Run any LSP operation against a .kt file (e.g. documentSymbol).
  4. The call hangs / returns server is starting; the LSP log shows no incoming requests.

Expected Behavior

The LSP responds to initialize and indexes the workspace.

Actual Behavior

kotlin-lsp runs in TCP socket mode, ignores stdin, and the MCP bridge times out / never marks the server as ready.

Fix

Patch kotlin-lsp/.lsp.json to pass --stdio. The schema used by sibling plugins (ocaml-lsp, omnisharp) is command as a string + separate args array:

{
  "kotlin": {
    "command": "kotlin-lsp",
    "args": ["--stdio"],
    "extensionToLanguage": {
      ".kt": "kotlin",
      ".kts": "kotlin"
    }
  }
}

Verified working locally against keyboard-quest (an Android/Kotlin project).

Additional Context

  • First indexing pass is slow (kotlin-lsp wraps a full IntelliJ platform, ~1.3 GB install) but that's expected and unrelated to this bug.
  • Happy to send a PR if helpful.

Ganon-M avatar May 27 '26 21:05 Ganon-M

Confirming the proposed fix works.

Patched my local install — added "args": ["--stdio"] to .lsp.json, restarted Claude Code, made a documentSymbol LSP call against a real .kt file. The LSP responded normally (~7s for spawn + initial indexing).

The spawned process now correctly has argv kotlin-lsp --stdio:

ps -axo pid,comm,args | grep kotlin-lsp
82057 kotlin-lsp       kotlin-lsp --stdio

Gotcha for anyone self-patching ahead of a release

Claude Code reads .lsp.json from the per-version cache copy, not the marketplace source. If you patch only ~/.claude/plugins/marketplaces/claude-code-lsps/kotlin-lsp/.lsp.json, restarts won't pick it up. The cache copy lives at:

~/.claude/plugins/cache/claude-code-lsps/kotlin-lsp/<version>/.lsp.json

Easiest options: edit both, or edit the cache copy and re-run /plugin to refresh after the fix is published. (Not the plugin's problem — just worth flagging.)

Happy to open a PR with the one-line change if useful.

Ganon-M avatar May 27 '26 22:05 Ganon-M