Skip to content

Commit a500962

Browse files
fix: add missing MCP server events to beta Realtime client event union
The beta Realtime client (`client.beta.realtime.connect()`) uses `types/beta/realtime/realtime_server_event.py` as the discriminated union for parsing incoming WebSocket events. This union was missing all eight MCP lifecycle event types that the server emits when MCP tools are configured: mcp_list_tools.in_progress mcp_list_tools.completed mcp_list_tools.failed response.mcp_call.in_progress response.mcp_call.completed response.mcp_call.failed response.mcp_call_arguments.delta response.mcp_call_arguments.done Because the discriminated union had no entry for these event types, any MCP event sent by the server could not be matched during parse_event(), causing pydantic to fail silently or raise a validation error. The practical effect is that MCP tool calls appear to do nothing: the server executes the tool, emits the lifecycle events, and the client drops them without dispatch. The same types already exist in `types/realtime/` (the non-beta path) and are fully covered there. This commit re-exports them into `types/beta/realtime/realtime_server_event.py` by importing from the shared location and registering them in both `__all__` and the `RealtimeServerEvent` union. Fixes #3128
1 parent e507a4e commit a500962

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/openai/types/beta/realtime/realtime_server_event.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,29 @@
3838
from .conversation_item_input_audio_transcription_completed_event import (
3939
ConversationItemInputAudioTranscriptionCompletedEvent,
4040
)
41+
from ...realtime.mcp_list_tools_in_progress import McpListToolsInProgress
42+
from ...realtime.mcp_list_tools_completed import McpListToolsCompleted
43+
from ...realtime.mcp_list_tools_failed import McpListToolsFailed
44+
from ...realtime.response_mcp_call_arguments_delta import ResponseMcpCallArgumentsDelta
45+
from ...realtime.response_mcp_call_arguments_done import ResponseMcpCallArgumentsDone
46+
from ...realtime.response_mcp_call_in_progress import ResponseMcpCallInProgress
47+
from ...realtime.response_mcp_call_completed import ResponseMcpCallCompleted
48+
from ...realtime.response_mcp_call_failed import ResponseMcpCallFailed
4149

4250
__all__ = [
4351
"RealtimeServerEvent",
4452
"ConversationItemRetrieved",
4553
"OutputAudioBufferStarted",
4654
"OutputAudioBufferStopped",
4755
"OutputAudioBufferCleared",
56+
"McpListToolsInProgress",
57+
"McpListToolsCompleted",
58+
"McpListToolsFailed",
59+
"ResponseMcpCallArgumentsDelta",
60+
"ResponseMcpCallArgumentsDone",
61+
"ResponseMcpCallInProgress",
62+
"ResponseMcpCallCompleted",
63+
"ResponseMcpCallFailed",
4864
]
4965

5066

@@ -128,6 +144,14 @@ class OutputAudioBufferCleared(BaseModel):
128144
OutputAudioBufferStarted,
129145
OutputAudioBufferStopped,
130146
OutputAudioBufferCleared,
147+
McpListToolsInProgress,
148+
McpListToolsCompleted,
149+
McpListToolsFailed,
150+
ResponseMcpCallArgumentsDelta,
151+
ResponseMcpCallArgumentsDone,
152+
ResponseMcpCallInProgress,
153+
ResponseMcpCallCompleted,
154+
ResponseMcpCallFailed,
131155
],
132156
PropertyInfo(discriminator="type"),
133157
]

0 commit comments

Comments
 (0)