Skip to content

Commit 52b2858

Browse files
committed
Fix @mcp_enabled decorator not working if defined after the app constructor
1 parent 17f67ec commit 52b2858

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

‎dash/mcp/_server.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@
5050
def enable_mcp_server(app: Dash, mcp_path: str) -> None:
5151
"""Add MCP routes to a Dash app."""
5252

53-
app.mcp_decorated_functions = dict(MCP_DECORATED_FUNCTIONS)
54-
MCP_DECORATED_FUNCTIONS.clear()
55-
5653
def _get_or_create_session_id() -> str:
5754
"""
5855
Creates a shared session ID shared across all clients. The session is
@@ -247,6 +244,7 @@ def _process_mcp_message(data: dict[str, Any]) -> dict[str, Any] | None:
247244
app = get_app()
248245
if app.mcp_callback_map is None:
249246
app.mcp_callback_map = CallbackAdapterCollection(app)
247+
app.mcp_decorated_functions = dict(MCP_DECORATED_FUNCTIONS)
250248

251249
mcp_methods = {
252250
"initialize": _handle_initialize,

0 commit comments

Comments
 (0)