Skip to content

feat(mcp-apps): add the show-issues view - #636

Open
charislam wants to merge 14 commits into
mainfrom
mcp-apps-issues
Open

charislam wants to merge 14 commits into
mainfrom
mcp-apps-issues

Conversation

@charislam

@charislam charislam commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Feature: an MCP Apps view that lists a project's advisor issues, plus the shared view plumbing it needs. Includes one small fix to get_issues.

What is the current behavior?

The model can read a project's security, performance and health issues with get_issues, but the user has no way to browse them or choose which ones to work on. Every issue the model reads also goes into its context.

What is the new behavior?

show_issues opens an inline view of the project's issues, most severe first, five to a page. The user selects issues across pages and hands them to the assistant with "Review selected issues (N)".

  • The issues stay out of the model's context. The model gets one sentence ("Opened the issues view for the user. It lists N issues."). The view gets its data in the tool result's _meta, which hosts do not show the model.
  • Paging uses a keyset cursor, served by app_paginate_issues, a tool only the view can call. A stale or malformed cursor returns an invalid_cursor error code, and the view offers a refresh.
  • The model can refresh the view after it changes the project, through a view tool, refresh_issues_view.
  • Older copies retire. When a newer view of the same project opens, earlier copies in the chat stop accepting actions, so nobody acts on stale state.
  • Both new tools are view-only. A host without MCP Apps neither lists them nor can call them.
  • Fix: get_issues now reports a category the platform has no advisor for as unsupported, not unavailable, which also means "the check failed".

How to Review

Please review commit by commit. The branch is 8,400 lines across 69 files, but each commit is self-contained and its message explains the design. The order runs from the server's building blocks, through the shared view plumbing, to the view and the tools that open it.

  1. Server: reading and paging issues

    • baafc57 Send a caller error's machine-readable code in the error result.
    • f00fc0e Report a category the platform lacks as unsupported in get_issues.
    • cddd420 Extract readIssues and the issue type enum from the get_issues handler. No behavior change.
    • 875ca9a Add pageIssues: sort, count and cut one page with a keyset cursor.
    • c15880a Define the contract between show_issues and its view: the view data, the _meta key and the input schemas.
  2. Shared view plumbing (packages/mcp-ui/src/shared/)

    • 30fe287 Read a tool error's code, and a view's data from _meta.
    • 8d56772 Let views send a message as the user and update the model context.
    • faacd41 Let views register tools the model can call.
    • c687089 Add useSupersession, which retires a view when a newer copy opens.
    • 82f5c6c Add shared skeleton tokens, a ghost button, chevron icons and a CSS lint rule for container style queries.
  3. The view and the tools that open it

    • 0375d3b Add the show-issues view. This is the largest commit; its message gives a reading order through the five layers.
    • d8ee840 Add the show_issues and app_paginate_issues tools and register the view as an app resource.
    • ae4852c Serve advisor issues from the dev mock API, with four scenarios for the view's edge cases.
    • 49d142b Declare all views as inline-only, so hosts do not offer fullscreen or picture-in-picture.

Verification

  • To try the view without a real project, run pnpm dev:mock from the repo root and call show_issues. Switch scenarios to see the edge cases:

    curl -X POST localhost:4010/__scenario -d '{"name":"show-issues:many"}'
    Scenario What it shows
    show-issues:many 23 issues, more than one server page
    show-issues:none the empty state
    show-issues:category-down health advisors fail, so that check is unavailable
    show-issues:page-fails the first read works, then the next page or a refresh fails

A ToolCallerError can now carry a stable, machine-readable `code`, and
the error result's JSON includes it as `error.code` beside `name` and
`message`. A client can then branch on the kind of failure without
reading the message. The issues view uses this to recognise a stale
paging cursor.

Only a caller error's own code is sent. Other errors can have a `code`
field of their own (Node and Postgres errors do), but those are
internal and stay out of the result.
…upported

get_issues marked a category with no advisor on this platform (health,
on platforms without it) as `unavailable`, the same status as a check
that was attempted and failed. The two mean different things to the
model: a failed check is not a clean assessment and may be worth
retrying, while a missing one never will be.

