-
Notifications
You must be signed in to change notification settings - Fork 302
mcp: surface auth-gated failures #1059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
RhysSullivan
merged 3 commits into
UsefulSoftwareCo:main
from
gjermundgaraba:gjermund/mcp-failure-surfacing
Jun 21, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| // Regression guard for the add-MCP dead-end on a server that gates on auth | ||
| // without a spec-compliant MCP challenge: the user should reach the auth-method | ||
| // editor, not a "requires authentication, add credentials below" error with no | ||
| // editor rendered below it. | ||
| // | ||
| // Selfhost-only because the probe must shape-probe a loopback server: the | ||
| // selfhost instance runs with EXECUTOR_ALLOW_LOCAL_NETWORK so its outbound | ||
| // probe can reach the loopback test server. Video is the artifact. | ||
| import { randomBytes } from "node:crypto"; | ||
|
|
||
| import { expect } from "@effect/vitest"; | ||
| import { Effect } from "effect"; | ||
| import { HttpServerResponse } from "effect/unstable/http"; | ||
| import { composePluginApi } from "@executor-js/api/server"; | ||
| import { deriveMcpNamespace } from "@executor-js/plugin-mcp"; | ||
| import { mcpHttpPlugin } from "@executor-js/plugin-mcp/api"; | ||
| import { IntegrationSlug } from "@executor-js/sdk/shared"; | ||
| import { serveTestHttpApp } from "@executor-js/sdk/testing"; | ||
|
|
||
| import { scenario } from "../src/scenario"; | ||
| import { Api, Browser, Target } from "../src/services"; | ||
|
|
||
| const api = composePluginApi([mcpHttpPlugin()] as const); | ||
|
|
||
| scenario( | ||
| "Auth methods · a non-spec-compliant 401 still gets the auth editor (no dead-end)", | ||
| {}, | ||
| Effect.scoped( | ||
| Effect.gen(function* () { | ||
| const target = yield* Target; | ||
| const browser = yield* Browser; | ||
| const { client: makeApiClient } = yield* Api; | ||
| // Auth-gated shape: a 401 with no Bearer WWW-Authenticate, no RFC 9728 | ||
| // protected-resource metadata (the .well-known probe 404s), and a body | ||
| // that is neither JSON-RPC nor an OAuth error envelope. | ||
| const server = yield* serveTestHttpApp((request) => | ||
| Effect.succeed( | ||
| (request.url ?? "").includes("/.well-known/") | ||
| ? HttpServerResponse.text("missing", { status: 404 }) | ||
| : HttpServerResponse.jsonUnsafe({ message: "Unauthorized" }, { status: 401 }), | ||
| ), | ||
| ); | ||
| const endpoint = server.url("/mcp"); | ||
| // The raw 401 server reports no server name, so the probe can't seed a | ||
| // unique identity. Selfhost identities share one tenant, so name the | ||
| // integration uniquely to keep the derived slug from colliding across | ||
| // runs. | ||
| const name = `auth-gated-401-${randomBytes(3).toString("hex")}`; | ||
| const slug = IntegrationSlug.make(deriveMcpNamespace({ name })); | ||
| const identity = yield* target.newIdentity(); | ||
| const client = yield* makeApiClient(api, identity); | ||
|
|
||
| yield* Effect.gen(function* () { | ||
| yield* browser.session(identity, async ({ page, step }) => { | ||
| await step("Open the add-MCP flow pointed at the auth-gated server", async () => { | ||
| await page.goto(`/integrations/add/mcp?url=${encodeURIComponent(endpoint)}`, { | ||
| waitUntil: "networkidle", | ||
| }); | ||
| // Before the fix this dead-ended on a red "add credentials below" | ||
| // error with no editor. Now the auth-method editor renders. | ||
| await page.getByText("How does this server authenticate?").waitFor(); | ||
| }); | ||
|
|
||
| await step("The probe seeded a detected Bearer-header method", async () => { | ||
| await page.getByText("Method 1 · Detected").waitFor(); | ||
| // The preview card flags the gate rather than failing the probe. | ||
| await page.getByText("Auth required").first().waitFor(); | ||
| }); | ||
|
|
||
| await step("Add the source with the declared method", async () => { | ||
| await page.getByPlaceholder("e.g. Linear").fill(name); | ||
| await page.getByRole("button", { name: "Add source" }).click(); | ||
| // onComplete routes to the new integration's detail hub. | ||
| await page.waitForURL(/\/integrations\/(?!add\b)[^/?]+$/, { timeout: 30_000 }); | ||
| const landedSlug = new URL(page.url()).pathname.split("/").filter(Boolean).at(-1); | ||
| expect(landedSlug, "the add flow lands on the created integration").toBe(String(slug)); | ||
| await page.getByText("Connections").first().waitFor(); | ||
| }); | ||
|
|
||
| await step("The declared API key method is connectable", async () => { | ||
| await page.getByRole("button", { name: "Add connection" }).first().click(); | ||
| await page.getByRole("tab", { name: "API key (Authorization)" }).waitFor(); | ||
| }); | ||
| }); | ||
| }).pipe(Effect.ensuring(client.mcp.removeServer({ params: { slug } }).pipe(Effect.ignore))); | ||
| }), | ||
| ), | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
McpInvocationErroris still exported fromindex.tsbut has been changed fromSchema.TaggedErrorClass(which carrieshttpApiStatus: 400and is compatible with.addError()on HTTP API groups) toData.TaggedError(no schema annotations). Any downstream consumer that used the old class as a typed HTTP API error would get a silent runtime change — thehttpApiStatusproperty no longer exists and the error can no longer be added to an HTTP API route withaddError. Consider also explicitly documenting whetherMcpOAuthReauthorizationRequiredis intentionally absent from the barrel export so the package surface is clear and consistent.