Skip to content

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

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

MCP Server Part 5: Pattern-matching callback schemas#3747
KoolADE85 wants to merge 3 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.

@KoolADE85 KoolADE85 force-pushed the feature/mcp-pattern-matching-schemas branch from 9b3063f to 7451883 Compare April 21, 2026 17:27
@KoolADE85 KoolADE85 force-pushed the feature/mcp-tools branch 6 times, most recently from 7cdc31e to f6cd30c Compare April 22, 2026 18:29
@KoolADE85 KoolADE85 force-pushed the feature/mcp-pattern-matching-schemas branch from 7451883 to 5fbf497 Compare April 22, 2026 21:13
@KoolADE85 KoolADE85 force-pushed the feature/mcp-pattern-matching-schemas branch from 5fbf497 to b564279 Compare April 23, 2026 20:04
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