Repository navigation
feat(catalog-mcp): add updateDataModel - #3573
josemontespg wants to merge 1 commit into
Conversation
bed3164 to
2526a71
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces three new data functions (parseJson, jmespath, and updateDataModel) to the A2UI MCP catalog, enabling surfaces to process headless tool outputs and write them to the data model. It also adds a helper to settle pending asynchronous arguments, comprehensive tests, schema updates, and documentation. Feedback suggests implementing a two-pass validation approach in updateDataModel to prevent prototype pollution and ensure atomic updates.
2526a71 to
7569b69
Compare
7569b69 to
105c151
Compare
105c151 to
bf2af14
Compare
bf2af14 to
1efcbc5
Compare
1efcbc5 to
2d8be18
Compare
2d8be18 to
6bf1f1d
Compare
6bf1f1d to
9c4b077
Compare
9c4b077 to
9fef81f
Compare
9fef81f to
402e22d
Compare
cd56db0 to
0a4e4ef
Compare
39fc1e0 to
82af3eb
Compare
7cd9e90 to
a3b763c
Compare
a3b763c to
bd66c46
Compare
bd66c46 to
fc248bd
Compare
fc248bd to
11ea93e
Compare
ditman
left a comment
There was a problem hiding this comment.
As we decided in #3153 and implemented in #3171, general-purpose data transformation functions (parseJson, jmespath, updateDataModel) and the jmespath dependency should not live in catalogs/mcp/v1/catalog.json, conformance/core/catalog.yaml, or @a2ui/catalog-mcp.
Putting these into the v1 MCP catalog specification and conformance suite would require every client SDK implementing the MCP catalog (TypeScript, Flutter/Dart, Swift, etc.) to pull in a third-party JMESPath dependency and implement general ETL functions that are not specific to the MCP protocol. Instead, these functions should remain in the sample application that needs them (samples/community/mcp/a2ui-over-mcp-filesystem).
Note: The fix in typescript/catalogs/mcp/src/functions/callMcpTool.ts (importing DynamicStringSchema and DynamicValueSchema from @a2ui/web_core/v1_0 so @path/@call tool arguments validate in v1.0) is great — please extract that into its own small PR (or fold it into #3577 / #3578) and close this PR.
11ea93e to
6726107
Compare
ditman
left a comment
There was a problem hiding this comment.
We discussed this offline and I was persuaded of letting some of these functions back in the catalog, even if they aren't directly required for the component to work, they may be generally helpful.
Please, update the documentation to ensure users know how to add their custom functions, we don't want a explosion of random functions becoming part of the catalog.
Summary
Adds the
updateDataModeldata function to the v1 MCP catalog and@a2ui/catalog-mcp, writing each key-value pair of itsupdatesobject to the surface data model. Keys starting with/write to absolute paths, while relative keys resolve against the calling data context, such as the current row of a template list.updateDataModelis declared incatalogs/mcp/v1/catalog.json, registered onmcpCatalog, and exported asUpdateDataModelApiandUpdateDataModelImplementationfor hosts that compose their own catalogs. Every key is validated before anything is written (rejecting empty keys and__proto__,constructor, orprototypesegments), objects and arrays are cloned before storage, and@pathor@callobjects inside values are stored as plain data rather than evaluated as expressions.Changes
typescript/catalogs/mcp/src/functions/update_data_model.tsandupdate_data_model.test.ts: implementUpdateDataModelApiandUpdateDataModelImplementationwith path validation and unit tests.typescript/catalogs/mcp/src/catalog.tsandsrc/index.ts: registerUpdateDataModelImplementationonmcpCatalogand exportUpdateDataModelApiandUpdateDataModelImplementation.catalogs/mcp/v1/catalog.jsonandtypescript/catalogs/mcp/src/catalog.test.ts: declareupdateDataModelin the v1 catalog schema and check parity withmcpCatalog.catalogs/mcp/README.md,typescript/catalogs/mcp/README.md,CHANGELOG.md: documentupdateDataModeland its path validation rules.Verification
yarn workspace @a2ui/catalog-mcp run testandyarn workspace @a2ui/catalog-mcp run lint: node and karma test suites pass, includingupdate_data_model.test.tsand catalog parity checks.specification/v1_0/test/run_tests.pyand./scripts/fix_format.sh --checkpass.