docs(guides): improve A2UI over MCP guide for new developers#1042
docs(guides): improve A2UI over MCP guide for new developers#1042wrenj merged 4 commits intogoogle:mainfrom
Conversation
Key improvements: - Add introduction explaining what A2UI is for newcomers - Add prerequisites section (Python, uv, mcp package) - Add Quick Start section with actual run instructions - Note version mismatch between sample (v0.8) and guide (v0.10) - Add missing 'import json' in Python example - Fix inconsistent decorator usage (@self.tool vs @app.call_tool) - Fix error handler accessing wrong field names - Add audience table for verbalization control - Add Related Guides section with cross-references - Add Samples table with direct links - Add cross-reference from MCP Apps guide back to this guide - Improve explanatory comments throughout code examples
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Key improvements: - Added Quick Start section with step-by-step instructions to run the sample - Added prerequisites section - Added visual flow diagram showing how A2UI over MCP works - Added note about a2ui-agent-sdk pip package - Fixed error handler to match actual payload structure (code/message, not error) - Added audience annotation table for clarity - Added section on using the A2UI Agent SDK - Added Next Steps section with links to related guides - Improved overall flow: run something first, then learn the protocol
There was a problem hiding this comment.
Code Review
This pull request updates the A2UI over MCP documentation to include prerequisites, a quick start guide, and updated code examples using the v0.10 schema. The review feedback identifies several issues in the Python code snippets, including the use of an undefined 'self' variable in decorators and incorrect return types for tool handlers, which should return 'CallToolResult' instead of a list to ensure compatibility with the MCP SDK.
I am having trouble creating individual review comments. Click here to see my feedback.
docs/guides/a2ui_over_mcp.md (105)
Using @self.tool() is confusing in a standalone code snippet as self is not defined. While the note at line 228 explains this refers to the FastMCP API, it is more idiomatic for documentation to use a standard variable name like mcp (e.g., @mcp.tool()) to avoid implying a class context that isn't shown.
@mcp.tool()
docs/guides/a2ui_over_mcp.md (212-225)
The low-level MCP Server.call_tool handler is expected to return a types.CallToolResult object (or a dictionary matching its schema), which contains a content list. Returning a list[types.TextContent] directly will cause a validation error in the MCP SDK. This is inconsistent with the correct usage shown earlier in the guide (line 149).
async def handle_call_tool(name: str, arguments: dict) -> types.CallToolResult:
if name == "action":
action_name = arguments["name"]
context = arguments.get("context", {})
if action_name == "confirm_booking":
start = context["start"]
end = context["end"]
return types.CallToolResult(content=[types.TextContent(
type="text",
text=f"Booking confirmed from {start} to {end}."
)])
raise ValueError(f"Unknown action: {action_name}")
docs/guides/a2ui_over_mcp.md (256-266)
Similar to the action handler, the error handler should return a types.CallToolResult to be compatible with the low-level MCP Server API. Returning a list of content items directly is not supported by the call_tool decorator's expected return type.
async def handle_call_tool(name: str, arguments: dict) -> types.CallToolResult:
if name == "error":
code = arguments.get("code", "UNKNOWN")
message = arguments.get("message", "")
surface_id = arguments.get("surfaceId", "")
# Log or handle the error
return types.CallToolResult(content=[types.TextContent(
type="text",
text=f"Received error {code} on surface {surface_id}: {message}"
)])
|
Hey @wrenj — you wrote the original version of this guide, so wanted to loop you in on the rewrite. Main changes:
Would love your review on whether the protocol details are still accurate after the restructure. cc @nanyu |
73b4d3e to
4efb67c
Compare
Embeds a 37s narrated tour showing: 1. Terminal: clone, run the MCP recipe sample 2. JSON→UI: A2UI payload transformed into a rendered recipe card
What changed
Rewrote the A2UI over MCP guide to be more developer-friendly. Walked through it as a new developer and fixed every pain point.
Key improvements
a2ui-agent-sdkreference — mentions the pip package for production useerror_payload['error']but the payload hascodeandmessageat top levelIssues found (not fixed in this PR)
a2ui-over-mcp-recipesample'spyproject.tomldepends ona2ui-agent(local path) — may need updating toa2ui-agent-sdkfor the published package namecc @nanyu @jacobsimionato