Skip to content

Commit 0420073

Browse files
committed
fix: do not call initialize for q dev cli / kiro cli
1 parent 3bbe8ec commit 0420073

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

mcp_proxy_for_aws/middleware/initialize_middleware.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,17 @@ async def on_initialize(
2828
client = await self._client_factory.get_client()
2929
# connect the http client, fail and don't succeed the stdio connect
3030
# if remote client cannot be connected
31-
await client._connect()
31+
client_name = context.message.params.clientInfo.name.lower()
32+
if 'kiro cli' not in client_name and 'q dev cli' not in client_name:
33+
# q cli / kiro cli uses the rust SDK which does not handle json rpc error
34+
# properly during initialization.
35+
# https://github.com/modelcontextprotocol/rust-sdk/pull/569
36+
# if calling _connect below raise mcp error, the q cli will skip the message
37+
# and containue wait for the json rpc response message, which will not come.
38+
# luckily, q cli calls list tool immediately after being connected to a mcp server
39+
# the list_tool call will require the client to be connected again, so the mcp error
40+
# will be displayed in the q cli logs.
41+
await client._connect()
3242
return await call_next(context)
3343
except Exception:
3444
logger.exception('Initialize failed in middleware.')

0 commit comments

Comments
 (0)