From 8e9548a1c5ba370114875903cb2bd925d2a9e4e0 Mon Sep 17 00:00:00 2001 From: Dickson Tsai Date: Fri, 29 Aug 2025 19:31:47 -0700 Subject: [PATCH] Bubble up initialization message --- src/claude_code_sdk/client.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/claude_code_sdk/client.py b/src/claude_code_sdk/client.py index 3cfeb42..330d947 100644 --- a/src/claude_code_sdk/client.py +++ b/src/claude_code_sdk/client.py @@ -185,6 +185,31 @@ class ClaudeSDKClient: if not self._query: raise CLIConnectionError("Not connected. Call connect() first.") await self._query.interrupt() + + async def get_server_info(self) -> dict[str, Any] | None: + """Get server initialization info including available commands and output styles. + + Returns initialization information from the Claude Code server including: + - Available commands (slash commands, system commands, etc.) + - Current and available output styles + - Server capabilities + + Returns: + Dictionary with server info, or None if not in streaming mode + + Example: + ```python + async with ClaudeSDKClient() as client: + info = await client.get_server_info() + if info: + print(f"Commands available: {len(info.get('commands', []))}") + print(f"Output style: {info.get('output_style', 'default')}") + ``` + """ + if not self._query: + raise CLIConnectionError("Not connected. Call connect() first.") + # Return the initialization result that was already obtained during connect + return getattr(self._query, '_initialization_result', None) async def get_server_info(self) -> dict[str, Any] | None: """Get server initialization info including available commands and output styles.