Skip to content

Accept both client ID and application ID URI as valid audiences#249

Merged
dkhalife merged 1 commit intomainfrom
accept_aud_cid
Mar 21, 2026
Merged

Accept both client ID and application ID URI as valid audiences#249
dkhalife merged 1 commit intomainfrom
accept_aud_cid

Conversation

@dkhalife
Copy link
Owner

@dkhalife dkhalife commented Mar 21, 2026

Problem

VS Code's MCP client acquires tokens from Entra using the app registration's Client ID as the resource identifier, so Entra stamps that GUID as the aud claim. The MCP server only accepted api://task-wizard (the Application ID URI), causing all requests to fail with:

IDX10214: Audience validation failed. Audiences: ''. Did not match: validationParameters.ValidAudience: 'api://'

Fix

  • Added TW_ENTRA_CLIENT_ID environment variable
  • Changed ValidAudience to ValidAudiences accepting both api://<app-name> and the Client ID GUID

Copilot AI review requested due to automatic review settings March 21, 2026 04:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the MCP server’s Entra JWT audience validation to accept access tokens whose aud claim is either the Application ID URI (e.g. api://task-wizard) or the app registration’s Client ID GUID—matching how VS Code’s MCP client requests tokens.

Changes:

  • Read TW_ENTRA_CLIENT_ID at startup and validate it is set.
  • Switch JWT validation from ValidAudience to ValidAudiences to allow both the configured audience and client ID.

@dkhalife dkhalife merged commit 67babb2 into main Mar 21, 2026
10 checks passed
@dkhalife dkhalife deleted the accept_aud_cid branch March 21, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants