From 05016e6ae3923ab2fbf8850ed7b30ce3e6dd9c5f Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sun, 8 Nov 2026 09:36:15 -0500 Subject: [PATCH 1/2] Figma card offers Use my own Figma app with its redirect URL and scopes; a key stays under Use a key instead --- dashboard/e2e/integrations-page.spec.ts | 40 +++++ .../integrations/mcp-callback/page.tsx | 14 +- dashboard/src/components/mcp-server-panel.tsx | 162 +++++++++++++++++- dashboard/src/lib/api.ts | 37 +++- dashboard/src/lib/openapi-fields.ts | 2 +- 5 files changed, 247 insertions(+), 8 deletions(-) diff --git a/dashboard/e2e/integrations-page.spec.ts b/dashboard/e2e/integrations-page.spec.ts index aaa2a4dc..4219e0d3 100644 --- a/dashboard/e2e/integrations-page.spec.ts +++ b/dashboard/e2e/integrations-page.spec.ts @@ -158,6 +158,13 @@ async function mockApi(page: Page, init: Partial = {}): Promise { + const db = await mockApi(page); + const figma = db.items.find((i) => i.id === "figma")!; + (figma.detail as Record).own_app_redirect_uri = "https://coderhelm.example.com/settings/integrations/mcp-callback/"; + (figma.detail as { plugin: Record }).plugin.own_app = { + authorize: "https://www.figma.com/oauth", + token: "https://api.figma.com/v1/oauth/token", + refresh: "https://api.figma.com/v1/oauth/refresh", + scopes: ["current_user:read", "file_content:read"], + console: "https://www.figma.com/developers/apps", + guide: "https://developers.figma.com/docs/rest-api/oauth-apps/", + }; + await page.goto("/settings/integrations#integration-figma"); + const panel = row(page, "figma").getByTestId("own-app"); + await expect(panel).toContainText("Use my own Figma app"); + await expect(panel.getByTestId("own-app-redirect")).toHaveText("https://coderhelm.example.com/settings/integrations/mcp-callback/"); + await expect(panel).toContainText("current_user:read, file_content:read"); + await expect(panel.getByRole("link", { name: "www.figma.com/developers/apps" })).toHaveAttribute("href", "https://www.figma.com/developers/apps"); + // The key form waits behind its disclosure. + await expect(row(page, "figma").getByText("Use a key instead")).toBeVisible(); + const go = panel.getByRole("button", { name: "Save and connect with Figma" }); + await expect(go).toBeDisabled(); + await panel.getByLabel("Client ID").fill("client-1"); + await panel.getByLabel("Client secret").fill("secret-1"); + await go.click(); + // Saved, then sent to Figma's sign-in, whose answer the callback page finishes. + await expect.poll(() => db.calls.some((c) => c.path === "/api/mcp-servers/oauth/callback")).toBe(true); + const saved = db.calls.find((c) => c.method === "PUT" && c.path === "/api/mcp-servers/apps/figma"); + expect(saved?.body).toEqual({ client_id: "client-1", client_secret: "secret-1" }); + expect(db.calls.some((c) => c.method === "POST" && c.path === "/api/mcp-servers/app-figma/connect")).toBe(true); + await expect(page).toHaveURL(/\/settings\/integrations\/#integration-figma$/); +}); diff --git a/dashboard/src/app/settings/integrations/mcp-callback/page.tsx b/dashboard/src/app/settings/integrations/mcp-callback/page.tsx index 7e70c1cb..2becdbbd 100644 --- a/dashboard/src/app/settings/integrations/mcp-callback/page.tsx +++ b/dashboard/src/app/settings/integrations/mcp-callback/page.tsx @@ -27,7 +27,7 @@ export default function McpCallbackGuarded() { ); } -type View = { kind: "working" } | { kind: "idle" } | { kind: "failed"; message: string } | { kind: "done"; name: string; note: string }; +type View = { kind: "working" } | { kind: "idle" } | { kind: "failed"; message: string } | { kind: "done"; name: string; note: string; ownApp: boolean }; function McpCallback() { const [view, setView] = useState({ kind: "working" }); @@ -61,7 +61,7 @@ function McpCallback() { .then((r) => { const s = r.server; const knowledgeApp = s.catalog_id?.startsWith("source:"); - setView({ kind: "done", name: knowledgeApp ? s.name.replace(/ \(knowledge\)$/, "") : s.name, note: knowledgeApp ? "" : (r.tools_error ?? "") }); + setView({ kind: "done", name: knowledgeApp ? s.name.replace(/ \(knowledge\)$/, "") : s.name, note: knowledgeApp ? "" : (r.tools_error ?? ""), ownApp: !!r.own_app }); // Opened as a popup (a sign-in card in a chat or a run, or Knowledge // signing in without leaving its page): tell the page that opened // it, and close. That page carries on by itself. @@ -107,7 +107,15 @@ function McpCallback() { )} {view.kind === "done" && ( -

{view.note ? "Connected, but its tools couldn't be listed yet. Open Integrations to try again." : "Taking you back to pick its tools…"}

+

+ {view.ownApp + ? view.note + ? `Signed in, but ${view.name} didn't accept the token. Open Integrations to see why.` + : "Taking you back to Integrations…" + : view.note + ? "Connected, but its tools couldn't be listed yet. Open Integrations to try again." + : "Taking you back to pick its tools…"} +

{view.note && }
)} diff --git a/dashboard/src/components/mcp-server-panel.tsx b/dashboard/src/components/mcp-server-panel.tsx index 1243c977..a96483c6 100644 --- a/dashboard/src/components/mcp-server-panel.tsx +++ b/dashboard/src/components/mcp-server-panel.tsx @@ -1,7 +1,7 @@ "use client"; import { useState } from "react"; -import { api, type Integration, type McpServer, type PluginDef } from "@/lib/api"; +import { api, type Integration, type McpServer, type OwnAppState, type PluginDef } from "@/lib/api"; import { errorMessage } from "@/lib/data-sources"; import { Field, SecretInput } from "./field"; import { Disclosure } from "./disclosure"; @@ -9,7 +9,8 @@ import { MarkdownEditor } from "./markdown-editor"; import { useConfirm } from "./confirm-dialog"; import { useToast } from "./toast"; import { inputClass, linkButton, primaryButton, secondaryButton } from "./ui"; -import { connectCatalogServer } from "./mcp-servers"; +import { connectCatalogServer, startMcpSignIn } from "./mcp-servers"; +import { CopyButton } from "./copy-button"; // A catalog MCP server (Sentry, Linear, Notion…), opened in place on // Integrations and on Connections: signing in through the vendor's remote @@ -17,9 +18,22 @@ import { connectCatalogServer } from "./mcp-servers"; /** An MCP server: credentials (entered here, never shown again), its test, its instructions, and turning it off. */ export function PluginPanel({ item, onChanged, onClose }: { item: Integration; onChanged: () => Promise; onClose: () => void }) { - const d = item.detail as { plugin: PluginDef; enabled: boolean; has_credentials: boolean; custom_prompt: string; remote?: McpServer | null }; + const d = item.detail as { plugin: PluginDef; enabled: boolean; has_credentials: boolean; custom_prompt: string; remote?: McpServer | null; own_app?: OwnAppState | null; own_app_redirect_uri?: string | null }; const p = d.plugin; const keyForm = ; + // The vendor's MCP server takes only apps it approved, but its API takes + // the team's own app: sign in with that, or use a key. + if (p.own_app) { + const signedIn = d.own_app?.status === "connected"; + return ( +
+ + + {keyForm} + +
+ ); + } const noKey = p.key_unavailable ? (

{p.key_unavailable} @@ -127,6 +141,148 @@ function OAuthOffer({ plugin }: { plugin: PluginDef }) { ); } +/** The team's own OAuth app with the vendor: where to create it, its client id and secret, and signing in with it. */ +function OwnAppPanel({ plugin, state, redirectUri, onChanged }: { plugin: PluginDef; state: OwnAppState | null; redirectUri: string; onChanged: () => Promise }) { + const app = plugin.own_app!; + const [clientId, setClientId] = useState(state?.client_id ?? ""); + const [secret, setSecret] = useState(""); + const [busy, setBusy] = useState<"" | "save" | "connect" | "remove">(""); + const [error, setError] = useState(""); + const { toast } = useToast(); + const { confirm } = useConfirm(); + // The API names this install's callback; the page's own address is the same one. + const redirect = redirectUri || state?.redirect_uri || `${window.location.origin}/settings/integrations/mcp-callback/`; + const sameApp = !!state && clientId.trim() === state.client_id; + const canSave = !!clientId.trim() && (!!secret.trim() || (sameApp && state!.has_secret)); + + const connect = async (id: string) => { + setBusy("connect"); + try { + await startMcpSignIn(id); + } catch (e) { + setError(errorMessage(e, "Couldn't start the sign-in.")); + setBusy(""); + } + }; + const save = async (thenConnect: boolean) => { + setBusy("save"); + setError(""); + try { + const r = await api.saveOwnApp(plugin.id, clientId.trim(), secret.trim()); + setSecret(""); + if (thenConnect) { + await connect(r.own_app.id); + return; + } + toast(`Your ${plugin.name} app is saved`); + await onChanged(); + } catch (e) { + setError(errorMessage(e, "Couldn't save the app.")); + } finally { + setBusy((b) => (b === "save" ? "" : b)); + } + }; + const remove = async () => { + if (!state) return; + const ok = await confirm({ + title: `Remove your ${plugin.name} app?`, + message: `Agents stop using its sign-in (and use the saved key, if there is one). The app itself stays in ${plugin.name}.`, + confirmLabel: "Remove", + destructive: true, + }); + if (!ok) return; + setBusy("remove"); + try { + await api.removeMcpServer(state.id); + setClientId(""); + await onChanged(); + } catch (e) { + toast(errorMessage(e, "Couldn't remove it."), "error"); + } finally { + setBusy(""); + } + }; + + return ( +

+

Use my own {plugin.name} app

+ {state?.status === "connected" ? ( +

+ Signed in{state.connected_by ? ` by ${state.connected_by}` : ""}. Agents use {plugin.name} with this sign-in. +

+ ) : state?.status_reason ? ( +

+ {state.status_reason} +

+ ) : null} +
    +
  1. + Create an app at{" "} + + {app.console.replace(/^https:\/\//, "")} + {" "} + under your {plugin.name} team or organization. +
  2. +
  3. + Add this redirect URL:{" "} + + {redirect} + {" "} + +
  4. +
  5. + Give it exactly these scopes: {app.scopes.join(", ")}. +
  6. +
  7. Publish it as a private app (no review needed), then paste its client id and secret here.
  8. +
+
{ + e.preventDefault(); + void save(true); + }} + > + + {(props) => setClientId(e.target.value)} autoComplete="off" />} + + + {(props) => ( + setSecret(e.target.value)} + autoComplete="off" + /> + )} + + {error && ( +

+ {error} +

+ )} +
+ {sameApp && !secret.trim() ? ( + + ) : ( + + )} + {state && ( + + )} +
+
+
+ ); +} + /** An MCP server run with a key: credentials (entered here, never shown again), its test, its instructions, and turning it off. */ function PluginKeyPanel({ item, onChanged, onClose }: { item: Integration; onChanged: () => Promise; onClose: () => void }) { const d = item.detail as { plugin: PluginDef; enabled: boolean; has_credentials: boolean; custom_prompt: string }; diff --git a/dashboard/src/lib/api.ts b/dashboard/src/lib/api.ts index a0cf48c9..5e285379 100644 --- a/dashboard/src/lib/api.ts +++ b/dashboard/src/lib/api.ts @@ -1456,7 +1456,7 @@ export const api = { connectMcpServer: (id: string) => request<{ authorize_url: string }>(`/api/mcp-servers/${encodeURIComponent(id)}/connect`, { method: "POST" }), finishMcpSignIn: (body: { state: string; code?: string; error?: string; iss?: string }) => - request<{ server: McpServer; tools_error: string | null }>("/api/mcp-servers/oauth/callback", { + request<{ server: McpServer; tools_error: string | null; own_app?: boolean }>("/api/mcp-servers/oauth/callback", { method: "POST", body: JSON.stringify(body), }), @@ -1464,6 +1464,12 @@ export const api = { request<{ server: McpServer; revoked: boolean }>(`/api/mcp-servers/${encodeURIComponent(id)}/connection`, { method: "DELETE" }), removeMcpServer: (id: string) => request<{ status: string }>(`/api/mcp-servers/${encodeURIComponent(id)}`, { method: "DELETE" }), + /** Saves the team's own OAuth app for a catalog server (a blank secret keeps the saved one for the same client id). */ + saveOwnApp: (catalogId: string, client_id: string, client_secret: string) => + request<{ own_app: OwnAppState }>(`/api/mcp-servers/apps/${encodeURIComponent(catalogId)}`, { + method: "PUT", + body: JSON.stringify({ client_id, client_secret }), + }), setMcpClient: (id: string, client_id: string, client_secret: string) => request<{ server: McpServer }>(`/api/mcp-servers/${encodeURIComponent(id)}/client`, { method: "PUT", @@ -2998,6 +3004,35 @@ export interface PluginDef { remote_key?: boolean; /** Why no key works for it, in plain words; empty when one does. */ key_unavailable?: string; + /** Its package also takes a token from the team's own OAuth app with the vendor (Figma). */ + own_app?: OwnAppDef; +} + +/** Where a team creates its own OAuth app for a catalog server, and what to give it. */ +export interface OwnAppDef { + authorize: string; + token: string; + refresh: string; + /** The scopes to tick on the app, exactly. */ + scopes: string[]; + /** Where the app is created. */ + console: string; + /** The vendor's guide to creating one. */ + guide: string; +} + +/** A team's own app for a catalog server, as its card shows it (never the secret). */ +export interface OwnAppState { + /** The connection's id, for connect, disconnect and remove. */ + id: string; + client_id: string; + has_secret: boolean; + status: "connected" | "not_connected" | "needs_reconnect" | "failed"; + status_reason: string; + connected_by: string; + connected_at: string; + /** The redirect URL to add to the app. */ + redirect_uri: string; } export interface EnabledPlugin { diff --git a/dashboard/src/lib/openapi-fields.ts b/dashboard/src/lib/openapi-fields.ts index 90fb9dfd..452c731a 100644 --- a/dashboard/src/lib/openapi-fields.ts +++ b/dashboard/src/lib/openapi-fields.ts @@ -2,7 +2,7 @@ // docs/api/openapi.json. Do not edit; run `npm run openapi:fields` instead. /** The platform commit this was generated from. */ -export const OPENAPI_REF = "b25ce7b6fe2825b72a6bc191de6f288f2c22a9bc"; +export const OPENAPI_REF = "657a281693f9f11cb63332ecb8695946bd67277c"; /** The fields each public API schema has. */ export interface OpenApiFields { From b370fa7c461d08cf174427c4154b924d0a8e9190 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sun, 8 Nov 2026 09:44:25 -0500 Subject: [PATCH 2/2] API field list at platform main --- dashboard/src/lib/openapi-fields.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard/src/lib/openapi-fields.ts b/dashboard/src/lib/openapi-fields.ts index 452c731a..86ad22ee 100644 --- a/dashboard/src/lib/openapi-fields.ts +++ b/dashboard/src/lib/openapi-fields.ts @@ -2,7 +2,7 @@ // docs/api/openapi.json. Do not edit; run `npm run openapi:fields` instead. /** The platform commit this was generated from. */ -export const OPENAPI_REF = "657a281693f9f11cb63332ecb8695946bd67277c"; +export const OPENAPI_REF = "5f361c3ff7c755e6f015ad0869df4fde5fd985e5"; /** The fields each public API schema has. */ export interface OpenApiFields {