Skip to content

feat(catalog-mcp): write tool results to targetDataPath and return them - #3728

Open
josemontespg wants to merge 1 commit into
mainfrom
catalogs-mcp-tool-payload
Open

josemontespg wants to merge 1 commit into
mainfrom
catalogs-mcp-tool-payload

Conversation

@josemontespg

@josemontespg josemontespg commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Most MCP tools return plain text or JSON content rather than A2UI resources, and until now callMcpTool handed back the raw CallToolResult, which a payload could not use without client code. callMcpTool now returns one payload for every call: toolName, toolInput, toolResult, structuredContent when the server sends one, the text blocks joined with newlines, and their json parse, or an array of the per-block parses when a server sends one JSON block per row. When the result carries an MCP App resource, the payload also carries its resourceUri, html, csp and permissions.

With targetDataPath set, each successful call replaces the object at that path with its payload. A response that arrives after a newer call to the same path has started is not written, so the latest call wins, which keeps out-of-order responses such as autocomplete suggestions from overwriting newer ones. A result flagged isError fails the call and writes nothing.

callMcpTool now validates its arguments with the v1.0 schemas, so a tool argument bound with @path validates when the surface is processed, and the published v1 MCP catalog gets from_json and round_trip conformance cases.

Changes

  • typescript/catalogs/mcp/src/functions/callMcpTool.ts: add McpToolDataPayload and extractToolResultContent, build the payload on every call, write it to targetDataPath unless a newer call to that path has started, return it, and validate arguments with the v1.0 DynamicString and DynamicValue schemas.
  • typescript/catalogs/mcp/src/components/mcp_app.ts: read the raw result from payload.toolResult when forwarding a tool call to an app.
  • typescript/catalogs/mcp/src/index.ts: export the McpToolDataPayload type.
  • catalogs/mcp/v1/catalog.json: describe the payload on callMcpTool and the replace and latest-call-wins rules on targetDataPath.
  • conformance/core/catalog.yaml: add from_json (self-contained) and round_trip cases for the published v1 MCP catalog.
  • catalogs/mcp/README.md, typescript/catalogs/mcp/README.md, CHANGELOG.md: document the payload fields, targetDataPath, and the v1.0 call shape with catalogId on the call.

Verification

  • yarn workspace @a2ui/catalog-mcp run test: node and karma suites pass, including the new tool data payload tests in callMcpTool.test.ts (payload fields, JSON per-block parsing, targetDataPath replace and latest-call-wins, no write on isError).
  • specification/v1_0/test/run_tests.py and ./scripts/fix_format.sh --check pass.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the callMcpTool function in the MCP catalog to return a structured McpToolDataPayload containing the tool name, resolved input, raw result, structured content, joined text blocks, and parsed JSON. It also updates targetDataPath handling to write this payload to the specified path, ensuring that only the latest call writes to prevent out-of-order response overwrites. The changes include updated documentation, schema descriptions, conformance tests, and comprehensive unit tests. One piece of feedback suggests using Object.hasOwn instead of the in operator in the tests to avoid prototype lookup issues.

@josemontespg
josemontespg force-pushed the catalogs-mcp-tool-payload branch from 53c6f2a to 3248ba6 Compare October 28, 2026 22:45
@josemontespg
josemontespg added this pull request to stack #3730 October 28, 2026 22:46
@josemontespg
josemontespg force-pushed the catalogs-mcp-tool-payload branch from 3248ba6 to e6f60a9 Compare October 28, 2026 22:49
@josemontespg
josemontespg force-pushed the catalogs-mcp-tool-payload branch from e6f60a9 to f331744 Compare October 28, 2026 23:21
Comment thread typescript/catalogs/mcp/README.md Resolved
@josemontespg
josemontespg removed this pull request from stack #3730 October 28, 2026 23:42
@josemontespg
josemontespg changed the base branch from web-core-export-safe-regex to main October 28, 2026 23:42
@josemontespg
josemontespg force-pushed the catalogs-mcp-tool-payload branch from f331744 to 439e554 Compare October 28, 2026 23:42
@josemontespg
josemontespg added this pull request to stack #3733 October 28, 2026 23:44
@josemontespg
josemontespg removed this pull request from stack #3733 October 29, 2026 00:22
@josemontespg
josemontespg force-pushed the catalogs-mcp-tool-payload branch from 439e554 to c7abb66 Compare October 29, 2026 00:22
@josemontespg
josemontespg added this pull request to stack #3737 October 29, 2026 00:28
@josemontespg
josemontespg force-pushed the catalogs-mcp-tool-payload branch from c7abb66 to 436a91b Compare October 29, 2026 00:59
@josemontespg
josemontespg marked this pull request as ready for review October 29, 2026 17:05
@josemontespg
josemontespg requested a review from ditman October 29, 2026 17:06
Comment thread catalogs/mcp/README.md Resolved
@josemontespg
josemontespg force-pushed the catalogs-mcp-tool-payload branch from 436a91b to 2d5acbc Compare October 29, 2026 18:28
@josemontespg
josemontespg requested a review from ditman October 30, 2026 18:19
@josemontespg
josemontespg removed this pull request from stack #3737 October 30, 2026 20:56
@josemontespg
josemontespg changed the base branch from main to catalogs-mcp-json-functions October 30, 2026 20:56
@josemontespg
josemontespg force-pushed the catalogs-mcp-tool-payload branch from 2d5acbc to d2c4c5b Compare October 30, 2026 20:57
@josemontespg
josemontespg added this pull request to stack #3796 October 30, 2026 20:58
Base automatically changed from catalogs-mcp-json-functions to main October 30, 2026 21:41
Most MCP tools return plain text or JSON content rather than A2UI resources. callMcpTool now returns one payload for every call: toolName, toolInput, toolResult, structuredContent when the server sends one, the joined text blocks, and their json parse (or an array of the per-block parses when a server sends one JSON block per row). With targetDataPath set, each call replaces the object at that path, and a response that arrives after a newer call to the same path has started is not written, so the latest call wins.

callMcpTool validates its arguments with the v1.0 schemas, so a tool argument bound with @path validates, and the published v1 MCP catalog gets from_json and round_trip conformance cases.
@josemontespg
josemontespg force-pushed the catalogs-mcp-tool-payload branch from d2c4c5b to 037c50e Compare October 30, 2026 21:41
@josemontespg
josemontespg removed this pull request from stack #3796 October 30, 2026 21:43
@josemontespg
josemontespg added this pull request to stack #3797 October 30, 2026 21:43

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants