Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

fix: log config-blocked MCP recovery at debug instead of error (#15360)

Danny Avila180b56531a1a
diff --git a/packages/api/src/mcp/catalog/recovery.spec.ts b/packages/api/src/mcp/catalog/recovery.spec.ts
index d9b374cd79..053230268c 100644
--- a/packages/api/src/mcp/catalog/recovery.spec.ts
+++ b/packages/api/src/mcp/catalog/recovery.spec.ts
@@ -1,8 +1,14 @@
+import { logger } from '@librechat/data-schemas';
import { Constants } from 'librechat-data-provider';
+import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
import type { IUser } from '@librechat/data-schemas';
import type { LCAvailableTools, ParsedServerConfig, ToolDiscoveryOptions } from '../types';
import { loadMCPServerCatalogs, recoverMCPServerCatalogs } from './recovery';
+jest.mock('@librechat/data-schemas', () => ({
+ logger: { info: jest.fn(), warn: jest.fn(), error: jest.fn(), debug: jest.fn() },
+}));
+
const user = { id: 'user-1' } as IUser;
const serverConfig = (name: string): ParsedServerConfig =>
({ type: 'streamable-http', url: `https://${name}.example.com/mcp` }) as ParsedServerConfig;
@@ -94,6 +100,40 @@ describe('recoverMCPServerCatalogs', () => {
expect(result.size).toBe(7);
});
+ it('logs configuration-impossible discovery failures at debug, keeping error for the unexpected', async () => {
+ const servers = [
+ { serverName: 'policy-blocked', serverConfig: serverConfig('blocked') },
+ { serverName: 'crashed', serverConfig: serverConfig('crashed') },
+ ];
+
+ const result = await recoverMCPServerCatalogs(
+ { user, servers },
+ {
+ loadUserMCPAuthMap: jest.fn().mockResolvedValue({}),
+ discoverServerTools: jest.fn(async ({ serverName }: ToolDiscoveryOptions) => {
+ if (serverName === 'policy-blocked') {
+ throw new McpError(
+ ErrorCode.InvalidRequest,
+ 'Resolved MCP server URL is not allowed by the configured domain policy.',
+ );
+ }
+ throw new Error('socket hang up');
+ }),
+ formatServerTools: jest.fn(),
+ },
+ );
+
+ expect(result.size).toBe(0);
+ expect(logger.debug).toHaveBeenCalledWith(
+ expect.stringContaining('policy-blocked is not recoverable under current configuration'),
+ );
+ expect(logger.error).toHaveBeenCalledTimes(1);
+ expect(logger.error).toHaveBeenCalledWith(
+ expect.stringContaining('crashed'),
+ expect.any(Error),
+ );
+ });
+
it('keeps successful catalogs when another server fails or has no authoritative tools', async () => {
const servers = ['good', 'failed', 'missing'].map((serverName) => ({
serverName,
diff --git a/packages/api/src/mcp/catalog/recovery.ts b/packages/api/src/mcp/catalog/recovery.ts
index 6d17b6dd02..f4e9f7ab95 100644
--- a/packages/api/src/mcp/catalog/recovery.ts
+++ b/packages/api/src/mcp/catalog/recovery.ts
@@ -1,4 +1,5 @@
import { logger } from '@librechat/data-schemas';
+import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
import type { IUser } from '@librechat/data-schemas';
import type { LCAvailableTools, ParsedServerConfig, ToolDiscoveryOptions } from '../types';
@@ -94,6 +95,16 @@ async function discoverCandidate(
result.tools == null ? null : deps.formatServerTools(serverName, result.tools),
];
} catch (error) {
+ /** Discovery raises `InvalidRequest` precisely when configuration makes the attempt
+ * impossible — domain policy, unresolved placeholders, missing runtime fields. That
+ * failure recurs on every request until an admin changes configuration, so it is
+ * expected state, logged at the same level as this file's other config-proven skips. */
+ if (error instanceof McpError && error.code === ErrorCode.InvalidRequest) {
+ logger.debug(
+ `[MCP catalog recovery] ${serverName} is not recoverable under current configuration: ${error.message}`,
+ );
+ return [serverName, null];
+ }
logger.error(`[MCP catalog recovery] Failed to discover tools for ${serverName}:`, error);
return [serverName, null];
}