Skip to content

Commit 198df55

Browse files
committed
fix: correct MCPClient.__exit__ and stop() type annotations
Fixes #2247
1 parent 8638fc2 commit 198df55

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/strands/tools/mcp/mcp_client.py

Lines changed: 7 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,7 @@ 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(self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None) -> None:
322327
"""Signals the background thread to stop and waits for it to complete, ensuring proper cleanup of all resources.
323328
324329
This method is defensive and can handle partial initialization states that may occur

0 commit comments

Comments
 (0)