Skip to content

Commit 980bc91

Browse files
authored
fix: correct MCPClient.__exit__ and stop() type annotations (#2248)
1 parent 800e7c4 commit 980bc91

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/strands/tools/mcp/mcp_client.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,12 @@ def __enter__(self) -> "MCPClient":
178178
"""
179179
return self.start()
180180

181-
def __exit__(self, exc_type: BaseException, exc_val: BaseException, exc_tb: TracebackType) -> None:
181+
def __exit__(
182+
self,
183+
exc_type: type[BaseException] | None,
184+
exc_val: BaseException | None,
185+
exc_tb: TracebackType | None,
186+
) -> None:
182187
"""Context manager exit point that cleans up resources."""
183188
self.stop(exc_type, exc_val, exc_tb)
184189

@@ -318,7 +323,12 @@ def remove_consumer(self, consumer_id: Any, **kwargs: Any) -> None:
318323

319324
# MCP-specific methods
320325

321-
def stop(self, exc_type: BaseException | None, exc_val: BaseException | None, exc_tb: TracebackType | None) -> None:
326+
def stop(
327+
self,
328+
exc_type: type[BaseException] | None,
329+
exc_val: BaseException | None,
330+
exc_tb: TracebackType | None,
331+
) -> None:
322332
"""Signals the background thread to stop and waits for it to complete, ensuring proper cleanup of all resources.
323333
324334
This method is defensive and can handle partial initialization states that may occur

0 commit comments

Comments
 (0)