Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/strands/tools/mcp/mcp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def start(self) -> "MCPClient":
logger.exception("client failed to initialize")
# Pass None for exc_type, exc_val, exc_tb since this isn't a context manager exit
self.stop(None, None, None)
raise MCPClientInitializationError("the client initialization failed") from e
raise MCPClientInitializationError(f"the client initialization failed: {e}") from e
return self

# ToolProvider interface methods
Expand Down
5 changes: 4 additions & 1 deletion tests/strands/tools/mcp/test_mcp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,10 @@ def test_enter_with_initialization_exception(mock_transport):
client = MCPClient(mock_transport["transport_callable"])

with patch.object(client, "stop") as mock_stop:
with pytest.raises(MCPClientInitializationError, match="the client initialization failed"):
with pytest.raises(
MCPClientInitializationError,
match="the client initialization failed: Transport initialization failed",
):
client.start()

# Verify stop() was called for cleanup
Expand Down