MCP Reference

Dash() Constructor Parameters

Parameter Type Default Description
enable_mcp bool False Turns on/off the entire MCP system
mcp_path str /_mcp The route within your Dash app that will be used by AI agents to access the MCP server. See also, requests_pathname_prefix.

Alternatively, you can set these same parameters with environment variables:

If both the environment variable and the constructor parameter are passed, the constructor parameter is used.

configure_mcp_server()

configure_mcp_server() controls what the MCP server exposes. Import it from dash.mcp and call it at the module level (before or after creating your Dash app, but not from within a callback).

from dash.mcp import configure_mcp_server

configure_mcp_server(expose_callback_docstrings=True)

Only the parameters you pass are changed; any you omit keep their current value. By default, all content is exposed except callback docstrings.

Parameter Type Default Description
include_layout bool True Expose the dash://layout and dash://components resources and the get_dash_component tool.
include_callbacks bool True When True, all callbacks are exposed and mcp_enabled=False opts an individual callback out. When False, no callbacks are exposed by default and mcp_enabled=True opts an individual callback in.
include_clientside_callbacks bool True Expose the dash://clientside-callbacks resource.
include_pages bool True Expose the dash://pages and dash://page-layout/{path} resources.
expose_callback_docstrings bool False Include every callback’s docstring in its tool description. Override per-callback with mcp_expose_docstring on @callback.

To expose only your @mcp_enabled-decorated functions, turn everything else off:

from dash.mcp import configure_mcp_server

configure_mcp_server(
    include_layout=False,
    include_callbacks=False,
    include_clientside_callbacks=False,
    include_pages=False,
)

@callback Parameters

Parameter Type Default Description
mcp_enabled bool None Enables/disables an individual callback for AI agent visibility and access, overriding the include_callbacks default set by configure_mcp_server. It cannot be used to enable a callback when enable_mcp=False at the constructor level.
mcp_expose_docstring bool None Includes/excludes an individual callback’s docstring from AI visibility. When left unset (None), it inherits the app-wide expose_callback_docstrings setting.

@mcp_enabled Decorator Parameters

Turns any function into an MCP tool that AI agents can discover and call. This adds to the existing tools made available by your app and has no effect on the page when visited in the browser.

Supports both bare and parameterized usage:

from dash.mcp import mcp_enabled

@mcp_enabled
def my_tool(x: int) -> str: ...

@mcp_enabled(name="custom_name", expose_docstring=True)
def my_tool(x: int) -> str: ...
Argument Type Default Description
name str None The name to present to AI agents. Used to request execution permission from the user. Defaults to the name of the function itself.
expose_docstring bool None Includes/excludes the function’s docstring from AI visibility. When left unset (None), it inherits the app-wide expose_callback_docstrings setting.

A Note on the Docstring Parameter Names

The same docstring setting appears under three slightly different names depending on where it is set. The differences are intentional:

Where Parameter Why
configure_mcp_server() expose_callback_docstrings Plural — it controls every callback in the app.
@callback mcp_expose_docstring Singular — it controls just that one callback, and overrides the app-wide default.
@mcp_enabled expose_docstring No mcp_ prefix — the decorator already lives in the dash.mcp namespace, so the prefix would be redundant. When unset, it falls back to the app-wide expose_callback_docstrings setting.