Skip to content

Bug report: Streamable HTTP transport fails with "Server already initialized" error across multiple clients #36

Description

@Saifaldeen-sl

Description
When utilizing Streamable HTTP transport mode, the server consistently rejects connection attempts from standard MCP clients (LM Studio, Lobe, MCP Inspector) with a JSON-RPC error. The server correctly processes stdio transport requests, indicating the issue is isolated to the HTTP transport lifecycle/handshake management.

Error Message

{"jsonrpc":"2.0","error":{"code":-32600,"message":"Invalid Request: Server already initialized"},"id":null}

To Reproduce

  1. Run the container with HTTP transport:

    docker run --rm -p 4000:3000 \
      -e CYBERCHEF_TRANSPORT=http \
      -e CYBERCHEF_HTTP_PORT=3000 \
      -e CYBERCHEF_HTTP_HOST=0.0.0.0 \
      ghcr.io/doublegate/cyberchef-mcp_v1:latest
  2. Attempt to connect using an MCP client (e.g., LM Studio, Lobe, or MCP Inspector) using http://127.0.0.1:4000/mcp.

  3. Observe the Server already initialized error during the client's connection/probing phase.

Expected Behavior
The server should negotiate the connection handshake without rejecting the formal initialize request following the client's discovery probe.

Environment

  • OS: Windows 11 / Docker v4.45
  • **MCP Client: ** LM Studio, Lobe, @modelcontextprotocol/inspector and webui
  • Transport Mode: Streamable HTTP

more details
Many MCP clients perform an initial discovery/probing request to the endpoint. It appears this initial probe initializes the global Server instance. Consequently, when the client sends the subsequent formal initialize handshake, the SDK rejects it because the server state is already marked as initialized.

While stdio transport functions as expected, the HTTP transport implementation currently prevents compatibility with clients that utilize these discovery protocols.

Thank you for your work on this project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions