File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
src/mcp/server/message_queue Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -82,17 +82,22 @@ async def _listen_for_messages(self) -> None:
8282 if message is None :
8383 continue
8484
85- # Extract session ID from channel name
8685 channel : str = cast (str , message ["channel" ])
87- if not channel .startswith (self ._prefix ):
86+ expected_prefix = f"{ self ._prefix } session:"
87+
88+ if not channel .startswith (expected_prefix ):
8889 logger .debug (f"Ignoring message from non-MCP channel: { channel } " )
8990 continue
90-
91- session_hex = channel . split ( ":" )[ - 1 ]
91+
92+ session_hex = channel [ len ( expected_prefix ): ]
9293 try :
9394 session_id = UUID (hex = session_hex )
95+ expected_channel = self ._session_channel (session_id )
96+ if channel != expected_channel :
97+ logger .error (f"Channel format mismatch: { channel } " )
98+ continue
9499 except ValueError :
95- logger .error (f"Received message for invalid session channel: { channel } " )
100+ logger .error (f"Received message with invalid UUID in channel: { channel } " )
96101 continue
97102
98103 data : str = cast (str , message ["data" ])
You can’t perform that action at this time.
0 commit comments