Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): make MCP connections usable in dev (#365)

Ruic0f9749ea509
diff --git a/.changeset/local-oauth-callback-host.md b/.changeset/local-oauth-callback-host.md
new file mode 100644
index 000000000..eb52f7c83
--- /dev/null
+++ b/.changeset/local-oauth-callback-host.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Fix Vercel Connect local interactive connection authorization when the dev server uses an IPv4 or IPv6 loopback address. OAuth callbacks now retain the active port while using the `localhost` hostname accepted by Connect, and local `/connect` refreshes the dev runtime before the next prompt can use the new connection.
diff --git a/packages/eve-catalog/src/index.test.ts b/packages/eve-catalog/src/index.test.ts
index c3d4abab1..9b1bd43d8 100644
--- a/packages/eve-catalog/src/index.test.ts
+++ b/packages/eve-catalog/src/index.test.ts
@@ -44,4 +44,8 @@ describe("integration catalog", () => {
]);
expect(connectionProtocols(getIntegrationEntry("linear")!.connection!)).toEqual(["mcp"]);
});
+
+ it("uses Linear's streamable HTTP MCP endpoint", () => {
+ expect(getIntegrationEntry("linear")!.connection!.mcp!.url).toBe("https://mcp.linear.app/mcp");
+ });
});
diff --git a/packages/eve/src/cli/dev/tui/mcp-connection-status.test.ts b/packages/eve/src/cli/dev/tui/mcp-connection-status.test.ts
new file mode 100644
index 000000000..1c5348375
--- /dev/null
+++ b/packages/eve/src/cli/dev/tui/mcp-connection-status.test.ts
@@ -0,0 +1,65 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import { createMcpConnectionStatusTracker, probeMcpConnection } from "./mcp-connection-status.js";
+
+afterEach(() => {
+ vi.useRealTimers();
+ vi.unstubAllGlobals();
+});
+
+describe("probeMcpConnection", () => {
+ it("treats an authorization response as a reachable endpoint", async () => {
+ const fetch = vi.fn(async () => new Response(null, { status: 401 }));
+ vi.stubGlobal("fetch", fetch);
+
+ await expect(
+ probeMcpConnection({
+ url: "https://mcp.notion.com/mcp",
+ signal: new AbortController().signal,
+ }),
+ ).resolves.toBeUndefined();
+ });
+
+ it("reports the observed status for an unreachable endpoint", async () => {
+ vi.stubGlobal(
+ "fetch",
+ vi.fn(async () => new Response(null, { status: 404 })),
+ );
+
+ await expect(
+ probeMcpConnection({
+ url: "https://mcp.datadoghq.com/api/mcp",
+ signal: new AbortController().signal,
+ }),
+ ).resolves.toBe("https://mcp.datadoghq.com/api/mcp is not reachable (HTTP 404).");
+ });
+});
+
+describe("createMcpConnectionStatusTracker", () => {
+ it("probes at boot and refreshes the cached warning during the session", async () => {
+ vi.useFakeTimers();
+ const snapshots: Array<Readonly<Record<string, string>>> = [];
+ let datadogAvailable = false;
+ const tracker = createMcpConnectionStatusTracker({
+ intervalMs: 60_000,
+ onChange: (snapshot) => snapshots.push(snapshot),
+ probe: async ({ url }) =>
+ url === "https://mcp.datadoghq.com/api/mcp" && !datadogAvailable
+ ? `${url} is not reachable (HTTP 404).`
+ : undefined,
+ });
+
+ tracker.refresh();
+ await vi.advanceTimersByTimeAsync(0);
+ expect(tracker.current()).toEqual({
+ datadog: "https://mcp.datadoghq.com/api/mcp is not reachable (HTTP 404).",
+ });
+
+ datadogAvailable = true;
+ await vi.advanceTimersByTimeAsync(60_000);
+ expect(tracker.current()).toEqual({});
+ expect(snapshots).toHaveLength(2);
+
+ tracker.dispose();
+ });
+});
diff --git a/packages/eve/src/cli/dev/tui/mcp-connection-status.ts b/packages/eve/src/cli/dev/tui/mcp-connection-status.ts
new file mode 100644
index 000000000..bad411ca0
--- /dev/null
+++ b/packages/eve/src/cli/dev/tui/mcp-connection-status.ts
@@ -0,0 +1,108 @@
+import { CONNECTION_CATALOG } from "#setup/scaffold/index.js";
+
+const DEFAULT_PROBE_INTERVAL_MS = 60_000;
+
+export type McpConnectionProbe = (input: {
+ url: string;
+ signal: AbortSignal;
+}) => Promise<string | undefined>;
+
+export async function probeMcpConnection(input: {
+ url: string;
+ signal: AbortSignal;
+}): Promise<string | undefined> {
+ try {
+ const response = await fetch(input.url, {
+ method: "POST",
+ signal: input.signal,
+ headers: {
+ Accept: "application/json, text/event-stream",
+ "Content-Type": "application/json",
+ "MCP-Protocol-Version": "2025-03-26",
+ },
+ body: JSON.stringify({
+ jsonrpc: "2.0",
+ id: "eve-connection-probe",
+ method: "initialize",
+ params: {
+ protocolVersion: "2025-03-26",
+ capabilities: {},
+ clientInfo: { name: "eve", version: "connection-probe" },
+ },
+ }),
+ });
+ if (response.ok || response.status === 401 || response.status === 403) return undefined;
+ return `${input.url} is not reachable (HTTP ${response.status}).`;
+ } catch (error) {
+ if (input.signal.aborted) throw error;
+ const message = error instanceof Error ? error.message : "connection failed";
+ return `${input.url} is not reachable (${message}).`;
+ }
+}
+
+export interface McpConnectionStatusTracker {
+ current(): Readonly<Record<string, string>>;
+ refresh(): void;
+ dispose(): void;
+}
+
+export interface McpConnectionStatusTrackerOptions {
+ onChange: (disabledConnectionReasons: Readonly<Record<string, string>>) => void;
+ probe?: McpConnectionProbe;
+ intervalMs?: number;
+}
+
+export function createMcpConnectionStatusTracker(
+ options: McpConnectionStatusTrackerOptions,
+): McpConnectionStatusTracker {
+ const probe = options.probe ?? probeMcpConnection;
+ const intervalMs = options.intervalMs ?? DEFAULT_PROBE_INTERVAL_MS;
+ let disabledConnectionReasons: Readonly<Record<string, string>> = {};
+ let disposed = false;
+ let epoch = 0;
+ let controller: AbortController | undefined;
+ const interval = setInterval(() => refresh(), intervalMs);
+ interval.unref();
+
+ const refresh = (): void => {
+ if (disposed) return;
+ controller?.abort();
+ controller = new AbortController();
+ const currentController = controller;
+ const currentEpoch = ++epoch;
+ void Promise.all(
+ CONNECTION_CATALOG.flatMap((entry) => {
+ const url = entry.mcp?.url;
+ if (url === undefined) return [];
+ return [
+ probe({ url, signal: currentController.signal }).then(
+ (reason) => [entry.slug, reason] as const,
+ ),
+ ];
+ }),
+ )
+ .then((results) => {
+ if (disposed || currentEpoch !== epoch) return;
+ disabledConnectionReasons = Object.fromEntries(
+ results.flatMap(([slug, reason]) => (reason === undefined ? [] : [[slug, reason]])),
+ );
+ options.onChange(disabledConnectionReasons);
+ })
+ .catch(() => {
+ if (currentController.signal.aborted) return;
+ });
+ };
+
+ return {
+ current: () => disabledConnectionReasons,
+ refresh,
+ dispose: () => {
+ if (disposed) return;
+ disposed = true;
+ epoch += 1;
+ controller?.abort();
+ controller = undefined;
+ clearInterval(interval);
+ },
+ };
+}
diff --git a/packages/eve/src/cli/dev/tui/prompt-command-handler.ts b/packages/eve/src/cli/dev/tui/prompt-command-handler.ts
index d3c33d9c6..a0402a32d 100644
--- a/packages/eve/src/cli/dev/tui/prompt-command-handler.ts
+++ b/packages/eve/src/cli/dev/tui/prompt-command-handler.ts
@@ -118,6 +118,7 @@ export function createPromptCommandHandler(
command: command.name,
appRoot: target.workspaceRoot,
renderer: flow,
+ disabledConnectionReasons: context.disabledConnectionReasons,
};
if (context.initialModelStep !== undefined) {
commandInput.initialModelStep = context.initialModelStep;
diff --git a/packages/eve/src/cli/dev/tui/runner.test.ts b/packages/eve/src/cli/dev/tui/runner.test.ts
index c43598fb8..33024bce9 100644
--- a/packages/eve/src/cli/dev/tui/runner.test.ts
+++ b/packages/eve/src/cli/dev/tui/runner.test.ts
@@ -1822,6 +1822,58 @@ describe("EveTUIRunner Vercel status line", () => {
).toBe(true);
});
+ it("forces a runtime rebuild through the /connect command path", async () => {
+ const client = stubClient();
+ vi.spyOn(client, "info").mockResolvedValue(AGENT_INFO);
+ const requests: URL[] = [];
+ vi.stubGlobal(
+ "fetch",
+ vi.fn(async (input: Parameters<typeof fetch>[0]) => {
+ const url = new URL(
+ typeof input === "string" ? input : input instanceof URL ? input : input.url,
+ );
+ requests.push(url);
+ return Response.json({ revision: url.searchParams.get("force") === "1" ? "next" : "base" });
+ }),
+ );
+ const runConnectionsFlow = vi.fn(async () => ({
+ kind: "done" as const,
+ addedConnections: ["linear"],
+ }));
+ const prompts: Array<string | undefined> = ["/connect", undefined];
+ const renderer = fakeRenderer({
+ readPrompt: vi.fn(async () => prompts.shift()),
+ setupFlow: idleSetupFlow(),
+ });
+
+ const runner = new EveTUIRunner({
+ session: stubSession(),
+ client,
+ renderer,
+ serverUrl: "http://localhost:3000",
+ name: "Weather Agent",
+ appRoot: "/tmp/weather-agent",
+ promptCommandHandler: createPromptCommandHandler({
+ target: {
+ kind: "local",
+ serverUrl: "http://localhost:3000",
+ workspaceRoot: "/tmp/weather-agent",
+ },
+ flows: { runConnectionsFlow },
+ }),
+ });
+ await runner.run();
+
+ expect(runConnectionsFlow).toHaveBeenCalledTimes(1);
+ expect(
+ requests.some(
+ (url) =>
+ url.pathname === "/eve/v1/dev/runtime-artifacts/rebuild" &&
+ url.searchParams.get("force") === "1",
+ ),
+ ).toBe(true);
+ });
+
it("never pushes Vercel status for a remote --url session", async () => {
const setVercelStatus = vi.fn();
const renderer = fakeRenderer({ setVercelStatus });
diff --git a/packages/eve/src/cli/dev/tui/runner.ts b/packages/eve/src/cli/dev/tui/runner.ts
index e78ad4665..d905d7dff 100644
--- a/packages/eve/src/cli/dev/tui/runner.ts
+++ b/packages/eve/src/cli/dev/tui/runner.ts
@@ -85,6 +85,11 @@ import {
type VercelStatusTracker,
type VercelStatusTrackerOptions,
} from "./vercel-status.js";
+import {
+ createMcpConnectionStatusTracker,
+ type McpConnectionProbe,
+ type McpConnectionStatusTracker,
+} from "./mcp-connection-status.js";
import type { detectProjectIdentity } from "#setup/project-resolution.js";
import { getVercelAuthStatus, type VercelAuthStatus } from "#setup/vercel-project.js";
@@ -303,6 +308,7 @@ export interface PromptCommandHandlerContext {
*/
readonly keepSetupFlowOpen?: true;
readonly remoteConnection?: RemoteConnectionController;
+ readonly disabledConnectionReasons?: Readonly<Record<string, string>>;
}
/** What one handled slash command leaves behind for the runner to apply. */
@@ -322,6 +328,8 @@ export interface PromptCommandHandler {
export type EveTUIRunnerOptions = TuiDisplayOptions & {
session: ClientSession;
+ /** Production TUI probe injected by the launcher; omitted in hermetic runners. */
+ probeMcpConnection?: McpConnectionProbe;
/**
* Optional client used to attach to child sessions for live subagent
* stream observation. When omitted, the TUI still shows the subagent
@@ -429,6 +437,7 @@ export class EveTUIRunner {
* session has no workspace to be linked.
*/
readonly #vercelStatus?: VercelStatusTracker;
+ readonly #mcpConnectionStatus?: McpConnectionStatusTracker;
/**
* The header's message-of-the-day, picked once so dev HMR header
* refreshes don't re-roll it mid-session. Local sessions only — every
@@ -504,6 +513,12 @@ export class EveTUIRunner {
trackerOptions.detectIdentity = options.detectProjectIdentity;
}
this.#vercelStatus = createVercelStatusTracker(trackerOptions);
+ if (options.probeMcpConnection !== undefined) {
+ this.#mcpConnectionStatus = createMcpConnectionStatusTracker({
+ onChange: () => {},
+ probe: options.probeMcpConnection,
+ });
+ }
}
if (options.promptCommandHandler !== undefined) {
this.#promptCommandHandler = options.promptCommandHandler;
@@ -607,6 +622,7 @@ export class EveTUIRunner {
// Drops any in-flight link probe so a late resolution cannot paint
// into a torn-down terminal.
this.#vercelStatus?.dispose();
+ this.#mcpConnectionStatus?.dispose();
this.#remoteConnection?.dispose();
}
}
@@ -633,6 +649,7 @@ export class EveTUIRunner {
// Fire-and-forget: the link identity is network-bound to resolve, and the
// first prompt must not wait on it. The segment appears when it lands.
this.#vercelStatus?.refreshIdentity();
+ this.#mcpConnectionStatus?.refresh();
const initialCommand =
this.#initialInput === undefined ? undefined : parsePromptCommand(this.#initialInput);
@@ -1128,12 +1145,17 @@ export class EveTUIRunner {
if (handler === undefined)
return { message: `/${command.name} is not available in this session.` };
- const context: PromptCommandHandlerContext = {
+ const baseContext: PromptCommandHandlerContext = {
renderer: this.#renderer,
title: input.title,
initialModelStep: input.initialModelStep,
remoteConnection: this.#remoteConnection,
};
+ const disabledConnectionReasons = this.#mcpConnectionStatus?.current();
+ const context: PromptCommandHandlerContext =
+ disabledConnectionReasons !== undefined && Object.keys(disabledConnectionReasons).length > 0
+ ? { ...baseContext, disabledConnectionReasons }
+ : baseContext;
if (input.keepSetupFlowOpen === true) {
return await handler.handle(command, { ...context, keepSetupFlowOpen: true });
}
diff --git a/packages/eve/src/cli/dev/tui/setup-commands.ts b/packages/eve/src/cli/dev/tui/setup-commands.ts
index 3a2dc2e78..e55454306 100644
--- a/packages/eve/src/cli/dev/tui/setup-commands.ts
+++ b/packages/eve/src/cli/dev/tui/setup-commands.ts
@@ -49,6 +49,7 @@ export interface TuiSetupCommandInput {
renderer: TuiSetupCommandRenderer;
/** Initial model-flow step authorized by the runner's boot evidence. */
initialModelStep?: "provider";
+ disabledConnectionReasons?: Readonly<Record<string, string>>;
/** Test seam; defaults to the real TUI-native prompter over `renderer`. */
createPrompter?: (renderer: TuiPrompterRenderer) => Prompter;
/** Test seam; defaults to the real setup flows. */
@@ -240,7 +241,12 @@ async function executeSetupCommand(
}
}
case "connect": {
- const result = await flows.runConnectionsFlow({ appRoot, prompter, signal });
+ const result = await flows.runConnectionsFlow({
+ appRoot,
+ prompter,
+ signal,
+ disabledConnectionReasons: input.disabledConnectionReasons,
+ });
switch (result.kind) {
case "cancelled":
return {
diff --git a/packages/eve/src/cli/dev/tui/setup-panel.test.ts b/packages/eve/src/cli/dev/tui/setup-panel.test.ts
index 58e859540..c96fce233 100644
--- a/packages/eve/src/cli/dev/tui/setup-panel.test.ts
+++ b/packages/eve/src/cli/dev/tui/setup-panel.test.ts
@@ -346,7 +346,7 @@ describe("renderSelectQuestion", () => {
expect(clipped?.endsWith("\x1b[0m")).toBe(true);
});
- it("renders a warning-toned disabled row with a dim label and yellow reason", () => {
+ it("renders a warning-toned disabled row with a dim label and yellow alert annotation", () => {
const colored = createTheme({ color: true, unicode: true });
const options = [
{ value: "web", label: "Web Chat" },
@@ -369,9 +369,9 @@ describe("renderSelectQuestion", () => {
80,
).join("\n");
- // Dim label (SGR 2), un-struck, followed by the reason in yellow (SGR 33).
+ // Dim label (SGR 2), un-struck, followed by the alert annotation in yellow (SGR 33).
expect(text).toContain(
- "\x1b[2mSlack\x1b[22m\x1b[33m (Requires Vercel account, see /model)\x1b[39m",
+ "\x1b[2mSlack\x1b[22m\x1b[33m ⚠ Requires Vercel account, see /model\x1b[39m",
);
});
diff --git a/packages/eve/src/cli/dev/tui/setup-panel.ts b/packages/eve/src/cli/dev/tui/setup-panel.ts
index 102cb8200..f32ea0cd0 100644
--- a/packages/eve/src/cli/dev/tui/setup-panel.ts
+++ b/packages/eve/src/cli/dev/tui/setup-panel.ts
@@ -330,6 +330,7 @@ function optionRow(input: {
success: theme.glyph.success,
placeholder: theme.glyph.option,
dot: theme.glyph.dot,
+ warning: theme.glyph.warning,
},
label: option.label,
hint: option.hint,
diff --git a/packages/eve/src/cli/dev/tui/tui.ts b/packages/eve/src/cli/dev/tui/tui.ts
index d6337ca52..2694bd9ab 100644
--- a/packages/eve/src/cli/dev/tui/tui.ts
+++ b/packages/eve/src/cli/dev/tui/tui.ts
@@ -16,6 +16,7 @@ import { toErrorMessage } from "#shared/errors.js";
import { createPromptCommandHandler } from "./prompt-command-handler.js";
import { promptCommandsFor } from "./prompt-commands.js";
import { formatRemoteAuthChallengeMessage } from "./remote-auth-result.js";
+import { probeMcpConnection } from "./mcp-connection-status.js";
import { EveTUIRunner, type EveTUIRunnerOptions } from "./runner.js";
import { remoteHost, type DevelopmentTuiTarget, type RemoteDevelopmentTarget } from "./target.js";
import type { TuiDisplayOptions } from "./types.js";
@@ -106,6 +107,7 @@ export async function runDevelopmentTui(input: RunDevelopmentTuiInput): Promise<
};
if (prepared.kind === "local") {
options.appRoot = prepared.target.workspaceRoot;
+ options.probeMcpConnection = probeMcpConnection;
} else {
options.remote = prepared.remote;
}
diff --git a/packages/eve/src/context/providers/connection-key.ts b/packages/eve/src/context/providers/connection-key.ts
new file mode 100644
index 000000000..1a429399c
--- /dev/null
+++ b/packages/eve/src/context/providers/connection-key.ts
@@ -0,0 +1,10 @@
+import { ContextKey } from "#context/key.js";
+import type { ConnectionRegistry } from "#runtime/connections/types.js";
+
+/**
+ * Context key for the per-session connection registry.
+ *
+ * Defined separately from the provider so framework tools can read the key
+ * without importing connection client setup into the framework-tools bundle.
+ */
+export const ConnectionRegistryKey = new ContextKey<ConnectionRegistry>("eve.connectionRegistry");
diff --git a/packages/eve/src/context/providers/connection.ts b/packages/eve/src/context/providers/connection.ts
index 271f32627..9d1883a09 100644
--- a/packages/eve/src/context/providers/connection.ts
+++ b/packages/eve/src/context/providers/connection.ts
@@ -1,18 +1,11 @@
-import { ContextKey } from "#context/key.js";
+import { ConnectionRegistryKey } from "#context/providers/connection-key.js";
import { ConnectionRegistryImpl } from "#runtime/connections/registry.js";
import type { ConnectionRegistry } from "#runtime/connections/types.js";
import { BundleKey } from "#runtime/sessions/runtime-context-keys.js";
import { getActiveRuntimeNode } from "#context/node.js";
import type { FrameworkContextProvider } from "#context/provider.js";
-/**
- * Context key for the per-session connection registry.
- *
- * Created as a derived key (no codec) because the registry holds live
- * client instances that cannot be serialized across step boundaries.
- * The `connectionProvider` reconstructs it each step.
- */
-export const ConnectionRegistryKey = new ContextKey<ConnectionRegistry>("eve.connectionRegistry");
+export { ConnectionRegistryKey } from "#context/providers/connection-key.js";
export const connectionProvider: FrameworkContextProvider<ConnectionRegistry> = {
key: ConnectionRegistryKey,
diff --git a/packages/eve/src/execution/tool-auth.integration.test.ts b/packages/eve/src/execution/tool-auth.integration.test.ts
index 2c5d8a3c6..38eac7777 100644
--- a/packages/eve/src/execution/tool-auth.integration.test.ts
+++ b/packages/eve/src/execution/tool-auth.integration.test.ts
@@ -232,6 +232,47 @@ describe("tool-hosted authorization", () => {
});
});
+ it("uses a localhost callback URL for a Vercel Connect inline provider", async () => {
+ let receivedCallbackUrl: string | undefined;
+ const inlineAuth: AuthorizationDefinition = {
+ principalType: "user",
+ vercelConnect: { connector: "mcp.notion.com/notion" },
+ async getToken(): Promise<TokenResult> {
+ throw requiredError();
+ },
+ async startAuthorization({ callbackUrl }) {
+ receivedCallbackUrl = callbackUrl;
+ return { challenge: { url: "https://idp.example/auth" } };
+ },
+ async completeAuthorization(): Promise<TokenResult> {
+ return { token: "after-signin" };
+ },
+ };
+ const tool = authoredTool({
+ name: "search_notion",
+ async execute(_input, ctx) {
+ return await ctx.getToken(inlineAuth);
+ },
+ });
+ const runtime = createTestRuntime({ tools: [tool] });
+
+ const result = await runtime.runAsSession(
+ { sessionId: "session_connect_callback" },
+ async () => {
+ seedUserPrincipal();
+ loadContext().set(CallbackBaseUrlKey, "http://[::1]:2000");
+ return runtime.executeTool(tool, {});
+ },
+ );
+
+ expect(isAuthorizationSignal(result)).toBe(true);
+ if (!isAuthorizationSignal(result)) throw new Error("expected signal");
+ expect(receivedCallbackUrl).toBe(
+ "http://localhost:2000/eve/v1/connections/search_notion__mcp.notion.com_notion/callback/session_auth%3Aauth",
+ );
+ expect(result.challenges[0]?.hookUrl).toBe(receivedCallbackUrl);
+ });
+
it("parks the turn with a challenge when getToken throws Required", async () => {
const auth: AuthorizationDefinition = {
principalType: "user",
diff --git a/packages/eve/src/internal/nitro/host/start-development-server.test.ts b/packages/eve/src/internal/nitro/host/start-development-server.test.ts
index a6c48ff50..dfa329e8b 100644
--- a/packages/eve/src/internal/nitro/host/start-development-server.test.ts
+++ b/packages/eve/src/internal/nitro/host/start-development-server.test.ts
@@ -4,6 +4,7 @@ import type { Socket } from "node:net";
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import type { Nitro } from "nitro/types";
import type {
DevelopmentServerHandle,
@@ -18,6 +19,7 @@ const mocks = vi.hoisted(() => {
const authoredSourceWatcher = {
close: vi.fn(async () => undefined),
flush: vi.fn(async () => undefined),
+ rebuild: vi.fn(async () => undefined),
};
const listenerServer = {
close: vi.fn(async () => undefined),
@@ -30,6 +32,7 @@ const mocks = vi.hoisted(() => {
upgrade: vi.fn(async (_req: unknown, _socket: unknown, _head: unknown) => undefined),
};
const files = new Map<string, string>();
+ const devHandlers: Nitro["options"]["devHandlers"] = [];
const nitro = {
close: vi.fn(async () => undefined),
options: {
@@ -40,6 +43,7 @@ const mocks = vi.hoisted(() => {
},
experimental: {},
features: {},
+ devHandlers,
},
};
@@ -321,6 +325,8 @@ describe("createDevelopmentServer", () => {
mocks.fsControl.stateReadError = undefined;
mocks.fsControl.stateWriteError = undefined;
mocks.authoredSourceWatcher.close.mockResolvedValue(undefined);
+ mocks.authoredSourceWatcher.flush.mockResolvedValue(undefined);
+ mocks.authoredSourceWatcher.rebuild.mockResolvedValue(undefined);
mocks.devServer.close.mockResolvedValue(undefined);
mocks.nitro.close.mockResolvedValue(undefined);
mocks.stopDevelopmentSandboxResources.mockResolvedValue(undefined);
@@ -333,6 +339,7 @@ describe("createDevelopmentServer", () => {
async (_req: unknown, _socket: unknown, _head: unknown) => undefined,
);
Object.assign(mocks.nitro.options, {
+ devHandlers: [],
experimental: {},
features: {},
});
@@ -466,6 +473,53 @@ describe("createDevelopmentServer", () => {
expect(mocks.files.has(developmentServerStatePath)).toBe(false);
});
+ async function callDevHandler(
+ handler: Nitro["options"]["devHandlers"][number]["handler"],
+ url: string,
+ ): Promise<unknown> {
+ if (typeof handler !== "function") throw new Error("Expected a callable dev handler.");
+ return await handler({
+ node: { req: { url } },
+ } as Parameters<typeof handler>[0]);
+ }
+
+ it("registers a host-owned runtime rebuild handler that forces the live watcher", async () => {
+ const startDevelopmentServer = await loadStartDevelopmentServer();
+ const server = await startDevelopmentServer("/tmp/eve-test");
+ const rebuildHandler = mocks.nitro.options.devHandlers.find(
+ (handler) => handler.route === "/eve/v1/dev/runtime-artifacts/rebuild",
+ );
+ if (rebuildHandler === undefined) throw new Error("Missing runtime rebuild handler.");
+
+ const response = await callDevHandler(
+ rebuildHandler.handler,
+ "/eve/v1/dev/runtime-artifacts/rebuild?force=1",
+ );
+
+ expect(mocks.authoredSourceWatcher.rebuild).toHaveBeenCalledOnce();
+ expect(mocks.authoredSourceWatcher.flush).not.toHaveBeenCalled();
+ if (!(response instanceof Response)) throw new Error("Expected a Response.");
+ await expect(response.json()).resolves.toEqual({ revision: "/tmp/eve-test" });
+
+ await server.close();
+ });
+
+ it("registers a host-owned runtime rebuild handler that flushes queued changes", async () => {
+ const startDevelopmentServer = await loadStartDevelopmentServer();
+ const server = await startDevelopmentServer("/tmp/eve-test");
+ const rebuildHandler = mocks.nitro.options.devHandlers.find(
+ (handler) => handler.route === "/eve/v1/dev/runtime-artifacts/rebuild",
+ );
+ if (rebuildHandler === undefined) throw new Error("Missing runtime rebuild handler.");
+
+ await callDevHandler(rebuildHandler.handler, "/eve/v1/dev/runtime-artifacts/rebuild");
+
+ expect(mocks.authoredSourceWatcher.flush).toHaveBeenCalledOnce();
+ expect(mocks.authoredSourceWatcher.rebuild).not.toHaveBeenCalled();
+
+ await server.close();
+ });
+
it("attempts every cleanup step when the authored-source watcher fails to close", async () => {
const startDevelopmentServer = await loadStartDevelopmentServer();
const server = await startDevelopmentServer("/tmp/eve-test");
diff --git a/packages/eve/src/internal/nitro/host/start-development-server.ts b/packages/eve/src/internal/nitro/host/start-development-server.ts
index 860ab5fd3..6442bb492 100644
--- a/packages/eve/src/internal/nitro/host/start-development-server.ts
+++ b/packages/eve/src/internal/nitro/host/start-development-server.ts
@@ -10,11 +10,13 @@ import { createApplicationNitro } from "#internal/nitro/host/create-application-
import { createNitroArtifactsConfig } from "#internal/nitro/host/artifacts-config.js";
import type { AuthoredSourceWatcherHandle } from "#internal/nitro/host/dev-authored-source-watcher.js";
import { prepareApplicationHost } from "#internal/nitro/host/prepare-application-host.js";
+import { EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH } from "#protocol/routes.js";
import { resolveDiscoveryProject } from "#discover/project.js";
import { DevelopmentServerState } from "#internal/nitro/host/dev-server-state.js";
import { toErrorMessage } from "#shared/errors.js";
import { isEveServerHealthy } from "#shared/eve-server-health.js";
import { isLoopbackServerUrl } from "#shared/network-address.js";
+import { handleDevRuntimeArtifactsRequest } from "#internal/nitro/routes/dev-runtime-artifacts.js";
import { resolveNitroCompiledArtifactsSource } from "#internal/nitro/routes/runtime-artifacts.js";
import {
pruneLocalSandboxTemplatesInBackground,
@@ -276,6 +278,26 @@ function guardDevelopmentServerWebSocketUpgrades(
devServer.upgrade = guardedUpgrade;
}
+function addDevelopmentRuntimeArtifactsRebuildHandler(input: {
+ readonly appRoot: string;
+ readonly nitro: Nitro;
+ readonly watcher: AuthoredSourceWatcherHandle;
+}): void {
+ input.nitro.options.devHandlers.push({
+ route: EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH,
+ handler: async (event) => {
+ const requestUrl = event.node?.req.url ?? "";
+ const url = new URL(requestUrl, "http://localhost");
+ if (url.searchParams.get("force") === "1") {
+ await input.watcher.rebuild();
+ } else {
+ await input.watcher.flush();
+ }
+ return handleDevRuntimeArtifactsRequest({ appRoot: input.appRoot });
+ },
+ });
+}
+
async function closeDevelopmentServerResources(input: {
readonly authoredSourceWatcher: AuthoredSourceWatcherHandle | undefined;
readonly devServer: NitroDevelopmentServer | undefined;
@@ -502,6 +524,11 @@ async function startNitroDevelopmentServer(
},
options.onBootProgress,
);
+ addDevelopmentRuntimeArtifactsRebuildHandler({
+ appRoot: project.appRoot,
+ nitro: activeNitro,
+ watcher: authoredSourceWatcher,
+ });
await state.write(serverUrl);
const restoreWorkflowLocalQueueEnvironmentOnClose = restoreWorkflowLocalQueueEnvironment;
if (restoreWorkflowLocalQueueEnvironmentOnClose === undefined) {
diff --git a/packages/eve/src/runtime/connections/scoped-authorization.test.ts b/packages/eve/src/runtime/connections/scoped-authorization.test.ts
index 14f55976c..b37654fbd 100644
--- a/packages/eve/src/runtime/connections/scoped-authorization.test.ts
+++ b/packages/eve/src/runtime/connections/scoped-authorization.test.ts
@@ -1,9 +1,14 @@
import { describe, expect, it } from "vitest";
-import { stampChallengeDisplayName } from "#runtime/connections/scoped-authorization.js";
+import {
+ resolveAuthorizationCallbackUrl,
+ stampChallengeDisplayName,
+} from "#runtime/connections/scoped-authorization.js";
import type { AuthorizationDefinition, TokenResult } from "#runtime/connections/types.js";
-function interactiveAuth(displayName?: string): AuthorizationDefinition {
+function interactiveAuth(
+ input: { displayName?: string; connector?: string } = {},
+): AuthorizationDefinition {
const auth: AuthorizationDefinition = {
principalType: "user",
async getToken(): Promise<TokenResult> {
@@ -16,15 +21,27 @@ function interactiveAuth(displayName?: string): AuthorizationDefinition {
return { token: "fresh" };
},
};
- if (displayName === undefined) return auth;
- return { ...auth, displayName };
+ if (input.displayName === undefined && input.connector === undefined) return auth;
+ const overrides: {
+ displayName?: AuthorizationDefinition["displayName"];
+ vercelConnect?: NonNullable<AuthorizationDefinition["vercelConnect"]>;
+ } = {};
+ if (input.connector !== undefined) {
+ overrides.vercelConnect = { connector: input.connector };
+ }
+ if (input.displayName !== undefined) {
+ overrides.displayName = input.displayName;
+ }
+ return { ...auth, ...overrides };
}
describe("stampChallengeDisplayName", () => {
it("prefers the definition-level displayName over the strategy's", () => {
const challenge = { displayName: "Strategy Default", url: "https://idp.example/auth" };
- expect(stampChallengeDisplayName(challenge, interactiveAuth("Salesforce"))).toEqual({
+ expect(
+ stampChallengeDisplayName(challenge, interactiveAuth({ displayName: "Salesforce" })),
+ ).toEqual({
displayName: "Salesforce",
url: "https://idp.example/auth",
});
@@ -42,3 +59,42 @@ describe("stampChallengeDisplayName", () => {
expect(stampChallengeDisplayName(challenge, interactiveAuth())).toBe(challenge);
});
});
+
+describe("resolveAuthorizationCallbackUrl", () => {
+ it.each([
+ [
+ "http://127.0.0.1:2000/eve/v1/connections/notion/callback/wrun_123%3Aauth",
+ "http://localhost:2000/eve/v1/connections/notion/callback/wrun_123%3Aauth",
+ ],
+ [
+ "http://[::1]:2000/eve/v1/connections/notion/callback/wrun_123%3Aauth",
+ "http://localhost:2000/eve/v1/connections/notion/callback/wrun_123%3Aauth",
+ ],
+ ])("uses localhost for a Vercel Connect callback at %s", (callbackUrl, expectedUrl) => {
+ expect(
+ resolveAuthorizationCallbackUrl({
+ authorization: interactiveAuth({ connector: "mcp.notion.com/notion" }),
+ callbackUrl,
+ }),
+ ).toBe(expectedUrl);
+ });
+
+ it("preserves a custom authorization callback URL", () => {
+ const callbackUrl = "http://127.0.0.1:2000/callback";
+
+ expect(resolveAuthorizationCallbackUrl({ authorization: interactiveAuth(), callbackUrl })).toBe(
+ callbackUrl,
+ );
+ });
+
+ it("preserves an HTTPS Vercel Connect callback URL", () => {
+ const callbackUrl = "https://agent.example.com/callback";
+
+ expect(
+ resolveAuthorizationCallbackUrl({
+ authorization: interactiveAuth({ connector: "mcp.notion.com/notion" }),
+ callbackUrl,
+ }),
+ ).toBe(callbackUrl);
+ });
+});
diff --git a/packages/eve/src/runtime/connections/scoped-authorization.ts b/packages/eve/src/runtime/connections/scoped-authorization.ts
index 83b5cf651..abbd1a94b 100644
--- a/packages/eve/src/runtime/connections/scoped-authorization.ts
+++ b/packages/eve/src/runtime/connections/scoped-authorization.ts
@@ -33,6 +33,8 @@ import {
type TokenResult,
} from "#runtime/connections/types.js";
+const LOCAL_HTTP_VERCEL_CONNECT_HOSTNAMES: ReadonlySet<string> = new Set(["127.0.0.1", "[::1]"]);
+
/**
* Everything the scoped authorization helpers need to drive one
* authorization strategy: the cache/callback {@link scope}, the
@@ -170,21 +172,48 @@ export async function startScopedAuthorization(
const interactive = authorization as InteractiveAuthorizationDefinition<JsonValue>;
const principal = resolveConnectionPrincipal(scope, interactive);
+ const callbackUrl = resolveAuthorizationCallbackUrl({ authorization, callbackUrl: hookUrl });
const { challenge, resume } = await interactive.startAuthorization({
- callbackUrl: hookUrl,
+ callbackUrl,
connection,
principal,
});
return requestAuthorization([
{
challenge: stampChallengeDisplayName(challenge, authorization),
- hookUrl,
+ hookUrl: callbackUrl,
name: scope,
resume,
},
]);
}
+/**
+ * Vercel Connect accepts local HTTP callback URLs only when their hostname is
+ * literally `localhost`. Other authorization providers keep the framework's
+ * original callback URL so their registered redirect URI remains unchanged.
+ */
+export function resolveAuthorizationCallbackUrl(input: {
+ readonly authorization: Readonly<AuthorizationDefinition>;
+ readonly callbackUrl: string;
+}): string {
+ if (input.authorization.vercelConnect === undefined) return input.callbackUrl;
+
+ let url: URL;
+ try {
+ url = new URL(input.callbackUrl);
+ } catch {
+ return input.callbackUrl;
+ }
+
+ if (url.protocol !== "http:" || !LOCAL_HTTP_VERCEL_CONNECT_HOSTNAMES.has(url.hostname)) {
+ return input.callbackUrl;
+ }
+
+ url.hostname = "localhost";
+ return url.toString();
+}
+
/**
* Resolves the user-facing `displayName` onto a challenge before it is
* surfaced on `authorization.required`.
diff --git a/packages/eve/src/runtime/connections/types.ts b/packages/eve/src/runtime/connections/types.ts
index 453589fd9..fd941f9f4 100644
--- a/packages/eve/src/runtime/connections/types.ts
+++ b/packages/eve/src/runtime/connections/types.ts
@@ -227,10 +227,10 @@ interface AuthorizationDefinitionBase {
* that surfaces connector identifiers in build output, or the Vercel
* dashboard rendering deep links to a connector's settings page.
*
- * The runtime token-fetch path ignores this field; it is purely
- * provider attribution. Authors writing their own `getToken`
- * callbacks (raw bearer tokens, custom callbacks) should leave it
- * unset.
+ * The runtime uses this marker for Connect-specific authorization behavior,
+ * including its local callback URL contract. Authors writing their own
+ * `getToken` callbacks (raw bearer tokens, custom callbacks) should leave
+ * it unset.
*
* `connector` carries whatever value the author passed to
* `connect()`: a UID like `"oauth/mcp-linear-app"` or opaque
diff --git a/packages/eve/src/runtime/connections/validate-authorization.ts b/packages/eve/src/runtime/connections/validate-authorization.ts
index 25c61838e..2ba525088 100644
--- a/packages/eve/src/runtime/connections/validate-authorization.ts
+++ b/packages/eve/src/runtime/connections/validate-authorization.ts
@@ -118,12 +118,11 @@ export function normalizeAuthorizationSpec(
* attached by `@vercel/connect/eve`'s `connect()` helper. Returns the
* parsed marker when present and well-formed, otherwise `undefined`.
*
- * The marker is opaque to the runtime — it exists so downstream tooling
- * (eg. the eve compiler / Vercel dashboard) can attribute the auth
- * back to a Vercel Connect connector without inspecting `getToken`'s
- * closure state. Validation is lenient (a malformed marker is dropped,
- * not thrown) so a misbehaving auth provider can't fail an otherwise-
- * valid connection.
+ * The runtime uses the marker for Connect-specific authorization behavior,
+ * while downstream tooling can attribute the auth back to a Vercel Connect
+ * connector without inspecting `getToken`'s closure state. Validation is
+ * lenient (a malformed marker is dropped, not thrown) so a misbehaving auth
+ * provider can't fail an otherwise-valid connection.
*/
function extractVercelConnectMarker(value: unknown): { readonly connector: string } | undefined {
if (value === null || typeof value !== "object") {
diff --git a/packages/eve/src/runtime/framework-tools/connection-search-dynamic.ts b/packages/eve/src/runtime/framework-tools/connection-search-dynamic.ts
index de80884a0..3b97d22e5 100644
--- a/packages/eve/src/runtime/framework-tools/connection-search-dynamic.ts
+++ b/packages/eve/src/runtime/framework-tools/connection-search-dynamic.ts
@@ -17,7 +17,10 @@ import type { JsonObject } from "#shared/json.js";
import { writeCachedToken } from "#runtime/connections/authorization-tokens.js";
import { principalKey, resolveConnectionPrincipal } from "#runtime/connections/principal.js";
import { resolveConnectionAuthorization } from "#runtime/connections/resolve-authorization.js";
-import { stampChallengeDisplayName } from "#runtime/connections/scoped-authorization.js";
+import {
+ resolveAuthorizationCallbackUrl,
+ stampChallengeDisplayName,
+} from "#runtime/connections/scoped-authorization.js";
import {
type ConnectionRegistry,
type ConnectionToolMetadata,
@@ -29,7 +32,7 @@ import { createLogger } from "#internal/logging.js";
import type { DynamicToolEvents, DynamicToolEntry } from "#shared/dynamic-tool-definition.js";
import type { ModelMessage } from "ai";
-import { ConnectionRegistryKey } from "#context/providers/connection.js";
+import { ConnectionRegistryKey } from "#context/providers/connection-key.js";
const logger = createLogger("framework.connection-search-dynamic");
@@ -210,16 +213,20 @@ async function executeConnectionSearch(
const hookUrl = getHookUrl(conn.connectionName);
if (hookUrl) {
const principal = resolveConnectionPrincipal(conn.connectionName, auth);
+ const callbackUrl = resolveAuthorizationCallbackUrl({
+ authorization: auth,
+ callbackUrl: hookUrl,
+ });
try {
const { challenge, resume } = await auth.startAuthorization({
- callbackUrl: hookUrl,
+ callbackUrl,
connection: { url: conn.url ?? "" },
principal,
});
authChallenges.push({
name: conn.connectionName,
challenge: stampChallengeDisplayName(challenge, auth),
- hookUrl,
+ hookUrl: callbackUrl,
resume,
});
} catch (startErr) {
@@ -474,8 +481,12 @@ export function createConnectionSearchEvents(): DynamicToolEvents {
if (!hookUrl) throw err;
const principal = resolveConnectionPrincipal(connectionName, interactiveAuth);
- const { challenge, resume } = await interactiveAuth.startAuthorization({
+ const callbackUrl = resolveAuthorizationCallbackUrl({
+ authorization: interactiveAuth,
callbackUrl: hookUrl,
+ });
+ const { challenge, resume } = await interactiveAuth.startAuthorization({
+ callbackUrl,
connection: { url: conn?.url ?? "" },
principal,
});
@@ -484,7 +495,7 @@ export function createConnectionSearchEvents(): DynamicToolEvents {
{
name: connectionName,
challenge: stampChallengeDisplayName(challenge, interactiveAuth),
- hookUrl,
+ hookUrl: callbackUrl,
resume,
},
]);
diff --git a/packages/eve/src/runtime/framework-tools/index.ts b/packages/eve/src/runtime/framework-tools/index.ts
index d67569a3e..f5f7ec953 100644
--- a/packages/eve/src/runtime/framework-tools/index.ts
+++ b/packages/eve/src/runtime/framework-tools/index.ts
@@ -9,7 +9,7 @@ import { WEB_FETCH_TOOL_DEFINITION } from "#runtime/framework-tools/web-fetch.js
import { WEB_SEARCH_TOOL_DEFINITION } from "#runtime/framework-tools/web-search.js";
import { WRITE_FILE_TOOL_DEFINITION } from "#runtime/framework-tools/write-file.js";
-export { ConnectionRegistryKey } from "#context/providers/connection.js";
+export { ConnectionRegistryKey } from "#context/providers/connection-key.js";
export type { ReadFileStamp, ReadFileState } from "#runtime/framework-tools/file-state.js";
export { ReadFileStateKey } from "#runtime/framework-tools/file-state.js";
export type { TodoItem, TodoState } from "#runtime/framework-tools/todo.js";
diff --git a/packages/eve/src/runtime/framework-tools/skill.test.ts b/packages/eve/src/runtime/framework-tools/skill.test.ts
index 7f461773b..96d23a3e4 100644
--- a/packages/eve/src/runtime/framework-tools/skill.test.ts
+++ b/packages/eve/src/runtime/framework-tools/skill.test.ts
@@ -2,7 +2,9 @@ import { describe, expect, it } from "vitest";
import { ContextContainer, contextStorage } from "#context/container.js";
import { DynamicSkillManifestKey, SandboxKey } from "#context/keys.js";
+import { ConnectionRegistryKey } from "#context/providers/connection-key.js";
import { mockSandbox } from "#internal/testing/mocks/mock-sandbox.js";
+import type { ConnectionRegistry } from "#runtime/connections/types.js";
import { SKILL_TOOL_DEFINITION } from "#runtime/framework-tools/skill.js";
describe("SKILL_TOOL_DEFINITION", () => {
@@ -14,6 +16,8 @@ describe("SKILL_TOOL_DEFINITION", () => {
"Loading adds the skill instructions to the current turn.",
);
expect(SKILL_TOOL_DEFINITION.description).toContain("Available skills block");
+ expect(SKILL_TOOL_DEFINITION.description).toContain("not for MCP connections");
+ expect(SKILL_TOOL_DEFINITION.description).toContain("connection_search");
});
});
@@ -35,4 +39,26 @@ describe("load_skill executor", () => {
contextStorage.run(ctx, () => execute({ skill: "talk-like-a-dog" })),
).rejects.toThrow("Available skills: custom__bark, custom__talk-like-a-dog.");
});
+
+ it("redirects an installed connection mistakenly passed as a skill", async () => {
+ const registry = {
+ dispose: async () => {},
+ getClient: () => {
+ throw new Error("Not used by load_skill");
+ },
+ getConnectionApproval: () => undefined,
+ getConnectionNames: () => ["linear"],
+ getConnections: () => [],
+ } satisfies ConnectionRegistry;
+ const ctx = new ContextContainer();
+ ctx.set(SandboxKey, mockSandbox().access);
+ ctx.set(ConnectionRegistryKey, registry);
+
+ const execute = SKILL_TOOL_DEFINITION.execute;
+ if (execute === undefined) throw new Error("load_skill tool is missing an execute function");
+
+ await expect(contextStorage.run(ctx, () => execute({ skill: "linear" }))).rejects.toThrow(
+ '"linear" is an installed connection, not a skill. Use connection_search with connection "linear" to find its tools.',
+ );
+ });
});
diff --git a/packages/eve/src/runtime/framework-tools/skill.ts b/packages/eve/src/runtime/framework-tools/skill.ts
index 55bb92553..21f32c16b 100644
--- a/packages/eve/src/runtime/framework-tools/skill.ts
+++ b/packages/eve/src/runtime/framework-tools/skill.ts
@@ -1,5 +1,6 @@
import { loadContext } from "#context/container.js";
import { DynamicSkillManifestKey, SandboxKey } from "#context/keys.js";
+import { ConnectionRegistryKey } from "#context/providers/connection-key.js";
import { loadSkillFromSandbox } from "#runtime/skills/sandbox-access.js";
import type { ResolvedToolDefinition } from "#runtime/types.js";
import type { JsonObject } from "#shared/json.js";
@@ -29,7 +30,23 @@ async function executeLoadSkillTool(args: LoadSkillInput): Promise<unknown> {
}
const { skill } = args;
- return await loadSkillFromSandbox(sandbox, skill, availableSkillNames(ctx));
+ const availableSkills = availableSkillNames(ctx);
+ try {
+ return await loadSkillFromSandbox(sandbox, skill, availableSkills);
+ } catch (error) {
+ const connectionName = ctx
+ .get(ConnectionRegistryKey)
+ ?.getConnectionNames()
+ .find((name) => name.toLowerCase() === skill.toLowerCase());
+ if (connectionName === undefined || availableSkills.includes(skill)) throw error;
+
+ const message = error instanceof Error ? error.message : String(error);
+ throw new Error(
+ `${message} "${connectionName}" is an installed connection, not a skill. ` +
+ `Use connection_search with connection "${connectionName}" to find its tools.`,
+ { cause: error },
+ );
+ }
}
// Dynamic skill names for load_skill's not-found hint. Dynamic-only on purpose:
@@ -52,6 +69,7 @@ export const SKILL_TOOL_DEFINITION: ResolvedToolDefinition = {
description: [
"Load the full instructions for one available skill by name or id.",
"Use this tool when the request clearly matches a listed skill description or when the user explicitly asks for that skill.",
+ "This is not for MCP connections; use connection_search to access an installed connection.",
"Loading adds the skill instructions to the current turn.",
'Choose the "skill" value from the Available skills block.',
].join(" "),
diff --git a/packages/eve/src/setup/boxes/select-connections.ts b/packages/eve/src/setup/boxes/select-connections.ts
index 813706233..62ec994ff 100644
--- a/packages/eve/src/setup/boxes/select-connections.ts
+++ b/packages/eve/src/setup/boxes/select-connections.ts
@@ -156,7 +156,7 @@ async function planCustomInteractive(asker: Asker, slug: string): Promise<Connec
text({
key: `mcp-url:${slug}`,
message: `MCP server URL for ${slug}`,
- placeholder: "https://mcp.example.com/sse",
+ placeholder: "https://mcp.example.com/mcp",
validate: (value) => (value.trim().length === 0 ? "A URL is required." : null),
}),
);
diff --git a/packages/eve/src/setup/cli/option-row.test.ts b/packages/eve/src/setup/cli/option-row.test.ts
index 3c8c91bc2..458293b25 100644
--- a/packages/eve/src/setup/cli/option-row.test.ts
+++ b/packages/eve/src/setup/cli/option-row.test.ts
@@ -147,7 +147,7 @@ describe("renderOptionRow", () => {
).toBe(" <dim>▷</dim> <dim>Waiting</dim>");
});
- test("warning-toned disabled rows keep the label dim and turn the reason yellow", () => {
+ test("warning-toned disabled rows keep the label dim and show a yellow alert annotation", () => {
expect(
row({
label: "Slack",
@@ -157,7 +157,7 @@ describe("renderOptionRow", () => {
reasonTone: "warning",
},
}),
- ).toBe(" <dim>Slack</dim><yellow> (Requires Vercel account, see /model)</yellow>");
+ ).toBe(" <dim>Slack</dim><yellow> ⚠ Requires Vercel account, see /model</yellow>");
});
test("a hint tab-aligns behind a padded label column", () => {
diff --git a/packages/eve/src/setup/cli/option-row.ts b/packages/eve/src/setup/cli/option-row.ts
index 521be9cd4..7620ed5a1 100644
--- a/packages/eve/src/setup/cli/option-row.ts
+++ b/packages/eve/src/setup/cli/option-row.ts
@@ -32,6 +32,8 @@ export interface RowGlyphs {
placeholder: string;
/** Separator before an inline hint. */
dot: string;
+ /** Attention marker for an unavailable option with actionable guidance. */
+ warning: string;
}
/** Canonical unicode glyphs; the CLI prompts render with these. */
@@ -41,6 +43,7 @@ export const UNICODE_ROW_GLYPHS: RowGlyphs = {
success: "✓",
placeholder: "◦",
dot: "·",
+ warning: "⚠",
};
export type OptionRowState =
@@ -126,11 +129,13 @@ function disabledLabel(
label: string,
state: Extract<OptionRowState, { kind: "disabled" }>,
colors: RowColors,
+ glyphs: RowGlyphs,
): string {
- const reason = parenthetical(state.reason);
if (state.reasonTone === "warning") {
- return `${colors.dim(label)}${colors.yellow(reason)}`;
+ const warning = state.reason === undefined ? "" : ` ${glyphs.warning} ${state.reason}`;
+ return `${colors.dim(label)}${colors.yellow(warning)}`;
}
+ const reason = parenthetical(state.reason);
return colors.dim(`${label}${reason}`);
}
@@ -157,7 +162,7 @@ function optionRowPresentation(input: OptionRowInput): OptionRowPresentation {
case "disabled":
return {
glyph: input.isCursor ? c.dim(glyphs.pointer) : unfocusedGlyph(input),
- label: disabledLabel(input.label, state, c),
+ label: disabledLabel(input.label, state, c, glyphs),
};
case "locked":
return {
diff --git a/packages/eve/src/setup/flows/connections.test.ts b/packages/eve/src/setup/flows/connections.test.ts
index dcc456fdb..bf4bade3d 100644
--- a/packages/eve/src/setup/flows/connections.test.ts
+++ b/packages/eve/src/setup/flows/connections.test.ts
@@ -57,6 +57,7 @@ function addConnectionDeps(): AddConnectionsDeps {
function runConnectionFlow(
list: ReturnType<typeof scriptConnectionList>,
deps: Partial<ConnectionsFlowDeps> = {},
+ disabledConnectionReasons: Readonly<Record<string, string>> = {},
) {
const defaults: ConnectionsFlowDeps = {
detectDeployment: vi.fn(async () => LINKED),
@@ -71,6 +72,7 @@ function runConnectionFlow(
return runConnectionsFlow({
appRoot: APP_ROOT,
prompter: createFakePrompter({ single: list.single }).prompter,
+ disabledConnectionReasons,
deps: { ...defaults, ...deps },
});
}
@@ -126,6 +128,25 @@ describe("runConnectionsFlow", () => {
});
});
+ it("disables a connection whose MCP endpoint is unreachable", async () => {
+ const list = scriptConnectionList(["cancel"]);
+ await expect(
+ runConnectionFlow(
+ list,
+ {},
+ {
+ notion: "https://mcp.notion.com/mcp is not reachable (HTTP 404).",
+ },
+ ),
+ ).resolves.toEqual({ kind: "cancelled" });
+
+ expect(list.requests[0]?.options.find((row) => row.value === "notion")).toMatchObject({
+ disabled: true,
+ disabledReasonTone: "warning",
+ disabledReason: "https://mcp.notion.com/mcp is not reachable (HTTP 404).",
+ });
+ });
+
it("runs the shared create-or-link flow before configuring an unlinked project", async () => {
const detectDeployment = vi
.fn<ConnectionsFlowDeps["detectDeployment"]>()
diff --git a/packages/eve/src/setup/flows/connections.ts b/packages/eve/src/setup/flows/connections.ts
index 157f407b8..70765329c 100644
--- a/packages/eve/src/setup/flows/connections.ts
+++ b/packages/eve/src/setup/flows/connections.ts
@@ -54,6 +54,7 @@ export type ConnectionsFlowResult =
function connectionRows(
authored: ReadonlySet<string>,
authStatus: VercelAuthStatus,
+ disabledConnectionReasons: Readonly<Record<string, string>>,
): SelectOption<string>[] {
const blocker = vercelAuthBlockerReason(authStatus);
const rows: SelectOption<string>[] = CONNECT_CONNECTIONS.map((entry) => {
@@ -61,6 +62,15 @@ function connectionRows(
if (authored.has(entry.slug)) {
return { ...row, completed: true, focusHint: "Already added" };
}
+ const disabledConnectionReason = disabledConnectionReasons[entry.slug];
+ if (disabledConnectionReason !== undefined) {
+ return {
+ ...row,
+ disabled: true,
+ disabledReason: disabledConnectionReason,
+ disabledReasonTone: "warning",
+ };
+ }
if (blocker !== undefined) {
return {
...row,
@@ -79,8 +89,9 @@ async function pickConnection(
prompter: Prompter,
authored: ReadonlySet<string>,
authStatus: VercelAuthStatus,
+ disabledConnectionReasons: Readonly<Record<string, string>>,
): Promise<string | undefined> {
- const options = connectionRows(authored, authStatus);
+ const options = connectionRows(authored, authStatus, disabledConnectionReasons);
const request: SingleSelectOptions<string> = {
message: CONNECTIONS_PROMPT_MESSAGE,
options,
@@ -108,6 +119,7 @@ export async function runConnectionsFlow(input: {
appRoot: string;
prompter: Prompter;
signal?: AbortSignal;
+ disabledConnectionReasons?: Readonly<Record<string, string>>;
deps?: Partial<ConnectionsFlowDeps>;
}): Promise<ConnectionsFlowResult> {
const { appRoot, prompter, signal } = input;
@@ -135,7 +147,12 @@ export async function runConnectionsFlow(input: {
let state = inProjectSetupState(appRoot, projectResolutionFromDeployment(deployment));
const authored = new Set(initialAuthored);
- const selected = await pickConnection(prompter, authored, authStatus);
+ const selected = await pickConnection(
+ prompter,
+ authored,
+ authStatus,
+ input.disabledConnectionReasons ?? {},
+ );
if (selected === undefined) return { kind: "cancelled" };
if (selected === "done" || authored.has(selected)) {
return { kind: "done", addedConnections: [] };