Such a category now gets its own `unsupported` status, and the tool
description says what it means.
…enum

get_issues read every advisor category inline in its tool handler. The
issues view needs the same read, so it moves to `readIssues` in
`issues.ts`, along with the rule for which failures still throw
(authorization and protocol errors) and which become an `unavailable`
check.

Two pieces that were spelt out more than once are now defined once:
`issueTypeSchema` (all, or one category) and `getAdvisorAdapters`, the
one place that says which advisor categories a platform supports.

get_issues behaves as before. readIssues gets its own tests for the
unsupported and unavailable cases.
`pageIssues` cuts one page out of a project's issues for a view. It
leaves out info-level issues, sorts the rest (critical first, then
security, performance, health, then id), and counts them per category.

Paging uses a keyset cursor: the sort key of the last issue on the
page, encoded as base64url JSON with the issue type it was made for.
Unlike an offset, it stays correct when issues are fixed or appear
between pages. `decodeIssuesCursor` rejects a cursor that is malformed
or was made for another type with an `InvalidIssuesCursorError`.

The module is pure: it knows nothing about tools, and the caller passes
in when the issues were read.
Sets the contract between the coming show_issues tools and their view
before either exists, so the view can be written against it.

- `VIEW_DATA_META_KEY`: the tool result `_meta` key that carries a
  view's data. Hosts do not give `_meta` to the model, so the model
  reads only the result's text.
- `apps/show-issues.ts`: the view data (the first page of issues, when
  and for which project the view opened, and the project facts the view
  puts in its messages), the invalid cursor error code, and the paging
  tool's name and arguments. The mcp-ui package imports these types
  type-only, so fields may be added but never renamed or removed.
- `tools/show-issues-inputs.ts`: the input schemas of `show_issues` and
  `app_paginate_issues`, kept apart from the tools so the view's types
  can reach them without pulling the tools in.
Two changes to how a view reads tool results, both needed by the issues
view:

- Errors: `readToolError` replaces `parseToolError` and returns the
  server's `error.code` beside the message, when a caller error sent
  one. `callTool` throws a `ToolCallError` that carries the code, so a
  view can branch on a failure (an expired paging cursor, say) without
  matching its text.
- View data: a tool can now give the model a sentence and its view the
  data, under `_meta['supabase.com/view']`, which hosts do not show the
  model. `readViewData` reads it. `useMcpView` takes a `read` option to
  choose how a view reads its tool result; the default is still the
  JSON text, so the existing views are unchanged.

`useMcpView` gets its first tests.
`useMcpView` now offers two more host actions, each undefined when the
host lacks the capability:

- `sendMessage` sends a message to the assistant as the user. The text
  is tidied to fit what Claude accepts (no long runs of blank lines or
  spaces). A blank message is refused, and one over 8,000 characters
  throws a `MessageTooLongError` before anything is sent, rather than
  being cut: cutting what the user chose to send would mislead the
  assistant. The rules apply on every host, so no view checks the
  host's name.
- `updateModelContext` replaces what the host shares with the model
  about the view for its next turn.

The issues view uses them to hand selected issues to the assistant and
to tell it what is selected.
A view can now give the model tools of its own (view tools, from the
draft MCP Apps spec). It passes them to `useMcpView` as `tools`, a
function returning each tool's name, description, handler and, once it
should be hidden, `disabled`.

`useMcpView` registers them once, before the view connects so the
handshake declares them, and reads the function again after every
render: a call runs the latest handler, and a tool stays disabled once
a render disables it. Disabling reaches every registration, since
`<StrictMode>` creates the app twice in development.

Underneath, `registerViewTool` registers each tool with
`app.registerTool`, and with WebMCP (`document.modelContext`) where the
browser has it, choosing by feature detection rather than the host's
name. A handler returns the text the model sees and throws to report a
failure. The WebMCP bridge can go once ext-apps 2.1.0, which mirrors to
WebMCP itself, is in.
Each tool call mounts a new view, and the older copies stay live further
up the chat, where a user could act on stale state. `useSupersession`
lets a view learn that a newer copy has opened.

