Skip to content

MCP: a card host's structuredContent is a summary of the card, not every row - #376

Merged
jrosskopf merged 3 commits into
mainfrom
fix/mcp-card-host-structured
Nov 18, 2026
Merged

jrosskopf merged 3 commits into
mainfrom
fix/mcp-card-host-structured

Conversation

@jrosskopf

@jrosskopf jrosskopf commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Why

Live on the Nidorel demo (2026-11-17), ChatGPT behaved differently from Claude:

  • What it did: it got the one-line card text for "List all agents" (it is a card host: card_host: true and io.modelcontextprotocol/ui in the per-call log line). Yet its model called list_agents twice more on its own, then printed all 30 rows as its own table under a card that showed the last page.
  • Claude, same answer: called once.

Cause: ChatGPT shows structuredContent to its model, and that was the full envelope: every row, plus the paging state.

What

The rule lives in one place, mcp_app::model_view, and decides both of a card host's model-visible outputs:

  • Card shows every row (card host, not cut by a budget, at least one named row):
    • content is the card text, as before;
    • structuredContent is {card: {title, context?, rows, shown_in_card: true}, trace_id, latency_ms}, with no row and no cursor. context is the header's context line, e.g. "Page 2 of 3", the same line the text names.
  • Any other case (a cut card, an answer without a card, any non-card client): the full text and the full envelope stay.
  • In-card reruns (MCP Apps widget: in-card actions via app-only tools (callServerTool) instead of ui/message #369) go through the same answer() and follow the same rule.

Tests (red first, spawned binary)

  • mcp_card_text, card host:
    • structuredContent is exactly card + trace_id + latency_ms;
    • a receipt (no rows) and a card cut by its row budget (60 rows) keep the envelope;
    • a non-card client keeps the envelope.
  • mcp_in_card: a page turn's result carries the summary with context: "Page 2 of 3" and no result.
  • model_view unit test: title fallback, trailing punctuation trimmed, title left out when there is none, blank labels not counted, context.
  • mcp_schema (every protocol era), mcp_app_widget, embed_parity: green.
  • Pre-push scripts/check.sh: 9/9 steps. Run with the CI-pinned Flutter 3.44.4; the local system Flutter is now 3.50.0, whose analyzer flags package:flutter/material.dart as deprecated.

Review

An agent crew (correctness and security on Codex, design on Claude) approved. Its follow-ups are in refactor(mcp): one rule decides…:

  • one function for the rule;
  • rows from the named rows;
  • the cut-card test and the exact-keys test;
  • a named card_envelope.

By your decision, the summary also carries the context line.

After merge

Bump Nidorel's vendor/triton, deploy the demo, then re-check "List all agents" in ChatGPT. Expected: one list_agents call, page 1 on the card, no row table from the model.


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

…ot every row

Live on the Nidorel demo, ChatGPT (a card host, so it got the one-line
card text) still called list_agents twice more on its own and printed all
30 rows under the card, which showed the last page: ChatGPT shows
structuredContent to its model, and that was the full envelope with every
row and the paging state. Whenever the card text applies (card host and a
card that shows every row), structuredContent is now
{card: {title, rows, shown_in_card: true}, trace_id, latency_ms}. A cut
card, a card-less answer and every non-card client keep the envelope. The
in-card rerun path gets the same result (one answer()).
…crew review)

- mcp_app::model_view returns the card text and the structuredContent
  summary together, applying the cut/empty guard once; card_text delegates
  to it. rows counts the named rows (a blank label is none), as the card
  text does.
- card_envelope() names the card host's typed-result shape beside
  envelope(); architecture notes that a client wanting the full envelope
  does not declare the MCP Apps extension.
- Tests: a card cut by its row budget keeps the full text and envelope
  (spawned binary); the summary carries exactly card, trace_id and
  latency_ms; model_view's title fallback, punctuation, omitted title and
  blank-label count.
structuredContent.card gets context (e.g. "Page 2 of 3"), the same line
the card text names, so a card host's two model-visible outputs agree.
Still no row and no cursor.
@jrosskopf
jrosskopf merged commit 999ccbb into main Nov 18, 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.

1 participant