From 88edfa02d113ef31ce320b32e5246648c831cda3 Mon Sep 17 00:00:00 2001
From: LHaghfoss
Date: Wed, 25 Nov 2026 22:55:10 +0100
Subject: [PATCH] fix(desktop): connect Vercel and show why a connection failed
Vercel MCP accepts only reviewed clients or ones identified by a Client ID Metadata Document, so the engine's dynamically registered client could never finish signing in. The engine now uses RustCode's metadata document as its client_id for Vercel and for any server advertising client_id_metadata_document_supported.
Settings > Connections > Apps now shows a failed app's reason with Retry and Remove instead of a dead 'Not connected' chip, lists set-up apps first, tints connected and failed cards, and counts the connected apps.
---
apps/desktop/src/acp/mockMcp.ts | 22 +++-
apps/desktop/src/ui/Connectors.test.ts | 43 ++++++
apps/desktop/src/ui/Connectors.tsx | 144 ++++++++++++++++++---
apps/desktop/src/ui/connectorCatalog.ts | 7 +-
rustcode/engine/src/mcp.rs | 9 ++
rustcode/engine/src/mcp/client_metadata.rs | 99 ++++++++++++++
6 files changed, 298 insertions(+), 26 deletions(-)
create mode 100644 apps/desktop/src/ui/Connectors.test.ts
create mode 100644 rustcode/engine/src/mcp/client_metadata.rs
diff --git a/apps/desktop/src/acp/mockMcp.ts b/apps/desktop/src/acp/mockMcp.ts
index 9663b07b4..279846188 100644
--- a/apps/desktop/src/acp/mockMcp.ts
+++ b/apps/desktop/src/acp/mockMcp.ts
@@ -10,8 +10,8 @@ const signedOut = (server: JsonObject): JsonObject => ({
});
/**
- * The mock's remote MCP servers that sign in with OAuth: the seeded `sentry` row and any server
- * added through `_rustcode/capabilities/mcp/add`, which signs itself in a moment later as the
+ * The mock's remote MCP servers that sign in with OAuth: the seeded `sentry` row, a `vercel` row
+ * whose sign-in failed, and any server added through `_rustcode/capabilities/mcp/add`, which signs itself in a moment later as the
* engine's browser login would. Reconnecting one signs it in; logging out forgets it.
*/
export class MockAddedMcp {
@@ -24,6 +24,16 @@ export class MockAddedMcp {
scope: "user",
error: null,
}),
+ {
+ name: "vercel",
+ transport: "http",
+ target: "https://mcp.vercel.com",
+ enabled: true,
+ scope: "user",
+ connection: "failed",
+ tools: 0,
+ error: "MCP OAuth for 'vercel': token request failed (HTTP 401): invalid_client",
+ },
];
apply(method: string, params: JsonObject) {
@@ -61,7 +71,13 @@ export class MockAddedMcp {
if (!this.servers.some((server) => str(server.name) === name)) return false;
this.servers = this.servers.map((server) =>
str(server.name) === name
- ? { ...server, connection: "connected", tools: name === "sentry" ? 58 : 12, auth: "signed_in" }
+ ? {
+ ...server,
+ connection: "connected",
+ tools: name === "sentry" ? 58 : 12,
+ auth: "signed_in",
+ error: null,
+ }
: server,
);
return true;
diff --git a/apps/desktop/src/ui/Connectors.test.ts b/apps/desktop/src/ui/Connectors.test.ts
new file mode 100644
index 000000000..27f9bb583
--- /dev/null
+++ b/apps/desktop/src/ui/Connectors.test.ts
@@ -0,0 +1,43 @@
+import { describe, expect, test } from "bun:test";
+import type { McpServer } from "./Capabilities";
+import { cardState, firstLine } from "./Connectors";
+
+const server = (over: Partial): McpServer => ({
+ name: "vercel",
+ transport: "http",
+ target: "https://mcp.vercel.com",
+ enabled: true,
+ scope: "user",
+ connection: "connecting",
+ tools: [],
+ toolCount: 0,
+ envKeys: [],
+ headerKeys: [],
+ copyTarget: null,
+ ...over,
+});
+
+describe("connector card state", () => {
+ test("an app not set up is available", () => {
+ expect(cardState(undefined)).toBe("available");
+ });
+
+ test("a failed connection offers a retry instead of a dead chip", () => {
+ expect(cardState(server({ connection: "failed", error: "client registration failed" }))).toBe("failed");
+ });
+
+ test("a signed-out server asks for a sign-in even with an error", () => {
+ expect(cardState(server({ auth: "signed_out", error: "sign-in required" }))).toBe("signed-out");
+ });
+
+ test("connected and off win over everything else", () => {
+ expect(cardState(server({ connection: "connected", auth: "signed_in" }))).toBe("connected");
+ expect(cardState(server({ enabled: false, error: "x" }))).toBe("off");
+ });
+});
+
+test("a card error drops the engine's server prefix and keeps the first line", () => {
+ expect(firstLine("MCP OAuth for 'vercel': token request failed (HTTP 401)\nmore")).toBe(
+ "token request failed (HTTP 401)",
+ );
+});
diff --git a/apps/desktop/src/ui/Connectors.tsx b/apps/desktop/src/ui/Connectors.tsx
index 8774d5d60..09722661f 100644
--- a/apps/desktop/src/ui/Connectors.tsx
+++ b/apps/desktop/src/ui/Connectors.tsx
@@ -19,7 +19,8 @@ import { Search } from "./icons";
import { cx, noTextHelpers, Segments, Spinner } from "./primitives";
import { Action, Chip, fieldClass, SectionTitle } from "./settingsKit";
-type Busy = { id: string; step: "adding" | "signing-in" } | null;
+type Step = "adding" | "signing-in" | "removing";
+type Busy = { id: string; step: Step } | null;
/**
* Settings › Connections › Apps: a gallery of hosted MCP servers. Connect adds one to this
@@ -97,6 +98,18 @@ export function ConnectorGallery() {
}
};
+ const remove = async (connector: Connector, server: McpServer) => {
+ setBusy({ id: connector.id, step: "removing" });
+ try {
+ await request(Method.mcpRemove, { name: server.name }, 15_000);
+ toast(`${connector.name} was removed.`, "info");
+ } catch (e) {
+ toast(errorText(e), "error");
+ } finally {
+ setBusy(null);
+ }
+ };
+
const reconnect = async (connector: Connector, server: McpServer) => {
try {
await signIn(connector, server.name);
@@ -107,9 +120,14 @@ export function ConnectorGallery() {
}
};
- const shown = CONNECTORS.filter(
- (c) => (category === "all" || c.category === category) && matchesConnector(c, query),
+ const servers = data?.mcpServers ?? [];
+ const shown = sortConnected(
+ CONNECTORS.filter((c) => (category === "all" || c.category === category) && matchesConnector(c, query)),
+ servers,
);
+ const connectedCount = CONNECTORS.filter(
+ (c) => configuredAs(c, servers)?.connection === "connected",
+ ).length;
return (
Connect an app to give every thread its tools. Sign-ins open in your browser and stay on this
computer.
+ {connectedCount > 0 ? ` ${connectedCount} connected.` : ""}