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:
@@ -19,6 +19,10 @@ export interface MCPService {
|
||||
// optional-property typing remains so create-mode payloads can still
|
||||
// carry them in the initial POST body.
|
||||
api_key?: string
|
||||
// Header name carrying api_key when auth_type is "api_key". Non-secret;
|
||||
// empty defaults to "X-API-Key". Lets services expecting the key in a
|
||||
// different header (e.g. raw token in "Authorization") work.
|
||||
api_key_header?: string
|
||||
token?: string
|
||||
custom_headers?: Record<string, string>
|
||||
// OAuth-only, non-secret configuration.
|
||||
@@ -69,6 +73,10 @@ export interface MCPResource {
|
||||
export interface MCPTestResult {
|
||||
success: boolean
|
||||
message?: string
|
||||
description?: string
|
||||
// Set when the server requires OAuth (RFC 9728) but the service was not
|
||||
// configured for it — the UI guides the user to switch to OAuth 2.0.
|
||||
oauth_required?: boolean
|
||||
tools?: MCPTool[]
|
||||
resources?: MCPResource[]
|
||||
}
|
||||
@@ -212,4 +220,3 @@ export async function resolveToolApproval(
|
||||
): Promise<void> {
|
||||
await post(`/api/v1/agent/tool-approvals/${encodeURIComponent(pendingId)}`, body)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user