Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e9b2b20
feat: Integrate MCP Apps into A2UI
dmandar Mar 2, 2026
77e96a2
chore: address PR review comments from gemini-code-assist
dmandar Mar 2, 2026
24cbc89
fix: Secure postMessage by capturing trusted host origin statefully
dmandar Mar 2, 2026
ab56d17
fix: fully secure MCP iframe initialization handshake with sandbox-in…
dmandar Mar 3, 2026
ad105f4
Merge branch 'main' into md-mcpuinew
dmandar Mar 3, 2026
e22bed7
style: run pyink auto-formatter to fix CI build
dmandar Mar 3, 2026
f5b2f41
fix(markdown-it): add missing package main and exports to resolve dow…
dmandar Mar 10, 2026
22859bf
fix(contact): resolve MCP iframe security issues and location double-…
dmandar Mar 10, 2026
0f43a44
revert(markdown-it): undo package exports change per PR review
dmandar Mar 10, 2026
63a3fd3
refactor(contact): address PR 748 review comments for McpApps integra…
dmandar Mar 10, 2026
04c0782
Merge main and resolve conflicts
dmandar Mar 11, 2026
c1b84a1
fix(lit): resolve compiler type errors and review comments
dmandar Mar 11, 2026
62bfcd3
chore: remove internal Google3 configs and properly align renderer sc…
dmandar Mar 11, 2026
22cfcec
Fix A2UI schema validator for incremental updates and update sample i…
dmandar Mar 12, 2026
6c53d20
Fix f-string curly brace escaping in prompt_builder.py
dmandar Mar 12, 2026
776fa4d
Fix LLM prompt for chart_node_click missing context to extract name
dmandar Mar 12, 2026
6bf4868
Address remaining PR #748 comments
dmandar Mar 13, 2026
7a544f8
Merge remote-tracking branch 'origin/main' into md-mcpuinew
dmandar Mar 13, 2026
441f282
Auto-format python code and add missing Apache license headers
dmandar Mar 13, 2026
b80812e
Merge main into md-mcpuinew
dmandar Mar 13, 2026
5f3a7db
chore: fix CI sample formatting, lit workspace, and revert agent_sdks…
dmandar Mar 13, 2026
57091eb
chore: fix NPM 401 error by regenerating package-lock.json via public…
dmandar Mar 13, 2026
dd1d846
chore: revert non-functional pyink formatting outside sample scope an…
dmandar Mar 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 122 additions & 7 deletions samples/agent/adk/contact_multiple_surfaces/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,131 @@ async def stream(self, query, session_id) -> AsyncIterable[dict[str, Any]]:
if query.startswith("ACTION:") and "view_location" in query:
logger.info("--- ContactAgent.stream: Detected view_location ACTION ---")

# Use the predefined example floor plan
json_content = load_floor_plan_example().strip()
start_idx = json_content.find("[")
end_idx = json_content.rfind("]")
if start_idx != -1 and end_idx != -1:
json_content = json_content[start_idx : end_idx + 1]
from mcp import ClientSession
from mcp.client.sse import sse_client

try:
# Connect to the persistent Starlette SSE server
async with sse_client("http://127.0.0.1:8000/sse") as (read, write):
async with ClientSession(read, write) as mcp_session:
await mcp_session.initialize()

logger.info("--- ContactAgent: Fetching ui://floor-plan-server/map from persistent SSE server ---")
result = await mcp_session.read_resource("ui://floor-plan-server/map")

if not result.contents or len(result.contents) == 0:
raise ValueError("No content returned from floor plan server")

html_content = result.contents[0].text
except Exception as e:
logger.error(f"Failed to fetch floor plan from SSE server: {e}")
yield {
"is_task_complete": True,
"content": f"Failed to load floor plan: {str(e)}"
}
return

json_content = [
{
"beginRendering": {
"surfaceId": "location-surface",
"root": "floor-plan-card"
}
},
{
"surfaceUpdate": {
"surfaceId": "location-surface",
"components": [
{
"id": "floor-plan-card",
"component": {
"Card": {
"child": "floor-plan-col"
}
}
},
{
"id": "floor-plan-col",
"component": {
"Column": {
"children": {
"explicitList": [
"floor-plan-title",
"floor-plan-comp",
"dismiss-fp"
]
}
}
}
},
{
"id": "floor-plan-title",
"component": {
"Text": {
"usageHint": "h2",
"text": {
"literalString": "Office Floor Plan"
}
}
}
},
{
"id": "floor-plan-comp",
"component": {
"McpAppsCustomComponent": {
"htmlContent": html_content,
"height": 400,
"allowedTools": [
"chart_node_click"
]
}
}
},
{
"id": "dismiss-fp-text",
"component": {
"Text": {
"text": {
"literalString": "Close Map"
}
}
}
},
{
"id": "dismiss-fp",
"component": {
"Button": {
"child": "dismiss-fp-text",
"action": {
"name": "close_modal",
"context": []
}
}
}
}
]
}
}
]

logger.info(f"--- ContactAgent.stream: Sending Floor Plan ---")
final_response_content = (
f"Here is the floor plan.\n---a2ui_JSON---\n{json_content}"
f"Here is the floor plan.\n---a2ui_JSON---\n{json.dumps(json_content)}"
)
yield {"is_task_complete": True, "content": final_response_content}
return

if query.startswith("ACTION:") and "close_modal" in query:
logger.info("--- ContactAgent.stream: Handling close_modal ACTION ---")
json_content = [
{
"deleteSurface": {
"surfaceId": "location-surface"
}
}
]
final_response_content = (
f"Modal closed.\n---a2ui_JSON---\n{json.dumps(json_content)}"
)
yield {"is_task_complete": True, "content": final_response_content}
return
Expand Down
Loading
Loading