Repository navigation
Conversation
c227dbe to
f99b4b1
Compare
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.
f99b4b1 to
49d142b
Compare
Coverage Report for CI Build 46048961527Coverage increased (+0.05%) to 98.312%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
| ); | ||
|
|
||
| /** Tools removed entirely for hosts without MCP Apps. Derived from tool defs. */ | ||
| export const viewOnlyToolSet = new Set( |
There was a problem hiding this comment.
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([ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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`. |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
@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 |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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:
- Yes to both tools once mapped in
supabase/platform(comment), and yes tounsupportedonget_issuessince it is still behind an unrolled feature flag. - Mostly minimal, just drop
project.name/getProject(comment), keep scope/filter explicit for replay (comment), and trim unusedcounts/read_at(non-blocking, worth fixing here sincecountsmakesdebugging-tools.tsfetch all 3 advisor categories even on filtered calls). - Yes, keep affected objects out and use the project ref only (comment).
- Good direction, left details on live cursor ordering (comment), coverage-aware model text (comment), and
BroadcastChannelretirement (comment). - No need for the custom bridge,
ext-apps@2.1.0is 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).
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_issuesopens 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)"._meta, which hosts do not show the model.app_paginate_issues, a tool only the view can call. A stale or malformed cursor returns aninvalid_cursorerror code, and the view offers a refresh.refresh_issues_view.get_issuesnow reports a category the platform has no advisor for asunsupported, notunavailable, 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.
Server: reading and paging issues
baafc57Send a caller error's machine-readablecodein the error result.f00fc0eReport a category the platform lacks asunsupportedinget_issues.cddd420ExtractreadIssuesand the issue type enum from theget_issueshandler. No behavior change.875ca9aAddpageIssues: sort, count and cut one page with a keyset cursor.c15880aDefine the contract betweenshow_issuesand its view: the view data, the_metakey and the input schemas.Shared view plumbing (
packages/mcp-ui/src/shared/)30fe287Read a tool error's code, and a view's data from_meta.8d56772Let views send a message as the user and update the model context.faacd41Let views register tools the model can call.c687089AdduseSupersession, which retires a view when a newer copy opens.82f5c6cAdd shared skeleton tokens, a ghost button, chevron icons and a CSS lint rule for container style queries.The view and the tools that open it
0375d3bAdd the show-issues view. This is the largest commit; its message gives a reading order through the five layers.d8ee840Add theshow_issuesandapp_paginate_issuestools and register the view as an app resource.ae4852cServe advisor issues from the dev mock API, with four scenarios for the view's edge cases.49d142bDeclare 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:mockfrom the repo root and callshow_issues. Switch scenarios to see the edge cases:curl -X POST localhost:4010/__scenario -d '{"name":"show-issues:many"}'show-issues:manyshow-issues:noneshow-issues:category-downshow-issues:page-fails