Skip to content

Commit a41dd6a

Browse files
committed
Remove blocking behavior workaround in MCP ClientSession
This reverts commit d3c2c0f. This workaround is not necessary anymore and now harmful since the fix is applied in MCP 1.6.0. modelcontextprotocol/python-sdk#325
1 parent dd43d73 commit a41dd6a

File tree

3 files changed

+2
-27
lines changed

3 files changed

+2
-27
lines changed

mcp_bridge/mcp_clients/session.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,6 @@ def __init__(
4040
read_timeout_seconds=read_timeout_seconds,
4141
)
4242

43-
async def __aenter__(self):
44-
session = await super().__aenter__()
45-
self._task_group.start_soon(self._consume_messages)
46-
return session
47-
48-
async def _consume_messages(self):
49-
try:
50-
async for message in self.incoming_messages:
51-
try:
52-
if isinstance(message, Exception):
53-
logger.error(f"Received exception in message stream: {message}")
54-
elif isinstance(message, RequestResponder):
55-
logger.debug(f"Received request: {message.request}")
56-
elif isinstance(message, types.ServerNotification):
57-
if isinstance(message.root, types.LoggingMessageNotification):
58-
logger.debug(f"Received notification from server: {message.root.params}")
59-
else:
60-
logger.debug(f"Received notification from server: {message}")
61-
else:
62-
logger.debug(f"Received notification: {message}")
63-
except Exception as e:
64-
logger.exception(f"Error processing message: {e}")
65-
except Exception as e:
66-
logger.exception(f"Message consumer task failed: {e}")
67-
6843
async def initialize(self) -> types.InitializeResult:
6944
result = await self.send_request(
7045
types.ClientRequest(

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies = [
1111
"httpx-sse>=0.4.0",
1212
"lmos-openai-types",
1313
"loguru>=0.7.3",
14-
"mcp>=1.2.0,<=1.7.1",
14+
"mcp>=1.6.0,<=1.7.1",
1515
"mcpx[docker]>=0.1.1",
1616
"opentelemetry-api>=1.33.1",
1717
"opentelemetry-exporter-otlp>=1.33.1",

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)