Skip to content

MCP stdio: write NDJSON so Cursor can discover search_docs - #13

Merged
alex-16moro merged 1 commit into
mainfrom
cursor/mcp-ndjson-stdio-3eed
Sep 20, 2026
Merged

alex-16moro merged 1 commit into
mainfrom
cursor/mcp-ndjson-stdio-3eed

Conversation

@alex-16moro

Copy link
Copy Markdown
Owner

Summary

Cursor MCP stdio expects newline-delimited JSON. The docs server was writing LSP Content-Length frames, which broke live tool discovery (search_docs).

  • _write_message now emits one JSON object per line
  • Reader still accepts Content-Length and NDJSON
  • --selftest parses NDJSON
  • overlay/mcp.optional.json uses workspace-relative .cursor/mcp-diffusers-docs.py (not /workspace/...)

Default overlay mcp.json stays empty ({}).

Convention gate

Tooling only. examples/scaffolded_scheduler unchanged.

Tests run

printf '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05"}}\n{"jsonrpc":"2.0","id":2,"method":"tools/list"}\n' | python3 -u .cursor/mcp-diffusers-docs.py
python3 tools/docs_mcp_server.py --selftest
python3 -m unittest discover -s tests -t .
python3 -c "import yaml"

Handshake prints two bare JSON lines, search_docs is listed, no Content-Length. 43 tests, 4 skipped. PyYAML imports on /usr/bin/python3.

Open in Web Open in Cursor 

Cursor live tool discovery expects newline-delimited JSON. Keep a
dual-mode reader. Opt-in overlay MCP uses a workspace-relative launcher
path for local Desktop.

Co-authored-by: ale93.moro <ale93.moro@gmail.com>
@alex-16moro
alex-16moro marked this pull request as ready for review September 20, 2026 10:35
@alex-16moro
alex-16moro merged commit 9584b8c into main Sep 20, 2026
1 check passed
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.

2 participants