Add oauth section to mcp.json to allow overriding of client id (#308648)

* Add `oauth` section to mcp.json to allow overriding of client id

More properties (like client secret) can come later... but this is the foundation, which is a lot of plumbing...

ref https://github.com/microsoft/vscode/issues/257415

* feedback
This commit is contained in:
Tyler James Leonhardt
2026-04-08 19:40:23 -07:00
committed by GitHub
parent 99d79c60bf
commit d632fa37d2
15 changed files with 94 additions and 24 deletions
@@ -170,7 +170,7 @@ export class MsalAuthProvider implements AuthenticationProvider {
async getSessions(scopes: string[] | undefined, options: AuthenticationGetSessionOptions = {}): Promise<AuthenticationSession[]> {
const askingForAll = scopes === undefined;
const scopeData = new ScopeData(scopes, undefined, options?.authorizationServer);
const scopeData = new ScopeData(scopes, undefined, options?.authorizationServer, options?.clientId);
// Do NOT use `scopes` beyond this place in the code. Use `scopeData` instead.
this._logger.info('[getSessions]', askingForAll ? '[all]' : `[${scopeData.scopeStr}]`, 'starting');
@@ -200,7 +200,7 @@ export class MsalAuthProvider implements AuthenticationProvider {
}
async createSession(scopes: readonly string[], options: AuthenticationProviderSessionOptions): Promise<AuthenticationSession> {
const scopeData = new ScopeData(scopes, undefined, options.authorizationServer);
const scopeData = new ScopeData(scopes, undefined, options.authorizationServer, options.clientId);
// Do NOT use `scopes` beyond this place in the code. Use `scopeData` instead.
this._logger.info('[createSession]', `[${scopeData.scopeStr}]`, 'starting');
@@ -315,7 +315,7 @@ export class MsalAuthProvider implements AuthenticationProvider {
if (!claims) {
throw new Error('No claims found in authentication challenges');
}
const scopeData = new ScopeData(scopes, claims, options?.authorizationServer);
const scopeData = new ScopeData(scopes, claims, options?.authorizationServer, options?.clientId);
this._logger.info('[getSessionsFromChallenges]', `[${scopeData.scopeStr}]`, 'with claims:', scopeData.claims);
const cachedPca = await this._publicClientManager.getOrCreate(scopeData.clientId);
@@ -338,7 +338,7 @@ export class MsalAuthProvider implements AuthenticationProvider {
// Use scopes if available, otherwise fall back to default scopes
const effectiveScopes = scopes.length > 0 ? scopes : ['https://graph.microsoft.com/User.Read'];
const scopeData = new ScopeData(effectiveScopes, claims, options.authorizationServer);
const scopeData = new ScopeData(effectiveScopes, claims, options.authorizationServer, options.clientId);
this._logger.info('[createSessionFromChallenges]', `[${scopeData.scopeStr}]`, 'starting with claims:', claims);
const cachedPca = await this._publicClientManager.getOrCreate(scopeData.clientId);