Each view posts a stamp, `{ key, at, id }`, on one shared
`BroadcastChannel`. The key is the view's name plus the project ref, so
only views of the same kind and project retire each other; `at` comes
from the server's clock, and a random `id` breaks ties. A view that
hears a newer stamp with its key retires for good. One that hears an
older stamp answers with its own, so an old view that mounts late (as
when a saved chat is reopened) still learns it is old.

Stamps from the channel are validated, since any view of any version
can post there. Where `BroadcastChannel` is missing or the sandbox
refuses it, the view takes no part and never retires.

The BroadcastChannel fake lives in `test/`, which tsconfig now
includes.
…icons

Shared pieces the issues view needs, added where every view can use
them:

- `--sb-skeleton-background` and `--sb-skeleton-animation` in `base`,
  with the animation turned off under `prefers-reduced-motion`. The
  project card's skeleton now uses them instead of its own copy.
- A quiet `.ghost` button for a minor action beside a primary one.
- Left and right chevron icons, for paging.
- A CSS lint rule for container style queries. Biome's formatter
  rewrites `@container style(…)` as `style (…)`, which queries a
  container named `style` and never matches; `pnpm lint:css` now fails
  on the spaced form.

The CSS skill documents the tokens, the Biome gotcha, and how a view
that must change layout at a width states each threshold once with a
size container and style queries.
The issues view, built into `show-issues.html`. It lists a project's
security, performance and health issues, most severe first, five to a
page. The user can select issues across pages and hand them to the
assistant with "Review selected issues (N)", or, on a host that does
not take messages from views, ask about the selection in the chat.

It lands in one commit because the build makes every folder under
`src/views/` into a view, so the folder cannot exist without its entry
point. It is split into layers, each knowing only the one below it,
and reads best in this order:

1. Reading the server's results: `issues-schema.ts` parses the view
   data and each `app_paginate_issues` page without casting, since the
   view and the server can be different versions. Only the rows are
   required; other parts fall back on their own, and an unreadable row
   is dropped and counted. Type assertions tie the parsed shapes to the
   server's types, imported type-only through a new tsconfig path.
   `issues-client.ts` calls `app_paginate_issues` and parses the page.
2. The list machine (`issues-list.ts`): what is loaded, loading or
   failed, as a pure state machine. Each page load is an effect with a
   request id, and only the newest request's answer is accepted. A
   rejected cursor tells the user the list changed, and Refresh starts
   over. `list-model.ts` turns it into the one model the components
   draw.
3. Selection, prompt and hand-off, also pure: `selection.ts` keeps the
   selected issues across pages and refreshes; `prompts.ts` writes the
   review message, with advisor metadata only (the affected objects,
   which name things the user created, never go in); `handoff.ts` and
   `view-state.ts` hold the hand-off and the top-level machine, which
   refuses every event once a newer view retires it.
4. Wiring: `use-issues.ts` runs the machine and its effects, retires
   the view through `useSupersession`, and is the only place that
   catches errors. `refresh-tool.ts` adds `refresh_issues_view`, the
   view tool the model calls after changing the project; it reloads
   the list and returns one line such as "Issues reloaded: 21 issues,
   was 23."
5. Components (`IssuesList`, `IssueRow`, `SeverityIndicator`, `Pager`,
   `SelectionBar`, `ShowIssues`) that only draw props, `view.css`, and
   the entry point. The layout changes once at a narrow width, set in
   one place with a size container and style queries.

The README describes the layers, how older views retire, and view
tools.
Two debugging tools that open and feed the show-issues view:

- `show_issues` reads every advisor category, then gives the model one
  sentence ("Opened the issues view for the user. It lists N issues.")
  and the view its data in `_meta`: the first page, when and for which
  project it opened, and the project facts the view puts in its
  messages. The issues stay out of the model's context; to read them,
  the model uses get_issues. A project that cannot be read still opens
  the view, with only its id as context.
- `app_paginate_issues` returns one page after a keyset cursor. Only
  the view calls it: it is named with an `app_` prefix and visible to
  the app alone. A malformed or mismatched cursor is rejected, before
  any advisor is read, with the `invalid_cursor` error code, so the
  view can say the list changed and offer a refresh.

