From 0599d72625b57445197cbdc110a1037d9f4dd27a Mon Sep 17 00:00:00 2001 From: Patrick Buckley Date: Tue, 11 Aug 2026 21:42:04 -0700 Subject: [PATCH] Apply MCP formatting --- tests/test_mcp_transport_owner.py | 8 ++------ turnstone/core/mcp_client.py | 20 ++++---------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/tests/test_mcp_transport_owner.py b/tests/test_mcp_transport_owner.py index 1eb6ba2a..5a092049 100644 --- a/tests/test_mcp_transport_owner.py +++ b/tests/test_mcp_transport_owner.py @@ -157,9 +157,7 @@ class TestTransportOwnerLifecycle: assert state.owner_task is None assert state.close_requested is None - def test_tools_only_connect_skips_unchanged_catalog_listeners( - self, running_loop_mgr - ) -> None: + def test_tools_only_connect_skips_unchanged_catalog_listeners(self, running_loop_mgr) -> None: """A tools-only registration must not rebuild every live chat twice.""" mgr, loop, _ = running_loop_mgr patches: dict[str, Any] = {} @@ -465,9 +463,7 @@ class TestTransportOwnerLifecycle: assert len(state.tools) == 1 assert mgr.is_mcp_tool("mcp__new__late") is True - def test_blocked_loop_cannot_return_failure_before_add_outcome( - self, running_loop_mgr - ) -> None: + def test_blocked_loop_cannot_return_failure_before_add_outcome(self, running_loop_mgr) -> None: """A synchronous listener stall may delay success, never expose a ghost.""" mgr, _loop, _ = running_loop_mgr diff --git a/turnstone/core/mcp_client.py b/turnstone/core/mcp_client.py index 23cb8743..4c026b32 100644 --- a/turnstone/core/mcp_client.py +++ b/turnstone/core/mcp_client.py @@ -2468,14 +2468,8 @@ class MCPClientManager: # exact wiring immediately before commit; there are no awaits from # this check through publication, so a callable catalog can never # be installed behind a dead/replaced transport. - if ( - owner.done() - or state.owner_task is not owner - or state.session is not session - ): - raise ConnectionError( - f"MCP server '{name}' transport died before catalog commit" - ) + if owner.done() or state.owner_task is not owner or state.session is not session: + raise ConnectionError(f"MCP server '{name}' transport died before catalog commit") except BaseException: await self._teardown_static_session(name) raise @@ -3154,11 +3148,7 @@ class MCPClientManager: # Mirror the static commit guard. A transport owner can finish in the # same scheduling turn as the final discovery response; never publish # that response into the per-user maps after its session was evicted. - if ( - owner.done() - or entry.owner_task is not owner - or entry.session is not session - ): + if owner.done() or entry.owner_task is not owner or entry.session is not session: await self._teardown_pool_entry(key) raise ConnectionError( f"MCP pool server '{server_name}' transport died before catalog commit" @@ -5835,9 +5825,7 @@ class MCPClientManager: # run after this cleanup releases the lock. _clear_failed_add_state() if isinstance(exc, TimeoutError): - raise TimeoutError( - f"MCP server '{name}' registration timed out" - ) from None + raise TimeoutError(f"MCP server '{name}' registration timed out") from None raise future = asyncio.run_coroutine_threadsafe(_add(), self._loop)