feat: oauth 2.1 static mcp

Co-Authored-By: Joost Mul <6438009+donmul@users.noreply.github.com>
This commit is contained in:
Timothy Jaeryang Baek
2026-03-24 17:58:21 -05:00
co-authored by Joost Mul
parent 631bd20c35
commit 601bb78358
6 changed files with 166 additions and 28 deletions
+1
View File
@@ -342,6 +342,7 @@ type RegisterOAuthClientForm = {
url: string;
client_id: string;
client_name?: string;
client_secret?: string;
};
export const registerOAuthClient = async (
+49 -13
View File
@@ -58,6 +58,9 @@
let oauthClientInfo = null;
let oauthClientId = '';
let oauthClientSecret = '';
let enable = true;
let loading = false;
let showAdvanced = false;
@@ -75,14 +78,22 @@
return;
}
const res = await registerOAuthClient(
localStorage.token,
{
url: url,
client_id: id
},
'mcp'
).catch((err) => {
const formData: { url: string; client_id: string; client_secret?: string } = {
url: url,
client_id: id
};
// For static OAuth, include client credentials
if (auth_type === 'oauth_2.1_static') {
if (!oauthClientId || !oauthClientSecret) {
toast.error($i18n.t('Please enter Client ID and Client Secret'));
return;
}
formData.client_id = id;
formData.client_secret = oauthClientSecret;
}
const res = await registerOAuthClient(localStorage.token, formData, 'mcp').catch((err) => {
toast.error($i18n.t('Registration failed'));
return null;
});
@@ -267,7 +278,11 @@
return;
}
if (type === 'mcp' && auth_type === 'oauth_2.1' && !oauthClientInfo) {
if (
type === 'mcp' &&
['oauth_2.1', 'oauth_2.1_static'].includes(auth_type) &&
!oauthClientInfo
) {
toast.error($i18n.t('Please register the OAuth client'));
loading = false;
return;
@@ -320,7 +335,10 @@
id: id,
name: name,
description: description,
...(oauthClientInfo ? { oauth_client_info: oauthClientInfo } : {})
...(oauthClientInfo ? { oauth_client_info: oauthClientInfo } : {}),
...(auth_type === 'oauth_2.1_static'
? { oauth_client_id: oauthClientId, oauth_client_secret: oauthClientSecret }
: {})
}
};
@@ -345,6 +363,8 @@
description = '';
oauthClientInfo = null;
oauthClientId = '';
oauthClientSecret = '';
enable = true;
functionNameFilterList = '';
@@ -369,6 +389,8 @@
name = connection.info?.name ?? '';
description = connection.info?.description ?? '';
oauthClientInfo = connection.info?.oauth_client_info ?? null;
oauthClientId = connection.info?.oauth_client_id ?? '';
oauthClientSecret = connection.info?.oauth_client_secret ?? '';
enable = connection.config?.enable ?? true;
functionNameFilterList = connection.config?.function_name_filter_list ?? '';
@@ -607,7 +629,7 @@
</div>
</div>
{#if auth_type === 'oauth_2.1'}
{#if ['oauth_2.1', 'oauth_2.1_static'].includes(auth_type)}
<div class="flex items-center gap-2">
<div class="flex flex-col justify-end items-center shrink-0">
<Tooltip
@@ -660,6 +682,7 @@
<option value="system_oauth">{$i18n.t('OAuth')}</option>
{#if type === 'mcp'}
<option value="oauth_2.1">{$i18n.t('OAuth 2.1')}</option>
<option value="oauth_2.1_static">{$i18n.t('OAuth 2.1 (Static)')}</option>
{/if}
{/if}
</select>
@@ -696,6 +719,19 @@
>
{$i18n.t('Uses OAuth 2.1 Dynamic Client Registration')}
</div>
{:else if auth_type === 'oauth_2.1_static'}
<div class="flex flex-col gap-1.5 w-full mt-0.5">
<SensitiveInput
bind:value={oauthClientId}
placeholder={$i18n.t('Client ID')}
required={false}
/>
<SensitiveInput
bind:value={oauthClientSecret}
placeholder={$i18n.t('Client Secret')}
required={false}
/>
</div>
{/if}
</div>
</div>
@@ -847,7 +883,7 @@
{/if}
{#if !direct}
<hr class=" border-gray-100 dark:border-gray-700/10 my-2.5 w-full" />
<hr class=" border-gray-100/50 dark:border-gray-700/10 my-2.5 w-full" />
<div class="flex flex-col w-full mt-2">
<label
@@ -872,7 +908,7 @@
{#if type === 'mcp'}
<div
class=" bg-yellow-500/20 text-yellow-700 dark:text-yellow-200 rounded-2xl text-xs px-4 py-3 mb-2"
class=" bg-yellow-500/20 text-yellow-700 dark:text-yellow-200 rounded-2xl text-xs px-4 py-3 mb-2 mt-1"
>
<span class="font-medium">
{$i18n.t('Warning')}:
@@ -333,6 +333,8 @@
"Click on the user role button to change a user's role.": "",
"Click to copy ID": "",
"Clipboard write permission denied. Please check your browser settings to grant the necessary access.": "",
"Client ID": "",
"Client Secret": "",
"Clone": "",
"Clone Chat": "",
"Clone of {{TITLE}}": "",
@@ -1381,6 +1383,7 @@
"November": "",
"OAuth": "",
"OAuth 2.1": "",
"OAuth 2.1 (Static)": "",
"OAuth ID": "",
"October": "",
"Off": "",
@@ -1495,6 +1498,7 @@
"Please enter a message or attach a file.": "",
"Please enter a prompt": "",
"Please enter a valid ID": "",
"Please enter Client ID and Client Secret": "",
"Please enter a valid JSON spec": "",
"Please enter a valid path": "",
"Please enter a valid URL": "",