Skip to content

feat(mcp apps): create project and create branch ui - #573

Merged
charislam merged 12 commits into
mainfrom
feat/create-project-tools
Nov 19, 2026
Merged

charislam merged 12 commits into
mainfrom
feat/create-project-tools

Conversation

@charislam

@charislam charislam commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Add MCP App views for create project and create branch

What is the current behavior?

No UI for either

What is the new behavior?

CleanShot 2026-11-17 at 15 48 24@2x CleanShot 2026-11-17 at 15 48 37@2x CleanShot 2026-11-17 at 15 48 53@2x CleanShot 2026-11-17 at 15 49 04@2x

How to Review

  • Test locally using pnpm inspector
  • Also connect to ChatGPT using tunnel-client to securely tunnel to locally running server, pnpm dev:mock can make setup easier by running against mock API

Verification

Tested on MCP Inspector and ChatGPT.

@charislam charislam changed the title Feat/create project tools feat(mcp apps): create project and create branch ui Nov 17, 2026
@coveralls

coveralls commented Nov 18, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 44379692934

Coverage increased (+0.3%) to 98.141%

Details

  • Coverage increased (+0.3%) from the base build.
  • Patch coverage: 19 of 19 lines across 3 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 6325
Covered Lines: 6230
Line Coverage: 98.5%
Relevant Branches: 1368
Covered Branches: 1320
Branch Coverage: 96.49%
Branches in Coverage %: Yes
Coverage Strength: 294.22 hits per line

💛 - Coveralls

