@@ -50,8 +50,17 @@ def __init__(self, callback_output_id: str):
5050
5151 @cached_property
5252 def as_mcp_tool (self ) -> Tool :
53- """Stub — will be implemented in a future PR."""
54- raise NotImplementedError ("as_mcp_tool will be implemented in a future PR." )
53+ """Transforms the internal Dash callback to a structured MCP tool.
54+
55+ This tool can be serialized for LLM consumption or used internally for
56+ its computed data.
57+ """
58+ return Tool (
59+ name = self .tool_name ,
60+ description = self ._description ,
61+ inputSchema = self ._input_schema ,
62+ outputSchema = self ._output_schema ,
63+ )
5564
5665 def as_callback_body (self , kwargs : dict [str , Any ]) -> CallbackExecutionBody :
5766 """Transforms the given kwargs to a dict suitable for calling this callback.
@@ -126,7 +135,8 @@ def output_id(self) -> str:
126135
127136 @property
128137 def tool_name (self ) -> str :
129- return get_app ().mcp_callback_map ._tool_names_map [self ._output_id ] # pylint: disable=protected-access
138+ # pylint: disable-next=protected-access
139+ return get_app ().mcp_callback_map ._tool_names_map [self ._output_id ]
130140
131141 @cached_property
132142 def prevents_initial_call (self ) -> bool :
@@ -141,7 +151,7 @@ def prevents_initial_call(self) -> bool:
141151
142152 @cached_property
143153 def _description (self ) -> str :
144- return build_tool_description (self . outputs , self . _docstring )
154+ return build_tool_description (self )
145155
146156 @cached_property
147157 def _input_schema (self ) -> dict [str , Any ]:
@@ -376,7 +386,7 @@ def _expand_output_spec(
376386 output_id : str ,
377387 cb_info : dict ,
378388 resolved_inputs : list [CallbackInput ],
379- ) -> list [CallbackOutputTarget ]:
389+ ) -> CallbackOutputTarget | list [CallbackOutputTarget ]:
380390 """Build the outputs spec, expanding wildcards to concrete IDs.
381391
382392 For wildcard outputs, derives concrete IDs from the resolved inputs.
@@ -408,6 +418,11 @@ def _expand_output_spec(
408418 else :
409419 results .append ({"id" : pid , "property" : prop })
410420
421+ # Mirror the Dash renderer: single-output callbacks send a bare dict,
422+ # multi-output callbacks send a list. The framework's output value
423+ # matching depends on this shape.
424+ if len (results ) == 1 :
425+ return results [0 ]
411426 return results
412427
413428
0 commit comments