Both are marked `viewOnly`: for a host without MCP Apps they are
neither listed nor callable, since without a view they do nothing
useful. The show-issues view is registered as an app resource and
linked from `show_issues`.
The mock Management API now answers the security, performance and
health advisor endpoints, so the issues view can be tried without a
real project. Every scenario serves a few issues by default, and four
new ones cover the view's edge cases:

- `show-issues:many`: 23 issues, more than one server page
- `show-issues:none`: no issues
- `show-issues:category-down`: health advisors fail with a 503
- `show-issues:page-fails`: the first read works, then security
  advisors fail with a 403, so the next page or a refresh fails

Scenarios now list only what they change from a shared base, so adding
a field does not mean repeating it in every scenario.
The views have no fullscreen or picture-in-picture layout. Say so in
the view's own capabilities and in the resource's openai/ui metadata,
so hosts do not offer a mode the views cannot render.
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 46048961527

Coverage increased (+0.05%) to 98.312%

Details

  • Coverage increased (+0.05%) from the base build.
  • Patch coverage: 3 uncovered changes across 2 files (351 of 354 lines covered, 99.15%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
packages/mcp-server-supabase/src/tools/debugging-tools.ts 111 109 98.2%
packages/mcp-server-supabase/src/issues.ts 74 73 98.65%
Total (9 files) 354 351 99.15%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 7001
Covered Lines: 6919
Line Coverage: 98.83%
Relevant Branches: 1532
Covered Branches: 1470
Branch Coverage: 95.95%
Branches in Coverage %: Yes
Coverage Strength: 2257.5 hits per line

💛 - Coveralls

@charislam
charislam marked this pull request as ready for review November 27, 2026 18:51
@charislam
charislam requested a review from a team as a code owner November 27, 2026 18:51
@charislam charislam changed the title Mcp apps issues feat(mcp-apps): add the show-issues view Nov 27, 2026
);

