MCP Server Part 6: Format callback results for LLM consumption#3748
MCP Server Part 6: Format callback results for LLM consumption#3748
Conversation
|
Thank you for your contribution to Dash! 🎉 This PR is exempt from requiring a linked issue due to its labels. |
9b3063f to
7451883
Compare
0e54d74 to
8a41b76
Compare
7451883 to
5fbf497
Compare
8a41b76 to
4fb9d4a
Compare
5fbf497 to
b564279
Compare
4fb9d4a to
10a544b
Compare
b564279 to
e2aec3d
Compare
2acb39d to
04ca2fe
Compare
04ca2fe to
8f9d5a0
Compare
camdecoster
left a comment
There was a problem hiding this comment.
Looks good. I add a few minor suggestions.
| formatters are called per output property and may add additional | ||
| content items (images, markdown, etc.). | ||
| """ | ||
| content: list[Any] = [ |
There was a problem hiding this comment.
Would using a dict instead of a list make more sense here? Then you wouldn't have to iterate through the list down below (assuming you could figure out which formatter to use before calling it).
There was a problem hiding this comment.
Thinking about this further, I'd like to keep the current structure for two reasons:
- consistency: the pattern of "iterate providers, each decides if it applies" is already used for input schemas, tool descriptions, and resource providers; I think it's valuable to keep a consistent pattern here too.
- flexibility: iterating lets each formatter decide dynamically whether it applies. While it's fairly static today, we are leaving room for multiple formatters to enrich the same output without restructuring later.
| ) | ||
|
|
||
| GENERIC_FIGURE = PropRole( | ||
| PLOTLY_FIGURE = PropRole( |
There was a problem hiding this comment.
Why is this change necessary?
There was a problem hiding this comment.
just a style choice: I wanted it to read more clearly when it's subsequently used in the result formatter, that we are actually concerned with formatting Plotly figures, not more "generic" figures.
Summary
PlotlyFigureResult— rendersGraph.figureoutputs as PNG images via kaleido, returned asImageContentDataFrameResult— rendersDataTable.dataandAgGrid.rowDataoutputs as markdown tables, returned asTextContentManual verification: