feat(mcp): drive auth by AuthType and auto-detect OAuth on test

Select the auth header for the configured strategy only, instead of
emitting both X-API-Key and Authorization whenever the fields happened
to be set (which double-authed after switching strategies). AuthType=""
keeps the legacy infer-from-fields behavior for pre-existing rows.

Add a configurable api_key_header (non-secret, defaults to X-API-Key) so
services expecting the key in a different header work without plaintext
custom headers.

On connection test, upgrade a bare 401 that advertises RFC 9728
protected-resource metadata into an explicit OAuthRequired signal so the
UI can guide the user to switch to OAuth 2.0. Surface the server's
description from the initialize handshake in the test result.
This commit is contained in:
wizardchen
2026-06-29 20:48:59 +08:00
committed by lyingbug
parent c29761331c
commit f2686e9e39
16 changed files with 546 additions and 155 deletions
+10 -1
View File
@@ -4113,6 +4113,14 @@ export default {
addEnvVar: 'Добавить переменную',
enableService: 'Включить сервис',
authConfig: 'Аутентификация',
authType: 'Способ аутентификации',
authTypeNone: 'Нет / Свой заголовок',
authTypeApiKey: 'API Key / Token',
authTypeOAuth: 'OAuth 2.0 (авторизация при первом подключении)',
oauthAuthorizeHint: 'Нажатие «Авторизоваться» сначала сохранит текущую конфигурацию, затем запустит авторизацию (каждый пользователь авторизуется отдельно).',
apiKeyHeader: 'Имя заголовка',
apiKeyHeaderDesc: 'По умолчанию X-API-Key. Для Bearer укажите Authorization и впишите "Bearer <token>" в значение ниже; для «сырого» токена используйте Authorization и сам токен.',
credentialValue: 'Секрет / Токен',
apiKey: 'API Key',
bearerToken: 'Bearer Token',
optional: 'Необязательно',
@@ -4132,7 +4140,8 @@ export default {
created: 'Сервис MCP создан',
updated: 'Сервис MCP обновлён',
createFailed: 'Не удалось создать сервис MCP',
updateFailed: 'Не удалось обновить сервис MCP'
updateFailed: 'Не удалось обновить сервис MCP',
oauthRequired: 'Сервис требует OAuth. Переключено на OAuth 2.0 — сохраните и нажмите «Авторизоваться».'
},
customHeaders: {
label: 'Пользовательские заголовки (необязательно)',