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
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🧬 fix: Normalize Legacy MCP Null Headers (#14720)
Danny Avila6bff5ba1488b
diff --git a/packages/api/src/mcp/registry/__tests__/ServerConfigsDB.test.ts b/packages/api/src/mcp/registry/__tests__/ServerConfigsDB.test.tsindex 7ae0862632..aebf774dd4 100644--- a/packages/api/src/mcp/registry/__tests__/ServerConfigsDB.test.ts+++ b/packages/api/src/mcp/registry/__tests__/ServerConfigsDB.test.ts@@ -6,6 +6,7 @@ import {PrincipalType,PermissionBits,PrincipalModel,+ MCPOptionsSchema,TokenExchangeMethodEnum,} from 'librechat-data-provider';import type { ParsedServerConfig } from '~/mcp/types';@@ -1033,6 +1034,35 @@ describe('ServerConfigsDB', () => {});describe('get()', () => {+ it('normalizes null headers from historical stored configs before runtime use', async () => {+ const server = await mongoose.models.MCPServer.create({+ serverName: 'legacy-null-headers',+ normalizedServerName: 'legacy-null-headers',+ author: new mongoose.Types.ObjectId(userId),+ config: {+ type: 'streamable-http',+ url: 'https://example.com/mcp',+ title: 'Legacy Null Headers',+ headers: null,+ },+ });+ await mongoose.models.AclEntry.create({+ principalType: PrincipalType.USER,+ principalModel: PrincipalModel.USER,+ principalId: new mongoose.Types.ObjectId(userId),+ resourceType: ResourceType.MCPSERVER,+ resourceId: server._id,+ permBits: PermissionBits.VIEW,+ grantedBy: new mongoose.Types.ObjectId(userId),+ });++ const result = await serverConfigsDB.get('legacy-null-headers', userId);++ expect(result).toBeDefined();+ expect(result).not.toHaveProperty('headers');+ expect(MCPOptionsSchema.safeParse(result).success).toBe(true);+ });+describe('public access (no userId)', () => {it('should return undefined for non-public server without userId', async () => {const config = createSSEConfig('Private Server');diff --git a/packages/api/src/mcp/registry/db/ServerConfigsDB.ts b/packages/api/src/mcp/registry/db/ServerConfigsDB.tsindex d15d918075..f561332233 100644--- a/packages/api/src/mcp/registry/db/ServerConfigsDB.ts+++ b/packages/api/src/mcp/registry/db/ServerConfigsDB.ts@@ -95,6 +95,19 @@ function sanitizeUserManagedOAuthConfig(config: ParsedServerConfig): ParsedServe};}+/** Normalizes legacy values that predate the current runtime config schemas. */+function normalizePersistedConfig(config: ParsedServerConfig): ParsedServerConfig {+ const persistedConfig = config as ParsedServerConfig & {+ headers?: Record<string, string> | null;+ };+ if (persistedConfig.headers !== null) {+ return config;+ }++ const { headers: _legacyNullHeaders, ...normalizedConfig } = persistedConfig;+ return normalizedConfig as ParsedServerConfig;+}+function normalizeOAuthUrl(value?: string): string | undefined {if (!value) {return value;@@ -577,7 +590,9 @@ export class ServerConfigsDB implements IServerConfigsRepositoryInterface {updatedAt: serverDBDoc.updatedAt?.getTime(),...(authorId ? { author: authorId } : {}),};- return sanitizeUserManagedOAuthConfig(await this.decryptConfig(config));+ return sanitizeUserManagedOAuthConfig(+ await this.decryptConfig(normalizePersistedConfig(config)),+ );}/**