Skip to content

Server crashes with "Unexpected end of JSON input" when connected from an SSE client via ngrok #1

@Geefer1985

Description

@Geefer1985

Describe the bug
When running the server via the npx command and connecting to it from a standard SSE client through an ngrok tunnel, the server process crashes instantly upon receiving the first connection request. The crash appears to be caused by the server trying to JSON.parse a raw HTTP request.

Steps to Reproduce

  1. Start an ngrok tunnel: ngrok http 8008 --request-header-add "ngrok-skip-browser-warning: true"
  2. Start the server with a valid API key: LIMITLESS_API_KEY="sk-..." npx 199bio-mcp-limitless-server
  3. The server logs: Limitless MCP Server starting...
  4. Connect a client (e.g., an app that connects to a custom SSE URL) to the ngrok forwarding address.
  5. The ngrok console shows a 502 Bad Gateway error.
  6. The server terminal shows no immediate output, but after pressing Enter, the following stack trace is revealed:

Error Log
MCP Server Error: SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at deserializeMessage (file:///Users/someuser/.npm/_npx/17fdf017b1962859/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:26:44)
at ReadBuffer.readMessage (file:///Users/someuser/.npm/_npx/17fdf017b1962859/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:19:16)
at StdioServerTransport.processReadBuffer (file:///Users/someuser/.npm/_npx/17fdf017b1962859/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js:39:50)
at StdioServerTransport._ondata (file:///Users/someuser/.npm/_npx/17fdf017b1962859/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js:17:18)
at ReadStream.emit (node:events:507:28)
at addChunk (node:internal/streams/readable:559:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
at Readable.push (node:internal/streams/readable:390:5)
at TTY.onStreamRead (node:internal/stream_base_commons:189:23)

Expected behavior
The server should be able to handle an incoming HTTP/SSE connection from a standard client without crashing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions