{"record":{"id":"31393d5dfbc96f5c","repo":"danny-avila/LibreChat","slug":"mcp-servername-toolname-oauth-authentica","errorCode":null,"errorMessage":"[MCP][${serverName}][${toolName}] OAuth authentication required. Please check the server logs for the authentication URL.","messagePattern":"\\[MCP\\]\\[(.+?)\\]\\[(.+?)\\] OAuth authentication required\\. Please check the server logs for the authentication URL\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"api/server/services/MCP.js","lineNumber":1148,"sourceCode":"        error.message?.includes('401') ||\n        error.message?.includes('OAuth') ||\n        error.message?.includes('authentication') ||\n        error.message?.includes('Non-200 status code (401)');\n      const isOAuthFlowSignal =\n        error.message === 'OAuth flow initiated - return early' ||\n        error.message === 'Pending OAuth flow reused - return early';\n\n      if (isOAuthError) {\n        if (\n          capturedServerConfig &&\n          !requiresOAuthMachinery(capturedServerConfig) &&\n          !isOAuthFlowSignal\n        ) {\n          throw new Error(\n            `[MCP][${serverName}][${toolName}] upstream authentication failed; MCP OAuth is not configured for this server.`,\n          );\n        }\n        throw new Error(\n          `[MCP][${serverName}][${toolName}] OAuth authentication required. Please check the server logs for the authentication URL.`,\n        );\n      }\n\n      throw new Error(\n        `[MCP][${serverName}][${toolName}] tool call failed${error?.message ? `: ${error?.message}` : '.'}`,\n      );\n    }\n  };\n\n  const toolInstance = tool(_call, {\n    schema,\n    name: normalizedToolKey,\n    description: description || '',\n    responseFormat: AgentConstants.CONTENT_AND_ARTIFACT,\n  });\n  toolInstance.mcp = true;\n  toolInstance.mcpRawServerName = serverName;","sourceCodeStart":1130,"sourceCodeEnd":1166,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/services/MCP.js#L1130-L1166","documentation":"In the MCP tool _call catch block (MCP.js:1148), when an auth-class error occurs and either OAuth machinery IS configured or an OAuth flow signal was emitted, the tool surfaces this message directing the user to the auth URL in the server logs. Unlike 149, this is the expected mid-flow state: the OAuth dance has started or is pending, and the operator must complete it.","triggerScenarios":"The MCP server returned 401/auth error and LibreChat has OAuth configured, so it initiated (or reused) an OAuth flow and threw 'OAuth flow initiated - return early'. The user must visit the printed authentication URL to authorize the MCP server.","commonSituations":"First tool call against a freshly added OAuth-backed MCP server. A previously authorized token expired and the refresh failed, forcing re-auth. Multiple users; one user has not yet completed consent.","solutions":["Read the server logs for the authentication URL printed for this server/user and complete the consent in the browser.","If no URL appears, raise log verbosity and confirm the OAuth flow actually started (check oauthStart/oauthEnd wiring).","After completing consent, retry the tool call — the token should now be cached."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await callMcpTool(...);\n} catch (e) {\n  if (/OAuth authentication required/.test(e.message)) {\n    const url = await pollLogsForAuthUrl(serverName, runId);\n    return redirectTo(url);\n  }\n  throw e;\n}","preventionTips":["Surface the auth URL from server logs to the user in-product, not just in logs.","After consent, retry automatically since the token is cached.","Monitor token expiry and refresh proactively to reduce re-consent prompts."],"tags":["mcp","oauth","authentication","user-action"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}