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: Resolve Env. Variables for MCP OAuth Manual Config (#9501)

Dev920966f89542
diff --git a/packages/api/src/utils/env.ts b/packages/api/src/utils/env.ts
index d9f29fddcb..767d95101e 100644
--- a/packages/api/src/utils/env.ts
+++ b/packages/api/src/utils/env.ts
@@ -191,6 +191,21 @@ export function processMCPEnv(params: {
newObj.url = processSingleValue({ originalValue: newObj.url, customUserVars, user, body });
}
+ // Process OAuth configuration if it exists (for all transport types)
+ if ('oauth' in newObj && newObj.oauth) {
+ const processedOAuth: Record<string, string | string[] | undefined> = {};
+ for (const [key, originalValue] of Object.entries(newObj.oauth)) {
+ // Only process string values for environment variables
+ // token_exchange_method is an enum and shouldn't be processed
+ if (typeof originalValue === 'string') {
+ processedOAuth[key] = processSingleValue({ originalValue, customUserVars, user, body });
+ } else {
+ processedOAuth[key] = originalValue;
+ }
+ }
+ newObj.oauth = processedOAuth;
+ }
+
return newObj;
}