@charislam
charislam marked this pull request as ready for review November 18, 2026 12:25
@charislam
charislam requested a review from a team as a code owner November 18, 2026 12:25
args: Record<string, unknown>
): Promise<T> {
const result = await app.callServerTool({ name, arguments: args });
return parseToolResult<T>(result);

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.

This PR moved the isError throw out of parseToolResult, but callTool still says it "throws on tool errors", and app.callServerTool doesn't throw on isError results. So every tool error (503, unknown tool, scope rejection, and on hosted the OAuth/FGA denials) reaches callers as { error } typed as T. I reproduced 4 different breakages from this in Inspector (use-poll.ts L64, ReadyActions.tsx L199, ReadyActions.tsx L222, call-tool.ts L29, with screenshots), and this one change fixes all of them (needs parseToolError imported):

Suggested change
return parseToolResult<T>(result);
if (result.isError) throw new Error(parseToolError(result));
return parseToolResult<T>(result);

Comment thread packages/mcp-ui/src/shared/use-poll.ts Outdated
return;
}
if (stopped) return;
if (callbacks.current.isTerminal(next)) {

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.

Same root cause as the callTool comment, with one more problem here: isTerminal runs outside the try, so a bad payload throws an unhandled rejection and polling stops silently. This is create-project:polling-error: one 503, no more polls, spinner forever.

1-poll-error-stuck-spinner

I'd fix two things here in one go: move the terminal/timeout checks inside the try, and retry a couple of times before switching to error. Right now a single blip ends live progress for a provisioning that takes minutes (the mock README's "retry then follows the happy sequence" reads like that was the intent).

),
]).then(
([{ url }, { keys }]) => {
const key = pickKey(keys);

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.

Same here, fixed by the callTool change. Without the development tools (?features=account,database,branching), both calls return "tool not found", pickKey(undefined) throws inside the then, the rejection handler never runs, and the view stays on "Loading connection details…" instead of falling back to the Studio link.

2-no-dev-tools-details-stuck

case 'ping': {
const start = performance.now();
callProjectTool(app, 'execute_sql', projectRef, {
query: 'select 1',

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.

Same root cause as the callTool comment: with the database tools off, execute_sql returns "tool not found" and we show "Reachable, 192 ms" (the mock got no query at all).

3-ping-reachable-without-execute-sql

Separate question: do we need Ping for the POC? It runs raw SQL through execute_sql (readOnlyHint: false), needs DATABASE_READ on hosted, and hosts may ask the user to approve view-initiated write tools. With "Open in Studio" now there, I'd drop it and skip this whole path.

Comment thread packages/mcp-ui/src/shared/call-tool.ts Outdated
* scoped to, and rejects it as an unrecognized key (its args are parsed with a
* strict schema).
*/
const isProjectIdRejected = (err: unknown) =>

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.

Scoped mode (?project_ref=…) is broken today: the scope rejection comes back as an isError result, never as a throw, so this check never matches and create_branch shows "Cannot read properties of undefined (reading 'find')".

4-scoped-branch-find-error

The callTool change makes this reachable again, but I'd remove the regex instead of relying on the Zod error text: in scoped mode project_id isn't in the tool input (CreateBranch.tsx L62-65 already relies on that), so input.project_id === undefined tells us the server is scoped. That drops the error-text coupling and the extra failed call per poll.

Comment thread packages/mcp-ui/package.json Outdated
"typecheck": "tsc --noEmit",
"prebuild": "pnpm typecheck"
"prebuild": "pnpm typecheck && pnpm lint:css",
"lint:css": "node scripts/check-css.mjs"

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.

mcp-ui has no tests yet. A small vitest suite for callTool (isError), usePoll (error / terminal / timeout) and the status → step maps would have caught the isError bugs flagged in call-tool.ts, use-poll.ts and ReadyActions.tsx, and it's the shared code every next view uses. Since those fixes touch exactly these files, I'd add it in this PR.

import { usePoll } from '../../shared/use-poll';
import { useMcpView } from '../../shared/use-mcp-view';

export type Project = {

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.

Project here and Branch in CreateBranch.tsx are hand-written copies of projectSchema / branchSchema, which the server already exports from @supabase/mcp-server-supabase/platform (Branch.status is the 6-value enum there, string here). In the Slack thread we agreed the views build against the server schemas. A type-only import (path alias to the server source, so no build cycle) keeps both views in sync when a schema changes.

const [input, setInput] = useState<Record<string, unknown>>();
const [hostContext, setHostContext] = useState<McpUiHostContext>();

const { app, error } = useApp({

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.

We never check app.getHostCapabilities(). Polling needs serverTools, and the Studio links call app.openLink, which needs openLinks. On a host without them we show a poll error and a dead link. I'd read the capabilities once here and return them with app, so ProgressView can skip polling (and show "ask the assistant to check with …") and ReadyActions can fall back to a plain link.

return 1;
}
// Left COMING_UP but not healthy yet (e.g. ACTIVE_UNHEALTHY).
return 2;

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: INACTIVE, PAUSING, RESTARTING, etc. land here as "Running health checks" and poll until the 10 min timeout. Unlikely right after create, so fine for the POC. Maybe say so in the comment.

import { RESOURCE_MIME_TYPE } from '@modelcontextprotocol/ext-apps/server';
import { resource, type Resource } from '@supabase/mcp-utils';
import createBranchHtml from '@supabase/mcp-ui/create-branch.html';
import createProjectHtml from '@supabase/mcp-ui/create-project.html';

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.

Each view is ~450 kB, and tsup inlines both into the ESM and the CJS chunk (~1 MB each in dist). Fine for the POC and for hosted; should we track it before adding more views (e.g. one bundle serving both views)? Maybe track it as a Linear issue as a follow up after releasing this POC

import createBranchHtml from '@supabase/mcp-ui/create-branch.html';
import createProjectHtml from '@supabase/mcp-ui/create-project.html';

export const CREATE_PROJECT_UI_URI = 'ui://supabase/create-project';

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.

Can we also export these from the package entry (src/index.ts, next to supabaseMcpToolSchemas)? The remote MCP server imports @supabase/mcp-server-supabase and will want to import them too, so its tests can check that create_project / create_branch point at these views and that resources/read serves them, without copying the ui:// strings:

export {
  CREATE_BRANCH_UI_URI,
  CREATE_PROJECT_UI_URI,
} from './resources/app-resources.js';

@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 flows look great in Inspector on the happy path and on the step-failure scenarios, awesome job 🙌

Requesting some changes for the callTool comment: tool errors come back to the views as data. That one line causes the stuck spinner, stuck connection details, false "Reachable" and broken scoped mode (screenshots in the inline comments). The rest are should-fix or nits and can be follow-ups if you'd rather ship.

Comment thread scripts/dev-mock.mjs Outdated

function killGroup(child, signal) {
try {
process.kill(-child.pid, signal);

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: killing a negative pid (a process group) only works on macOS/Linux, so on Windows Ctrl-C leaves the three processes running. Instead of adding a Windows branch, I'd let concurrently handle the processes and wait-on handle the port wait. concurrently uses tree-kill underneath (taskkill on Windows), and it takes care of prefixing output, Ctrl-C and stopping the others when one exits, so most of this file goes away:

import { concurrently } from 'concurrently';

const port = process.env.MOCK_API_PORT ?? '4010';
const apiUrl = `http://localhost:${port}`;
const extraArgs = process.argv.slice(2).map((arg) => JSON.stringify(arg)).join(' ');

const { result } = concurrently(
  [
    { name: 'mock-api', command: 'pnpm mock-api', env: { MOCK_API_PORT: port } },
    {
      name: 'dev-http',
      command: `wait-on tcp:localhost:${port} && pnpm dev:http --api-url ${apiUrl} --secret-url-template "${apiUrl}/mcp/secrets?ref={ref}&name={name}" ${extraArgs}`,
    },
    {
      name: 'inspector',
      command: 'pnpm inspector',
      env: { SUPABASE_ACCESS_TOKEN: process.env.MOCK_TOKEN ?? 'mock' },
    },
  ],
  { killOthersOn: ['failure', 'success'], prefixColors: 'auto' }
);
result.catch(() => process.exit(1));

Comment thread packages/mcp-ui/scripts/check-css.mjs Outdated
utilities: [0, 0, 0],
};

const root = new URL('..', import.meta.url).pathname;

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.

.pathname returns a percent-encoded path (and /C:/… on Windows), so pnpm build fails in prebuild when the checkout path contains a space, or on Windows. fileURLToPath from node:url handles both (needs import { fileURLToPath } from 'node:url'; up top):

Suggested change
const root = new URL('..', import.meta.url).pathname;
const root = fileURLToPath(new URL('..', import.meta.url));

charislam and others added 9 commits November 18, 2026 13:26
…ady state

- Add an "Open in Studio" button to the ready actions, linking to the project's (or branch's own project's) dashboard page
- Rename the connection-details fallback link to "Open in Studio" and add an external-link icon
- Share native button styles with button-styled links via `:is(button, a:where(.button))` instead of duplicating them; document the pattern in the mcp-ui-css skill
So the remote server's tests can check which tools point at the views and
that resources/read serves them without copying the ui:// strings.
- callTool throws on isError results; callServerTool returns them as data,
  which left spinners and connection details stuck, showed a false ping
  result and broke project-scoped mode.
- usePoll checks terminal/timeout inside the try, retries a failing poll
  twice before giving up, keeps done final and restarts after timeout or
  error when its inputs change.
- Detect a project-scoped server from the missing project_id in the tool
  input instead of matching the Zod error text.
- Read host capabilities: without serverTools, don't poll and ask the user
  to check with the assistant; without openLinks, hide Open in Studio and
  offer the Studio link to copy.
- Drop Ping project, which ran raw SQL through execute_sql.
- Type Project and Branch from the server's platform schemas.
- Add a vitest suite for callTool, tool results, usePoll and the status
  maps, run in its own CI job.
concurrently stops all three processes on Ctrl-C on every platform (the
process-group kill didn't work on Windows), and wait-on waits for the mock
API's port. MCP_QUERY adds query params to the MCP URL Inspector connects
to, for the no-development-tools and project-scoped scenarios.
@charislam
charislam force-pushed the feat/create-project-tools branch from 93964b5 to eabaf9f Compare November 18, 2026 18:28
URL.pathname stays percent-encoded and is /C:/… on Windows, so pnpm build
failed in prebuild for a checkout path with a space, or on Windows.
The views import Project and Branch types from the server source, which
imports @supabase/mcp-utils. Without a declared dependency, pnpm built
mcp-ui alongside mcp-utils and its typecheck ran before mcp-utils' types
existed.
description: `Creates a new Supabase project, which can add to the organization's bill. The user must agree to any nonzero quoted cost before the project is created. ${callBeforeConfirmingDescription} A project quoted at $0 may be created without a cost-confirmation form. Always ask the user which organization to create the project in. The project can take a few minutes to initialize. Call \`get_project\`, waiting a few seconds between checks, until \`status\` is \`ACTIVE_HEALTHY\` before running SQL, migrations, or other database tools against it. If \`status\` becomes \`INIT_FAILED\` or \`REMOVED\`, stop and tell the user.`,
parameters: createProjectInputSchema,
outputSchema: createProjectOutputSchema,
_meta: { ui: { resourceUri: CREATE_PROJECT_UI_URI } },

@Rodriguespn Rodriguespn Nov 18, 2026 •

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: the resources type their _meta with McpUiResourceMeta, but the tools' _meta is an untyped literal. Typing it the same way lets typecheck catch it if ext-apps changes the shape (same in branching-tools.ts):

Suggested change
_meta: { ui: { resourceUri: CREATE_PROJECT_UI_URI } },
_meta: { ui: { resourceUri: CREATE_PROJECT_UI_URI } } satisfies { ui: McpUiToolMeta },

with import type { McpUiToolMeta } from '@modelcontextprotocol/ext-apps';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is already covered, I think. The entire block has a satisfies ToolDef at the end which enforces the type here.

@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.

Lgtm! Thanks for addressing my feedback. Left a nit comment to use the _meta type that comes from the official sdk to catch any drift from this type on our CI.

@charislam
charislam merged commit a4e8c43 into main Nov 19, 2026
6 checks passed
@supabase-releaser supabase-releaser Bot mentioned this pull request Nov 19, 2026
@charislam
charislam deleted the feat/create-project-tools branch November 19, 2026 21:11
@charislam
charislam restored the feat/create-project-tools branch November 19, 2026 21:11
charislam added a commit that referenced this pull request Nov 19, 2026
…y import (#576)

Stacked on #573

## What kind of change does this PR introduce?

Refactor (no intended change to rendered output; see Verification).

## What is the current behavior?

Every view imports one shared stylesheet (`src/shared/styles.css`), so
each view's single-file HTML ships CSS for every component whether or
not it renders that component. That does not scale as views are added.

Related issues: none linked.

## What is the new behavior?

- `src/shared/styles.css` is split into `src/shared/base.css` (the
global core: layer order statement, tokens, native element styles,
`.sr-only`) plus one CSS file per component. Each component file owns
one class in the `components` layer and is imported by the TSX component
that renders it. A view now ships `base.css` plus the CSS of the
components it imports. Rules were moved verbatim; the authoring model
(plain CSS, cascade layers, specificity caps, `:where()`,
`data-slot`/`data-state`/`data-tone`) is unchanged.
- The layer order statement lives only in `base.css`, which must be the
first import in every view's `main.tsx`.
- Component custom properties are renamed from `--sb-local-*` to
`--sb-component-<component>-*`, namespaced by the component's file (for
example `--sb-component-progress-card-radius`). A component reads its
own properties without a fallback. A component reading another
component's properties must provide a fallback, because its file can
ship without the other's. `ready-actions.css` does this for the
`progress-card` properties it reads. `--sb-view-<view>-*` is reserved
for a view's `view.css`.
- `scripts/check-css.mjs` (`pnpm lint:css`) now checks every CSS file
under `src/` and enforces: one block per layer per file; which layers
each kind of file may contain; a component class styled in only one
file; the layer statement only in `base.css`, and `base.css` first in
each `main.tsx`; and the custom property namespace and fallback rules.
- `README.md` and `.agents/skills/mcp-ui-css/SKILL.md` describe the new
layout and rules.

## How to Review

1. **Shared core and tokens**
   - `packages/mcp-ui/src/shared/base.css`
- Layer order statement, tokens, and native element styles that every
view now imports.

2. **Component ownership and imports**
- `packages/mcp-ui/src/shared/badge.css`, `button.css`,
`copy-field.css`, `icon.css`, `message.css`, `progress-card.css`,
`ready-actions.css`, `summary.css`
- Each file owns one component class in the `components` layer; confirm
the matching TSX file in `packages/mcp-ui/src/shared/` imports it.

3. **Cross-component property fallbacks**
   - `packages/mcp-ui/src/shared/ready-actions.css`
   - Reads of `progress-card` custom properties, which carry fallbacks.

4. **View entrypoints**
   - `packages/mcp-ui/src/views/create-project/main.tsx`
   - `packages/mcp-ui/src/views/create-branch/main.tsx`
   - `base.css` is the first import in each.

5. **Rules enforced by the lint**
   - `packages/mcp-ui/scripts/check-css.mjs`
- The checks that `pnpm lint:css` now runs over every CSS file under
`src/`.

## Verification

- `pnpm build` in `packages/mcp-ui` passes (typecheck, `lint:css` on 9
files, both views).
- `pnpm exec biome check packages/mcp-ui` from the repository root
passes.
- The built CSS of both views has the same rules per layer with
identical declarations as before the change, apart from the renamed
properties and the added fallbacks. Rule order differs only inside the
`components` layer.
- A local side-by-side regression page rendered 55 states of the two
views (server-rendered from the real components) with the old and new
CSS, and compared computed styles and element geometry for every
element: 0 differences. It was checked in Chrome in light/narrow and
dark/wide against the final CSS.
- A throwaway view importing only `Badge` shipped about 4.9 KB of CSS
and none of the other components' rules.
- Size today: the two existing views use the same components, so nothing
is pruned yet. Their CSS grows from 12,029 to about 12,416 bytes each,
from the fallbacks and longer property names.

## Additional context

The two existing views use the same components, so this change does not
reduce their output yet; the benefit applies to views that import a
subset.
Rodriguespn pushed a commit that referenced this pull request Nov 20, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>mcp-server-supabase: 0.19.0</summary>

##
[0.19.0](mcp-server-supabase-v0.18.0...mcp-server-supabase-v0.19.0)
(2026-11-19)


### Features

* **mcp apps:** create project and create branch ui
([#573](#573))
([a4e8c43](a4e8c43))


### Bug Fixes

* **mcp-server-supabase:** detect deno.jsonc as the default edge
function import map ([#559](#559))
([16bde19](16bde19))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
charislam added a commit that referenced this pull request Nov 20, 2026
…#578)

Stacked on #573. Redesigns the `create_project` and `create_branch`
views as one shared project card.

## What changed

- **One card for both views.** `ProjectCard` shows breadcrumbs
(organization, and for a branch its project), the name, a status badge,
the ref and region, and an Open in dashboard action. Connection details
sit below once it is ready.
- **The badge names the current step** ("Creating", "Checking health",
"Running migrations", …) instead of a step list, then reads "Active" or
"Failed". A failure says which step it failed on.
- **Retry.** When status checks keep failing or the 10-minute timeout
passes, a retry icon appears beside the badge and resumes polling.
`usePoll` gains a `restartKey` for this.
- **Loading state.** Before the tool result arrives, the card keeps its
layout, filling in what the call's arguments say and showing skeletons
for the rest.
- **Shared logic.** `useCreationStatus` owns polling, Retry, the badge
and note for each state, and the screen reader announcements. Each view
supplies how to read its status and how a status maps to a step.
`ProgressView` and `StepStatus` are removed.
- **Colours go through Studio's semantic tokens** (`--foreground`,
`--border`, `--card`, …). A bridge in the `base` layer maps the host's
MCP Apps colour variables onto them, and `pnpm lint:css` fails on a host
colour read anywhere else.
- **Two mock scenarios** for the new states:
`create-project:health-checks` and `create-project:polling-down`.

## Why

- The card matches the project card in the other Supabase surfaces, and
still reads correctly when a conversation is reopened long after
creation finished, where a list of completed steps does not.
- Hosts disagree about what each MCP Apps colour variable means
(Claude's `--color-border-primary` is a strong line, Codex's is a
control outline). Mapping them once onto Studio's tokens keeps the views
consistent across hosts and lets the components move into Studio
unchanged. The table of choices is in the bridge's comment in
`styles.css`.

## Verification

- `pnpm --filter @supabase/mcp-ui test`: 64 tests pass, including new
view tests for both cards (steps, failure, Retry, timeout, loading
skeletons, breadcrumbs).
- `pnpm --filter @supabase/mcp-ui build` (typecheck and `lint:css`)
passes.
- Checked both views in MCP Inspector against the mock API (`pnpm
dev:mock`): each steps through to Active and loads its connection
details; the branch card shows "Organization / Project" above the branch
name.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.2 <[email protected]>
Co-authored-by: Pedro Rodrigues <[email protected]>
Co-authored-by: Charis Lam <[email protected]>
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