MCPcopy Index your code
hub / github.com/plotly/dash / configure_mcp_server

Function configure_mcp_server

dash/mcp/_configure.py:45–133  ·  view source on GitHub ↗

Configure which content the Dash MCP server exposes. Only the parameters that are explicitly passed are updated; any parameter that is omitted keeps its current value. On the first call, unset values take their defaults (all content included except callback docstrings). :param

(
    *,
    include_layout: Optional[bool] = None,
    include_callbacks: Optional[bool] = None,
    include_clientside_callbacks: Optional[bool] = None,
    include_pages: Optional[bool] = None,
    expose_callback_docstrings: Optional[bool] = None,
)

Source from the content-addressed store, hash-verified

43
44
45def configure_mcp_server(
46 *,
47 include_layout: Optional[bool] = None,
48 include_callbacks: Optional[bool] = None,
49 include_clientside_callbacks: Optional[bool] = None,
50 include_pages: Optional[bool] = None,
51 expose_callback_docstrings: Optional[bool] = None,
52) -> None:
53 """
54 Configure which content the Dash MCP server exposes.
55
56 Only the parameters that are explicitly passed are updated; any parameter
57 that is omitted keeps its current value. On the first call, unset values
58 take their defaults (all content included except callback docstrings).
59
60 :param include_layout: Expose ``dash://layout``, ``dash://components``,
61 and the ``get_dash_component`` tool. Defaults to ``True``.
62 :param include_callbacks: When ``True`` (default), all callbacks are
63 included; ``mcp_enabled=False`` on a ``@callback`` opts it out.
64 When ``False``, no callbacks are included by default;
65 ``mcp_enabled=True`` opts a specific callback in.
66 :param include_clientside_callbacks: Expose the
67 ``dash://clientside-callbacks`` resource. Defaults to ``True``.
68 :param include_pages: Expose ``dash://pages`` and
69 ``dash://page-layout/{path}``. Defaults to ``True``.
70 :param expose_callback_docstrings: Include callback docstrings in
71 tool descriptions. Defaults to ``False``.
72
73 Example — expose only ``@mcp_enabled``-decorated functions::
74
75 from dash.mcp import configure_mcp_server
76
77 configure_mcp_server(
78 include_layout=False,
79 include_callbacks=False,
80 include_clientside_callbacks=False,
81 include_pages=False,
82 )
83 """
84 try:
85 if get_app().backend.has_request_context():
86 raise RuntimeError("MCP server can't be configured within a callback")
87 except AppNotFoundError:
88 pass
89
90 passed = {
91 "include_layout": include_layout,
92 "include_callbacks": include_callbacks,
93 "include_clientside_callbacks": include_clientside_callbacks,
94 "include_pages": include_pages,
95 "expose_callback_docstrings": expose_callback_docstrings,
96 }
97 _current_config.update(
98 {key: value for key, value in passed.items() if value is not None}
99 )
100
101 CallbackTools.callbacks_mcp_enabled_by_default = _current_config[
102 "include_callbacks"

Calls 4

get_appFunction · 0.90
setFunction · 0.50
has_request_contextMethod · 0.45
updateMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…