diff --git a/examples/clients/simple-chatbot/mcp_simple_chatbot/main.py b/examples/clients/simple-chatbot/mcp_simple_chatbot/main.py index 7cb81edf..3892e498 100644 --- a/examples/clients/simple-chatbot/mcp_simple_chatbot/main.py +++ b/examples/clients/simple-chatbot/mcp_simple_chatbot/main.py @@ -91,10 +91,15 @@ class Server: else None, ) try: - stdio_transport = await self.exit_stack.enter_async_context(stdio_client(server_params)) + stdio_transport = await self.exit_stack.enter_async_context( + stdio_client(server_params) + ) read, write = stdio_transport - self.session = await self.exit_stack.enter_async_context(ClientSession(read, write)) - await self.session.initialize() + session = await self.exit_stack.enter_async_context( + ClientSession(read, write) + ) + await session.initialize() + self.session = session except Exception as e: logging.error(f"Error initializing server {self.name}: {e}") await self.cleanup() @@ -257,7 +262,7 @@ class LLMClient: error_message = f"Error getting LLM response: {str(e)}" logging.error(error_message) - if hasattr(e, 'response'): + if isinstance(e, httpx.HTTPStatusError): status_code = e.response.status_code logging.error(f"Status code: {status_code}") logging.error(f"Response details: {e.response.text}") diff --git a/examples/clients/simple-chatbot/pyproject.toml b/examples/clients/simple-chatbot/pyproject.toml index af9d9893..d88b8f6d 100644 --- a/examples/clients/simple-chatbot/pyproject.toml +++ b/examples/clients/simple-chatbot/pyproject.toml @@ -45,4 +45,4 @@ line-length = 88 target-version = "py310" [tool.uv] -dev-dependencies = ["pyright>=1.1.378", "pytest>=8.3.3", "ruff>=0.6.9"] \ No newline at end of file +dev-dependencies = ["pyright>=1.1.379", "pytest>=8.3.3", "ruff>=0.6.9"]