Skip to content

Commit 5374356

Browse files
Pascual Munoz Galianclaude
andcommitted
fix: mark client initialized after initialize handshake
Many real-world MCP clients (Claude Code, Gemini/Antigravity, Nova) complete the initialize handshake and immediately call tools/list or tools/call without sending the notifications/initialized notification. Currently, initialized is only set to true in handleNotificationInitialized(), so these clients get permanently locked out with "Client session not initialized" errors. This change marks the session as initialized right after a successful initialize response. If a client still sends notifications/initialized, handleNotificationInitialized() sets the flag again — a harmless no-op. Discovered while running a production MCP server (Cohete blog) that serves Claude Code, Nova, and custom MCP clients over SSE transport. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d2c5833 commit 5374356

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/Dispatcher.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ public function handleInitialize(InitializeRequest $request, SessionInterface $s
128128
$session->set('client_info', $request->clientInfo->toArray());
129129
$session->set('protocol_version', $protocolVersion);
130130

131+
// Mark client as initialized immediately after successful handshake.
132+
// Many real-world MCP clients (Claude Code, Gemini, Nova) skip
133+
// the notifications/initialized step, causing "Client session not
134+
// initialized" errors on all subsequent requests.
135+
$session->set('initialized', true);
136+
131137
$serverInfo = $this->configuration->serverInfo;
132138
$capabilities = $this->configuration->capabilities;
133139
$instructions = $this->configuration->instructions;

0 commit comments

Comments
 (0)