MCP Server Part 3: Dash App Resources#3712
MCP Server Part 3: Dash App Resources#3712KoolADE85 wants to merge 3 commits intofeature/mcp-callback-adaptersfrom
Resources#3712Conversation
|
Thank you for your contribution to Dash! 🎉 This PR is exempt from requiring a linked issue due to its labels. |
c6cbe97 to
cd073cf
Compare
93ea7ec to
0eecb3e
Compare
cd073cf to
74cd477
Compare
0eecb3e to
c397a38
Compare
T4rk1n
left a comment
There was a problem hiding this comment.
Looks good overall, just wondering why the pages import wouldn't work since that is a pretty standard module.
| def get_template() -> ResourceTemplate | None: | ||
| return None |
There was a problem hiding this comment.
Why is this necessary if it only returns None? Seems like the modules are being used as a class, maybe refactor to a base class instead.
There was a problem hiding this comment.
That is a great idea! I added a base class and removed the no-op methods from each type of resource.
| try: | ||
| from dash._pages import PAGE_REGISTRY | ||
| except ImportError: | ||
| raise ValueError("Dash Pages is not available.") |
There was a problem hiding this comment.
Why would this import be not available?
There was a problem hiding this comment.
Good point - I guess it would always be there. I removed the defensive import and put it at the top.
c397a38 to
4532955
Compare
Summary
Add read-only MCP resources:
dash://layout: retrieves the layout in the same json format as the_dash-layoutendpointdash://components: retrieves a flat list of components which have IDs, along with their typesdash://pages: retrieves all pages from the page registrydash://page-layout/{path}: a template for retrieving the layout of a specific pagedash://clientside-callbacks: describes all clientside callbacks for LLM discoveryResources may be conditionally listed (e.g.
dash://pagesonly appears for multi-page apps)Manual testing