serena icon indicating copy to clipboard operation
serena copied to clipboard

SSE Transport Mode Fails with Dynamic Client Registration Error

Open patrickrho opened this issue 6 months ago • 6 comments

Problem Description

When running multiple Claude Code instances (multiple terminals with claude), each instance spawns its own Serena MCP server process. For large codebases, this leads to significant RAM consumption as each server instance loads the entire project context into memory. This becomes unsustainable when running multiple Claude Code sessions in parallel.

Current Behavior (stdio mode)

  • Each Claude Code instance starts its own Serena MCP server
  • Multiple parallel sessions = multiple server instances
  • Large codebases consume substantial RAM per instance

Attempted Solution (SSE mode)

Tried to use SSE transport mode to have multiple clients connect to a single server instance, but encountering an error that prevents the server from working.

Steps to Reproduce

  1. Start Serena MCP server in SSE mode:
uv run serena-mcp-server --transport sse --port 9121 --context ide-assistant --project /path/to/large/project
  1. Server starts successfully:
INFO: Started server process [79602]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:9121 (Press CTRL+C to quit)
  1. Configure Claude Desktop to connect via SSE:
{
  "mcpServers": {
    "serena": {
      "type": "sse",
      "url": "http://localhost:9121"
    }
  }
}
  1. Connection attempt fails with:
INFO: 127.0.0.1:60690 - "GET / HTTP/1.1" 404 Not Found
INFO: 127.0.0.1:60722 - "GET /.well-known/oauth-authorization-server HTTP/1.1" 404 Not Found
INFO: 127.0.0.1:60725 - "POST /register HTTP/1.1" 404 Not Found
--- From Claude Code logs
│ Status: ✘ failed
│ URL: http://localhost:9121
│ Error: Dynamic client registration failed: HTTP 404

Expected Behavior

SSE mode should allow multiple Claude Code/Claude Desktop instances to connect to a single Serena MCP server, reducing overall memory consumption.

Impact

This issue is critical for users who:

  • Work with large codebases
  • Run multiple Claude Code sessions in parallel
  • Have multiple Anthropic accounts and use them simultaneously
  • Need to manage RAM consumption on their development machines

patrickrho avatar Jun 20 '25 09:06 patrickrho

I kept seeing 404 with every transport (including sse), not even for multiple clients.. I'm using Claude Code and finally got it working by providing the server url with the /sse path (I'm on main - f607b76a1f9132450f25e6799fec246aa729292f)

concrete - I run standalone server as follows:

uv run serena-mcp-server --port 8081 --project /home/vincent/tcons/TerraTitan --transport sse --context ide-assistant

I add mcp server to Claude Code as follows:

claude mcp add --transport sse serena -- http://localhost:8081/sse

Altho it seems SSE will be removed (currently deprecated) in MCP? https://modelcontextprotocol.io/docs/concepts/transports#server-sent-events-sse-deprecated

vincenthsh avatar Jun 22 '25 12:06 vincenthsh

Oh, wow, being deprecated so fast after being introduced... Thanks for the heads-up, I was not aware of it.

I will devote some time to improving documentation and functionality around sse (or http) and docker based setup next week

MischaPanch avatar Jun 26 '25 20:06 MischaPanch

@patrickrho @alex-paru @crushjz:

as @vincenthsh mentioned, you probably just have to add /sse to the url, I adjusted the readme accordingly now

MischaPanch avatar Jun 26 '25 20:06 MischaPanch

It's still wrong in the Readme. 🙈

foertel avatar Jun 27 '25 10:06 foertel

@foertel thx, missed that spot! Gonna fix

MischaPanch avatar Jun 27 '25 11:06 MischaPanch

Thanks! By the way, the doc says "http://localhost/sse:9121" but it should really be http://localhost:9121/sse :)

patrickrho avatar Jun 29 '25 09:06 patrickrho