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: Allow Optional client_secret for MCP OAuth (#12460)

apuzikovfb851cae6391
diff --git a/client/src/components/SidePanel/MCPBuilder/MCPServerDialog/sections/AuthSection.tsx b/client/src/components/SidePanel/MCPBuilder/MCPServerDialog/sections/AuthSection.tsx
index 6d18ccf15b..29b3924c3e 100644
--- a/client/src/components/SidePanel/MCPBuilder/MCPServerDialog/sections/AuthSection.tsx
+++ b/client/src/components/SidePanel/MCPBuilder/MCPServerDialog/sections/AuthSection.tsx
@@ -183,35 +183,13 @@ export default function AuthSection({ isEditMode, serverName }: AuthSectionProps
</div>
<div className="space-y-1.5">
<Label htmlFor="oauth_client_secret" className="text-sm font-medium">
- {localize('com_ui_client_secret')}{' '}
- {!isEditMode && (
- <>
- <span aria-hidden="true" className="text-text-secondary">
- *
- </span>
- <span className="sr-only">{localize('com_ui_field_required')}</span>
- </>
- )}
+ {localize('com_ui_client_secret')}
</Label>
<SecretInput
id="oauth_client_secret"
placeholder={isEditMode ? localize('com_ui_leave_blank_to_keep') : ''}
- aria-invalid={errors.auth?.oauth_client_secret ? 'true' : 'false'}
- aria-describedby={
- errors.auth?.oauth_client_secret ? 'oauth-client-secret-error' : undefined
- }
- {...register('auth.oauth_client_secret', { required: !isEditMode })}
- className={cn(errors.auth?.oauth_client_secret && 'border-border-destructive')}
+ {...register('auth.oauth_client_secret')}
/>
- {errors.auth?.oauth_client_secret && (
- <p
- id="oauth-client-secret-error"
- role="alert"
- className="text-xs text-text-destructive"
- >
- {localize('com_ui_field_required')}
- </p>
- )}
</div>
</div>
diff --git a/packages/api/src/mcp/oauth/handler.ts b/packages/api/src/mcp/oauth/handler.ts
index 0e7a645b03..6f1deea8a3 100644
--- a/packages/api/src/mcp/oauth/handler.ts
+++ b/packages/api/src/mcp/oauth/handler.ts
@@ -597,7 +597,25 @@ export class MCPOAuthHandler {
let clientInfo: OAuthClientInformation | undefined;
let reusedStoredClient = false;
- if (findToken) {
+ if (config?.client_id) {
+ logger.debug(`[MCPOAuth] Using predefined client_id for ${serverName}`);
+ let tokenEndpointAuthMethod: string;
+ if (!config.client_secret) {
+ tokenEndpointAuthMethod = 'none';
+ } else {
+ tokenEndpointAuthMethod =
+ getForcedTokenEndpointAuthMethod(config.token_exchange_method) ?? 'client_secret_basic';
+ }
+
+ clientInfo = {
+ client_id: config.client_id,
+ client_secret: config.client_secret,
+ redirect_uris: [redirectUri],
+ scope: config.scope,
+ token_endpoint_auth_method: tokenEndpointAuthMethod,
+ };
+ logger.debug(`[MCPOAuth] Using predefined client with ID: ${clientInfo.client_id}`);
+ } else if (findToken) {
try {
const existing = await MCPTokenStorage.getClientInfoAndMetadata({
userId,
@@ -638,6 +656,7 @@ export class MCPOAuthHandler {
}
if (!clientInfo) {
+ logger.debug(`[MCPOAuth] Registering OAuth client with redirect URI: ${redirectUri}`);
clientInfo = await this.registerOAuthClient(
authServerUrl.toString(),
metadata,