Skip to content

fix(mcp-apps): Lazily discover UI tools for cloud runs - #3851

Merged
charlesvien merged 2 commits into
mainfrom
fix/mcp-apps-lazy-discovery
Jul 27, 2026
Merged

fix(mcp-apps): Lazily discover UI tools for cloud runs#3851
charlesvien merged 2 commits into
mainfrom
fix/mcp-apps-lazy-discovery

Conversation

@charlesvien

@charlesvien charlesvien commented Jul 27, 2026

Copy link
Copy Markdown
Member

Problem

MCP app cards (like the loop builder's review card) only render if the desktop has started a local agent session since app launch. That's because the app only learns which MCP tools have a UI during a discovery step that a local session triggers. Cloud runs (loop builder, repo-less chat) never start a local session, so the check always says "no UI" and the card silently never appears. The agent then points users at a Create button that doesn't exist.

The same gap means cloud runs fetch app HTML without its CSP metadata, so since #3803 they get the restrictive default CSP.

Changes

When a UI lookup misses and the server hasn't been discovered yet, connect and discover it on the spot instead of waiting for a local session. Resource fetches also load CSP metadata first. A failed discovery throws with a 60s backoff so the UI retries later instead of caching "no card" forever.

How did you test this?

  • 7 new unit tests in @posthog/core covering the lazy path, failure backoff and CSP attachment.
  • biome lint packages/core and typecheck on core and host-router, all clean.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

@trunk-io

trunk-io Bot commented Jul 27, 2026

Copy link
Copy Markdown

😎 This pull request was merged.

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 68b361f.

@charlesvien
charlesvien marked this pull request as ready for review July 27, 2026 19:20
@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "discover MCP UI tools lazily for cloud r..." | Re-trigger Greptile

@charlesvien charlesvien added the Stamphog This will request an autostamp by stamphog on small changes label Jul 27, 2026
github-actions[bot]
github-actions Bot previously approved these changes Jul 27, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Contained core-package bugfix (lazy MCP UI discovery for cloud runs) with matching new unit tests covering the added logic paths; no auth/billing/CI/dependency/migration surface touched, and a Greptile bot review with a positive reaction adds further signal.

  • 👍 on the PR from greptile-apps[bot].
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 196L, 1F substantive, 317L/2F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1d-complex (317L, 2F, single-area, fix)
stamphog 2.0.0b3 .stamphog/policy.yml @ 05b4aa0 · reviewed head ac9e493

@stamphog
stamphog Bot dismissed github-actions[bot]’s stale review July 27, 2026 19:35

New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.

@stamphog

stamphog Bot commented Jul 27, 2026

Copy link
Copy Markdown

Note

🤖 stamphog reviewed 68b361fa539e688be390bc1cb94ae44680975fd7 — verdict: ESCALATE

This changes how CSP metadata is warmed and attached to MCP app UI resource fetches — a security-sensitive surface controlling what embedded HTML can do — and despite solid test coverage, it has no independent review (0 top-level reviews; only a Greptile discussion comment plus a lone 👍, and no owning-team or strong-familiarity author signal).

  • 👍 on the PR from greptile-apps[bot].
  • Touches CSP metadata caching/attachment for MCP app UI resources (security-relevant surface) without a formal review (0 top-level reviews).
  • No ownership match and author familiarity with these lines isn't reported as STRONG, so there's no independent-assurance path other than a human review.
  • The only external signal is a Greptile discussion comment + 👍 reaction, which is weak evidence, not a substantive review with no unresolved concerns.
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 243L, 1F substantive, 472L/2F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1d-complex (472L, 2F, single-area, fix)
stamphog 2.0.0b3 .stamphog/policy.yml @ 05b4aa0 · reviewed head 68b361f

@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jul 27, 2026
@charlesvien
charlesvien merged commit d723199 into main Jul 27, 2026
32 checks passed
@charlesvien
charlesvien deleted the fix/mcp-apps-lazy-discovery branch July 27, 2026 19:43
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