/** Tools removed entirely for hosts without MCP Apps. Derived from tool defs. */
export const viewOnlyToolSet = new Set(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Both show_issues and app_paginate_issues enter supabaseMcpToolSchemas even when Apps are off, which will fail supabase/platform's mcp-tool-auth.test.ts parity check until both names are mapped there. Please link the coordinated supabase/platform bump mapping both tools to the existing advisor permission rule so the hosted package release doesn't break CI.

: legacyShowIssuesInputSchema,
inject: { project_id },
execute: async ({ project_id, type }): Promise<CallToolResult> => {
const [result, project] = await Promise.all([

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Calling account.getProject(project_id) here requires projects:read / project-admin access on top of advisor permissions, so debugging-only or project-scoped callers hit an unnecessary denial that gets silently swallowed. Dropping this lookup and using the already-resolved project_id ref also removes the untrusted project.name from the role: 'user' review prompt (prompts.ts:39).


const matching =
type === 'all' ? all : all.filter((issue) => issue.category === type);
const remaining = after

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Because advisors are re-read on every page and severity is part of the seek key, an unseen warning that escalates to critical between pages moves before the cursor and is silently omitted (next_cursor: null with total still counting it). Bind the cursor to a result revision (or stable ordered fingerprint) and return invalid_cursor when the walk changes so the view falls back to its refresh path, and add a test that mutates severity between pages.

const loading = firstPage.current;
if (!loading) throw new Error('The issues view did not reload.');
const outcome = await loading;
if (outcome.type === 'pageFailed') throw new Error(outcome.message);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When all advisor checks fail with ordinary upstream errors (not 403), pageIssues returns total: 0 with three unavailable checks, so refresh_issues_view tells the model Issues reloaded: 0 issues, was N. (and show_issues at debugging-tools.ts:479 says 0 issues). That can mislead the model into thinking a fix worked; make the model-facing text coverage-aware (error when 0 checks succeeded, label partial reads) and test all-checks-unavailable after an initial populated load.

const { view, project } = key;

useEffect(() => {
if (at === undefined || typeof BroadcastChannel === 'undefined') return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BroadcastChannel has no conversation/connection scope: on shared-origin hosts another tab/conversation for the same project retires this view (and any same-origin script can spoof { at: Number.MAX_VALUE } or read open project refs), while in opaque-origin sandboxes like MCP Inspector v2.15.0 retirement never fires at all. Also, an in-flight refresh_issues_view (use-issues.ts:325-333) can still resolve with a success message after the retired reducer drops its result. Scope retirement to a host-provided conversation identity (or don't claim cross-view retirement when unavailable) and reject/cancel pending model refreshes on retirement.

sendMessage,
updateModelContext,
} = view;
// Only from the tool input: a project-scoped server has no `project_id`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the replay branch where tool input is missing or arrives late, this falls back to type: 'all' and treats an omitted project_id as scoped, so clicking Refresh on a replayed unscoped/filtered view either calls app_paginate_issues without its required project_id or refreshes the wrong filter. Include the effective filter and paging scope in the opening _meta payload and require reopening when older payloads lack trustworthy input.

}
}
);
const unregisterWebMcp = registerWithWebMcp(tool);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@modelcontextprotocol/ext-apps@2.1.0 is already published on npm with native registerTool -> WebMCP mirroring and close/disable teardown. Keeping this custom bridge leaks registrations on React StrictMode remount / SDK close (it only aborts on disable) and will double-register once the lockfile moves to 2.1.0 — let's bump to 2.1.0 directly and drop the bridge.

if (state.handoff.status !== 'sending') return null;
const handed: ActiveState = { ...state, handoff: { status: 'handed' } };
// On success only: on failure the selection stays for another try.
return state.selection.size

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Checkboxes stay interactive while sendMessage is in flight, so selecting issue B after starting Review for A clears both A and B on ack even though B was never sent. Either freeze selection changes while handoff.status === 'sending' or remove only the sent snapshot on ack.


export const CREATE_PROJECT_UI_URI = 'ui://supabase/create-project';
export const CREATE_BRANCH_UI_URI = 'ui://supabase/create-branch';
export const SHOW_ISSUES_UI_URI = 'ui://supabase/show-issues';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CREATE_PROJECT_UI_URI and CREATE_BRANCH_UI_URI are re-exported from packages/mcp-server-supabase/src/index.ts:41-44 so hosted MCP (bramble) doesn't hardcode ui:// strings. Please re-export SHOW_ISSUES_UI_URI there too for consistency.

export const SHOW_ISSUES_UI_URI = 'ui://supabase/show-issues';

const VIEW_META: { ui: McpUiResourceMeta } = {
export const OPENAI_UI_META = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: OpenAI docs cover availableDisplayModes but not preferredDisplayMode, and the standard SDK handshake already declares inline-only. Let's drop preferredDisplayMode unless a specific host needs it, and clarify whether the OpenAI hint is meant to be unconditional outside openaiPluginExtensions.

@Rodriguespn Rodriguespn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The view works nicely in Inspector on the happy path and error scenarios, nice work!

Requesting changes on the blocking inline comments before merging. On your questions:

  1. Yes to both tools once mapped in supabase/platform (comment), and yes to unsupported on get_issues since it is still behind an unrolled feature flag.
  2. Mostly minimal, just drop project.name / getProject (comment), keep scope/filter explicit for replay (comment), and trim unused counts / read_at (non-blocking, worth fixing here since counts makes debugging-tools.ts fetch all 3 advisor categories even on filtered calls).
  3. Yes, keep affected objects out and use the project ref only (comment).
  4. Good direction, left details on live cursor ordering (comment), coverage-aware model text (comment), and BroadcastChannel retirement (comment).
  5. No need for the custom bridge, ext-apps@2.1.0 is already on npm and clears our 7-day release age (comment).

Two small things that can either go here or in a follow-up: filtering getResources with enabledFeatures in server.ts (same as tools) so disabled feature views are not listed, and clearing role="alert" in Announcer.tsx after a failed refresh recovers (pre-existing).

This branch has not been deployed

No deployments
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.

3 participants