Skip to content

Commit 366d667

Browse files
committed
Fix regression in CallbackAdapter
1 parent 197e3ac commit 366d667

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

dash/mcp/primitives/tools/callback_adapter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def _expand_output_spec(
385385
output_id: str,
386386
cb_info: dict,
387387
resolved_inputs: list[CallbackInput],
388-
) -> list[CallbackOutputTarget]:
388+
) -> CallbackOutputTarget | list[CallbackOutputTarget]:
389389
"""Build the outputs spec, expanding wildcards to concrete IDs.
390390
391391
For wildcard outputs, derives concrete IDs from the resolved inputs.
@@ -417,6 +417,11 @@ def _expand_output_spec(
417417
else:
418418
results.append({"id": pid, "property": prop})
419419

420+
# Mirror the Dash renderer: single-output callbacks send a bare dict,
421+
# multi-output callbacks send a list. The framework's output value
422+
# matching depends on this shape.
423+
if len(results) == 1:
424+
return results[0]
420425
return results
421426

422427

dash/mcp/primitives/tools/output_schemas/schema_callback_response.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
"""Output schema derived from CallbackDispatchResponse."""
1+
"""Output schema derived from CallbackExecutionResponse."""
22

33
from __future__ import annotations
44

55
from typing import Any
66

77
from pydantic import TypeAdapter
88

9-
from dash.types import CallbackDispatchResponse
9+
from dash.types import CallbackExecutionResponse
1010

11-
_schema = TypeAdapter(CallbackDispatchResponse).json_schema()
11+
_schema = TypeAdapter(CallbackExecutionResponse).json_schema()
1212

1313

1414
def callback_response_schema() -> dict[str, Any]:

tests/unit/mcp/tools/test_tool_schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from pydantic import TypeAdapter
1717
from dash.development.base_component import Component
18-
from dash.types import CallbackDispatchResponse
18+
from dash.types import CallbackExecutionResponse
1919

2020
_DASH_COMPONENT_SCHEMA = TypeAdapter(Component).json_schema()
2121

@@ -51,7 +51,7 @@
5151
},
5252
},
5353
},
54-
"outputSchema": TypeAdapter(CallbackDispatchResponse).json_schema(),
54+
"outputSchema": TypeAdapter(CallbackExecutionResponse).json_schema(),
5555
}
5656

5757

0 commit comments

Comments
 (0)