Skip to content

feat(mcp): in-card actions on the answer card via an app-only tool (#369) - #374

Merged
jrosskopf merged 1 commit into
mainfrom
feat/mcp-app-in-card-actions
Nov 17, 2026
Merged

jrosskopf merged 1 commit into
mainfrom
feat/mcp-app-in-card-actions

Conversation

@jrosskopf

@jrosskopf jrosskopf commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #369.

What

A card control that asks for the same answer with other arguments (a page, a filter chip, a refresh) now updates the MCP Apps answer card in place through an app-only tool, instead of a new user turn (ui/message, which Claude stages behind a confirmation banner). Decisions D1–D5 as posted on the issue.

  • Contract. New conversation action {"type":"rerun","args":{…},"fallback":"…"} and a chip's rerun. args are laid over the producing call's arguments. Every other channel (A2A, Gemini Enterprise, Teams, chat, text) renders a rerun as send_message with fallback. A producer surface marks an in-card event with the name prefix triton.in_card: (allowed through passthrough vetting; every other triton.* name stays reserved).
  • App-only tool triton_ui_event. _meta.ui.visibility: ["app"], annotations.readOnlyHint, legacy openai/widgetAccessible. Listed only to a client that declared the MCP Apps extension, and only while some tool is in-card capable. Listing is cosmetic: every call is decided by the dispatcher.
  • Tokens. HMAC with the existing A2UI action key ring over (tool, scope, args), bound to tenant, sub, issuer and an expiry of at most 24 h. A producer token also names the answer's in-card event names and surfaces. Stateless, with no nonce store, which is acceptable only because the path is read-only.
  • Dispatcher::invoke_in_card (single audit pivot), in this order: revocation, per-principal rate limit (burst 10, 2/s), token, event scope and size limits, can_invoke, read-only gate. The read-only gate needs the tool declared in adapter.yaml (tools.<name>.in_card: true, or Dispatcher::with_in_card_tools for an embedding host) and annotated readOnlyHint (single-flight cache: a yes is kept 60 s, a no 5 s). Exactly one audit line per call, with an in_card part: event, component id, token state, and the context's key names and size, never values. The dispatch is buffered, so it cannot turn into an async task.
  • Adapter. Controls are signed only for a card host and a tool that is ready (declared and read-only). Otherwise they are their fallbacks. A refusal is an isError tool result.
  • Widget. Calls the tool via tools/call when the host reports serverTools, else via window.openai.callTool. It replaces the card and sends ui/update-model-context with the one-line card text (setWidgetState on ChatGPT without the bridge). When the call is refused, errors, times out after 15 s, or the answer is one the renderer takes none of, the control's fallback goes out as ui/message. A producer event has no fallback (the producer's own text is never sent as the user's). Also fixes a collapsed frame after a same-height re-render.
  • Docs. Upstream contract §4a, architecture §8.7, realizations §7, widget README, consumer skill reference and manifest template.

Out of scope, noted in the contract: read-only form submits in place (forms stay send_message), and drill-down (stays a new turn, D2).

Tests

  • Unit: token sign/verify (tamper, other key, other sub/tenant/issuer, expiry, cap, object-only args, event scope), arg overlay, rerun projection, the dispatcher gate (bad tokens, not read-only, not declared, event outside scope, revoked and scope-restricted principals, rate limit per principal, one audit line each, no context values).
  • Integration (crates/triton-tests/tests/mcp_in_card.rs, real binary + fake agent): tool listed to card hosts only; signed controls for card hosts and fallbacks elsewhere and for undeclared or non-read-only tools; a page turn, a chained page turn and a filter chip update the card without a turn, with _triton.client.in_card upstream and one audit line; a producer event arrives as _triton.client.a2ui_events; refusals for a writing tool (never reaching the upstream), another principal's, tampered, expired and missing tokens, and an event outside the token's scope; a concurrent burst is rate-limited.
  • Browser (deploy/local-e2e/mcp-widget/run.sh, 55 checks): Next sends one tools/call and no ui/message, the card shows page 2, the frame keeps its height, ui/update-model-context is sent once with the card text. Producer refresh carries the result token. Refusal, error, missing serverTools, a silent host (timeout) and a rejected answer each fall back to one ui/message. A no-card answer keeps the card. A producer's injected fallback is never sent. ChatGPT callTool plus widget state.
test mcp_in_card::the_in_card_goldens_are_pinned ... ok
test mcp_in_card::the_app_only_tool_is_listed_to_card_hosts_only ... ok
test mcp_in_card::a_producer_event_reaches_the_upstream_as_an_a2ui_event ... ok
test mcp_in_card::card_controls_are_signed_for_card_hosts_and_fallbacks_elsewhere ... ok
test mcp_in_card::in_card_calls_are_refused_unless_read_only_and_signed_for_the_caller ... ok
test mcp_in_card::a_page_turn_and_a_filter_update_the_card_in_place ... ok
test mcp_in_card::a_burst_of_in_card_calls_is_rate_limited_per_principal ... ok
test result: ok. 7 passed; 0 failed

Local gate: scripts/check.sh pre-push set, 9 of 9 steps green (Flutter at the CI pin 3.44.4).

Manual checks still open

Claude and ChatGPT: page a list and check that no composer banner appears, the card updates in place, the audit subject matches the original call's, the tool is absent from the model's tool list, and the model knows the current page. ChatGPT: also whether an approval prompt appears, whether widgetAccessible is needed, and whether callTool returns _meta.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EqCfXJb5WRqV9Mz4ZkdkjZ


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

)

A card control that asks for the same answer with other arguments (a page,
a filter chip, a refresh) now updates the MCP Apps card in place instead of
sending a new user turn.

- New conversation action `rerun` ({args, fallback}) and a chip's `rerun`;
  every other channel renders it as `send_message` with the fallback.
  Producer surfaces mark in-card events with the `triton.in_card:` prefix.
- App-only tool `triton_ui_event` (`_meta.ui.visibility: ["app"]`,
  readOnlyHint, `openai/widgetAccessible`), listed only to clients that
  declared the MCP Apps extension while some tool is in-card capable.
- Controls carry an HMAC token (A2UI action key) over (tool, scope, args),
  bound to tenant, sub, issuer and a <= 24 h expiry; producer tokens name
  the answer's in-card event names and surfaces.
- `Dispatcher::invoke_in_card`: revocation, per-principal rate limit,
  token, event scope, authorization, and the read-only gate (declared
  `tools.<name>.in_card` in adapter.yaml AND `readOnlyHint`); one audit
  line with an `in_card` part (key names and sizes, never values).
- Widget: `tools/call` (or `window.openai.callTool`), in-place update,
  `ui/update-model-context`; on refusal, error, timeout or an unusable
  answer the control's fallback goes as `ui/message`. Fixes a collapsed
  frame after a same-height re-render.
- Docs: upstream contract §4a, architecture, realizations, widget README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqCfXJb5WRqV9Mz4ZkdkjZ
@jrosskopf
jrosskopf merged commit 64239c2 into main Nov 17, 2026
3 checks passed
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.

MCP Apps widget: in-card actions via app-only tools (callServerTool) instead of ui/message

1 participant