From fbfaba09fd28fc0018f0e9f79ff57631e5cadf99 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 17 Jun 2026 09:51:51 +0800 Subject: [PATCH] refactor(agents): hide mcp oauth redirect classifier --- src/agents/mcp-oauth.test.ts | 10 ---------- src/agents/mcp-oauth.ts | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/agents/mcp-oauth.test.ts b/src/agents/mcp-oauth.test.ts index 19f330f08f38..40559be6421e 100644 --- a/src/agents/mcp-oauth.test.ts +++ b/src/agents/mcp-oauth.test.ts @@ -6,7 +6,6 @@ import { vi } from "vitest"; import { clearMcpOAuthCredentials, createMcpOAuthClientProvider, - isMcpOAuthRedirectRegistrationError, runMcpOAuthLogin, } from "./mcp-oauth.js"; @@ -88,15 +87,6 @@ describe("MCP OAuth provider", () => { expect(provider.redirectUrl).toBe("http://127.0.0.1:8989/oauth/callback"); }); - it("detects redirect registration failures for localhost fallback", () => { - expect( - isMcpOAuthRedirectRegistrationError( - new Error("HTTP 400: invalid_client_metadata redirect_uri must be localhost"), - ), - ).toBe(true); - expect(isMcpOAuthRedirectRegistrationError(new Error("unauthorized"))).toBe(false); - }); - it("retries MCP OAuth login with localhost after redirect registration rejection", async () => { authMock.mockReset(); authMock diff --git a/src/agents/mcp-oauth.ts b/src/agents/mcp-oauth.ts index 2ae0eb624c03..dcff4aa46505 100644 --- a/src/agents/mcp-oauth.ts +++ b/src/agents/mcp-oauth.ts @@ -49,7 +49,7 @@ export type McpOAuthCredentialsStatus = { const LEGACY_DEFAULT_REDIRECT_URL = "http://127.0.0.1:8989/oauth/callback"; const LOCALHOST_REDIRECT_URL = "http://localhost:8989/oauth/callback"; -export function isMcpOAuthRedirectRegistrationError(error: unknown): boolean { +function isMcpOAuthRedirectRegistrationError(error: unknown): boolean { return /invalid_client_metadata|redirect_uri/i.test(String(error)); }