Skip to content

Defer nimsuggest instance init out of MCP initialize handler#408

Open
ZoomRmc wants to merge 1 commit into
nim-lang:masterfrom
ZoomRmc:zdeferinit
Open

Defer nimsuggest instance init out of MCP initialize handler#408
ZoomRmc wants to merge 1 commit into
nim-lang:masterfrom
ZoomRmc:zdeferinit

Conversation

@ZoomRmc
Copy link
Copy Markdown

@ZoomRmc ZoomRmc commented May 15, 2026

The MCP initialize handler previously awaited initNimsuggestInstances before returning a response. This can be slow or hang (running nimble dump, starting nimsuggest processes). With some harnesses time-outs (30 second for OpenCode), a delayed initialize response causes the MCP connection to fail entirely, before any tool can be used.

MCP protocol expects the server to respond to initialize promptly, then handle the notifications/initialized message. Heavy initialization should happen after the handshake.

Fix: replace await with asyncSpawn so the initialize response is sent immediately and nimsuggest startup proceeds in the background.

The MCP `initialize` handler previously awaited `initNimsuggestInstances`
before returning a response. This can be slow or hang (running `nimble dump`,
starting nimsuggest processes). With some harnesses time-outs (30 second for
OpenCode), a delayed initialize response causes the MCP connection to fail
entirely, before any tool can be used.

MCP protocol expects the server to respond to `initialize` promptly,
then handle the `notifications/initialized` message.
Heavy initialization should happen after the handshake.

Fix: replace `await` with `asyncSpawn` so the initialize response is sent
immediately and nimsuggest startup proceeds in the background.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant