Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/lib/node-oauth-client-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class NodeOAuthClientProvider implements OAuthClientProvider {
private softwareVersion: string
private staticOAuthClientMetadata: StaticOAuthClientMetadata
private staticOAuthClientInfo: StaticOAuthClientInformationFull
private useOidcConfig: boolean

/**
* Creates a new NodeOAuthClientProvider
Expand All @@ -38,6 +39,7 @@ export class NodeOAuthClientProvider implements OAuthClientProvider {
this.softwareVersion = options.softwareVersion || MCP_REMOTE_VERSION
this.staticOAuthClientMetadata = options.staticOAuthClientMetadata
this.staticOAuthClientInfo = options.staticOAuthClientInfo
this.useOidcConfig = !!options.useOidcConfig
}

get redirectUrl(): string {
Expand Down Expand Up @@ -193,4 +195,13 @@ export class NodeOAuthClientProvider implements OAuthClientProvider {
if (DEBUG) await debugLog(this.serverUrlHash, 'Code verifier found:', !!verifier)
return verifier
}

/**
* Gets the PKCE code verifier
* @returns The code verifier
*/
async useOidcProviderConfiguration(): Promise<boolean> {
if (DEBUG) await debugLog(this.serverUrlHash, 'Use OpenID Configuration:', !!this.useOidcConfig)
return !!this.useOidcConfig;
}
}
2 changes: 2 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export interface OAuthProviderOptions {
staticOAuthClientMetadata?: StaticOAuthClientMetadata
/** Static OAuth client information to use instead of OAuth registration */
staticOAuthClientInfo?: StaticOAuthClientInformationFull
/** Static OAuth client information to use instead of OAuth registration */
useOidcConfig?: boolean
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ export async function parseCommandLineArgs(args: string[], usage: string) {
const serverUrl = args[0]
const specifiedPort = args[1] ? parseInt(args[1]) : undefined
const allowHttp = args.includes('--allow-http')
const useOidcConfig = args.includes('--use-oidc-config')

// Check for debug flag
const debug = args.includes('--debug')
Expand Down Expand Up @@ -669,7 +670,7 @@ export async function parseCommandLineArgs(args: string[], usage: string) {
})
}

return { serverUrl, callbackPort, headers, transportStrategy, host, debug, staticOAuthClientMetadata, staticOAuthClientInfo }
return { serverUrl, callbackPort, headers, transportStrategy, host, debug, staticOAuthClientMetadata, staticOAuthClientInfo, useOidcConfig }
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async function runProxy(
host: string,
staticOAuthClientMetadata: StaticOAuthClientMetadata,
staticOAuthClientInfo: StaticOAuthClientInformationFull,
useOidcConfig: boolean = false,
) {
// Set up event emitter for auth flow
const events = new EventEmitter()
Expand All @@ -54,6 +55,7 @@ async function runProxy(
clientName: 'MCP CLI Proxy',
staticOAuthClientMetadata,
staticOAuthClientInfo,
useOidcConfig,
})

// Create the STDIO transport for local connections
Expand Down Expand Up @@ -143,8 +145,8 @@ to the CA certificate file. If using claude_desktop_config.json, this might look

// Parse command-line arguments and run the proxy
parseCommandLineArgs(process.argv.slice(2), 'Usage: npx tsx proxy.ts <https://server-url> [callback-port] [--debug]')
.then(({ serverUrl, callbackPort, headers, transportStrategy, host, debug, staticOAuthClientMetadata, staticOAuthClientInfo }) => {
return runProxy(serverUrl, callbackPort, headers, transportStrategy, host, staticOAuthClientMetadata, staticOAuthClientInfo)
.then(({ serverUrl, callbackPort, headers, transportStrategy, host, debug, staticOAuthClientMetadata, staticOAuthClientInfo, useOidcConfig }) => {
return runProxy(serverUrl, callbackPort, headers, transportStrategy, host, staticOAuthClientMetadata, staticOAuthClientInfo, useOidcConfig)
})
.catch((error) => {
log('Fatal error:', error)
Expand Down