Skip to content

MCP Server Part 5: Pattern-matching callback schemas#3747

Open
KoolADE85 wants to merge 2 commits intofeature/mcp-toolsfrom
feature/mcp-pattern-matching-schemas
Open

MCP Server Part 5: Pattern-matching callback schemas#3747
KoolADE85 wants to merge 2 commits intofeature/mcp-toolsfrom
feature/mcp-pattern-matching-schemas

Conversation

@KoolADE85
Copy link
Copy Markdown
Contributor

Summary

  • Add pattern-matching callback support (ALL, MATCH, ALLSMALLER) to input schemas and descriptions
  • PatternMatchingSchema generates array schemas for ALL/ALLSMALLER and object schemas for MATCH, with value types inferred from matching layout components
  • PatternMatchingDescription explains the wildcard pattern and expected input format to the LLM

Manual verification:

from dash import Dash, html, Input, Output, ALL
import json

app = Dash(__name__)
app.layout = html.Div([
    html.Div(id={"type": "item", "index": 0}, children="A"),
    html.Div(id={"type": "item", "index": 1}, children="B"),
    html.Div(id="result"),
])

@app.callback(
    Output("result", "children"),
    Input({"type": "item", "index": ALL}, "children"),
)
def combine(values):
    """Combine all item values."""
    return ", ".join(values)

with app.server.app_context():
    from dash.mcp.primitives.tools.callback_adapter_collection import CallbackAdapterCollection
    collection = CallbackAdapterCollection(app)
    for adapter in collection:
        tool = adapter.as_mcp_tool
        print(f"Tool: {tool.name}")
        print(f"Description:\n{tool.description}\n")
        print(f"Input schema:\n{json.dumps(tool.inputSchema, indent=2)}\n")
        # Schema should show type: "array" with items containing {id, property, value}
        # Description should mention "Pattern-matching input (ALL)" and type="item"

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 16, 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.

2 participants