Implementation:1mcp app Agent SDKOAuthClientProvider
| Knowledge Sources | |
|---|---|
| Domains | Security, MCP_Protocol |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Concrete wrapper around the MCP SDK's OAuth client provider for upstream server authentication with credential storage, auto-registration, and authority-based scoping.
Description
The SDKOAuthClientProvider class wraps the MCP SDK's OAuth client to authenticate upstream MCP servers. It is created by `createOAuthProvider` in the transport factory with a redirect URL, optional client credentials, scopes, and issuer. The provider supports auto-registration with the upstream OAuth server and stores tokens in the upstream OAuth storage directory. The authority configuration includes owner (runtime scope ID), source (credential authority or server name), route (transport type and URL), and a configuration fingerprint for identity matching.
Usage
Reference this wrapper when you need to:
- Authenticate HTTP/SSE MCP backends that require OAuth
- Configure auto-registration with upstream OAuth servers
- Store OAuth tokens in the upstream credential store
- Scope credentials by runtime identity and server name
Code Reference
Source Location
- Repository: 1MCP Agent
- File: src/auth/sdkOAuthClientProvider.ts, src/sdk/legacy/transport/transportFactory.ts (L81-124, createOAuthProvider)
Signature
export interface OAuthClientConfig {
autoRegister: boolean;
redirectUrl: string;
clientId?: string;
clientSecret?: string;
scopes?: string[];
issuer?: string;
clientMetadataUrl?: string;
legacy?: boolean;
authority?: {
owner: string;
source: string;
route: { kind: 'sse' | 'http'; connectionKey: string; url: string };
configuration: string;
};
}
function createOAuthProvider(name: string, validatedTransport: ValidatedTransport): SDKOAuthClientProvider;
Import
import { SDKOAuthClientProvider, OAuthClientConfig } from '@src/auth/sdkOAuthClientProvider.js';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Server name (credential scope) |
| autoRegister | boolean | No | Auto client registration (default: true) |
| redirectUrl | string | Yes | OAuth callback URL |
| clientId, clientSecret | string | No | Pre-registered credentials |
| scopes | string[] | No | OAuth scopes |
Outputs
| Name | Type | Description |
|---|---|---|
| SDKOAuthClientProvider | instance | OAuth provider attached to transport |
Usage Examples
Auto-Registration OAuth Flow
# The transport factory auto-creates an OAuth provider for HTTP/SSE servers.
# Users trigger the flow by accessing the /oauth dashboard in the browser.
1mcp serve --enable-auth --external-url https://my-server.com
# Then add an OAuth-requiring server:
1mcp mcp add oauth-server --type=http --url=https://api.example.com/mcp