Skip to content

fix(mcp): clear initialize response suppression after first match#625

Open
chiehwangs wants to merge 1 commit into
colbymchenry:mainfrom
chiehwangs:codex/fix-mcp-proxy-reused-initialize-id
Open

fix(mcp): clear initialize response suppression after first match#625
chiehwangs wants to merge 1 commit into
colbymchenry:mainfrom
chiehwangs:codex/fix-mcp-proxy-reused-initialize-id

Conversation

@chiehwangs
Copy link
Copy Markdown

Description

The local-handshake proxy immediately returns an initialize response while the shared daemon connects in the background. It forwards the initialize request to the daemon and suppresses the daemon's duplicate response. However, a later JSON-RPC request can reuse the initialize request ID after the handshake completes. In that case, the proxy incorrectly drops the later response.

Root Cause

The proxy stores the initialize request ID in clientInitId to identify the daemon's duplicate initialize response. After filtering the matching response, it leaves clientInitId unchanged. The suppression logic therefore continues matching every later daemon response with the same request ID.

Fix

Clear clientInitId immediately after suppressing the first matching daemon response. Add a real daemon regression test that initializes with ID 1, reuses ID 1 for a subsequent ping request, and verifies that the later response is relayed to the client.

## Description

The local-handshake proxy immediately returns an initialize response while the shared daemon connects in the background. It forwards the initialize request to the daemon and suppresses the daemon's duplicate response. However, a later JSON-RPC request can reuse the initialize request ID after the handshake completes. In that case, the proxy incorrectly drops the later response.

## Root Cause

The proxy stores the initialize request ID in `clientInitId` to identify the daemon's duplicate initialize response. After filtering the matching response, it leaves `clientInitId` unchanged. The suppression logic therefore continues matching every later daemon response with the same request ID.

## Fix

Clear `clientInitId` immediately after suppressing the first matching daemon response. Add a real daemon regression test that initializes with ID 1, reuses ID 1 for a subsequent ping request, and verifies that the later response is relayed to the client.
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.

1 participant