Skip to content

MCP Server Part 3: Dash App Resources#3712

Open
KoolADE85 wants to merge 1 commit intofeature/mcp-callback-adaptersfrom
feature/mcp-resources
Open

MCP Server Part 3: Dash App Resources#3712
KoolADE85 wants to merge 1 commit intofeature/mcp-callback-adaptersfrom
feature/mcp-resources

Conversation

@KoolADE85
Copy link
Copy Markdown
Contributor

Summary

  • Add read-only MCP resources:

    • dash://layout: retrieves the layout in the same json format as the _dash-layout endpoint
    • dash://components: retrieves a flat list of components which have IDs, along with their types
    • dash://pages: retrieves all pages from the page registry
    • dash://page-layout/{path}: a template for retrieving the layout of a specific page
    • dash://clientside-callbacks: describes all clientside callbacks for LLM discovery
  • Resources may be conditionally listed (e.g. dash://pages only appears for multi-page apps)

Manual testing

from dash import Dash, html, dcc, Input, Output
from dash._get_app import app_context
import json

app = Dash(__name__)
app.layout = html.Div([
    dcc.Dropdown(id="city", options=["NYC", "LA", "Chicago"], value="NYC"),
    dcc.Graph(id="chart"),
])
@app.callback(Output("chart", "figure"), Input("city", "value"))
def update_chart(city):
    return {"data": [{"x": [1, 2], "y": [3, 4]}], "layout": {"title": city}}

with app.server.app_context():
    app_context.set(app)
    from dash.mcp.primitives.resources import list_resources, read_resource
    result = list_resources()
    for r in result.resources:
        print(f"Resource: {r.uri}{r.name}")
    result = read_resource("dash://components")
    print(json.loads(result.contents[0].text))

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

Thank you for your contribution to Dash! 🎉

This PR is exempt from requiring a linked issue due to its labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant