Skip to content

Improve error message for TenantMismatchError#1737

Merged
anannya03 merged 6 commits intomicrosoft:mainfrom
anannya03:tenant-mismatch-error-message
Feb 18, 2026
Merged

Improve error message for TenantMismatchError#1737
anannya03 merged 6 commits intomicrosoft:mainfrom
anannya03:tenant-mismatch-error-message

Conversation

@anannya03
Copy link
Copy Markdown
Contributor

@anannya03 anannya03 commented Feb 16, 2026

What does this PR do?

Improve error message for TenantMismatchError.

image

GitHub issue number?

#1706

Copy link
Copy Markdown
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 improves the error message displayed when users encounter tenant mismatch authentication errors in the Azure MCP Server. The change addresses issue #1706 where users receive cryptic error messages when their authentication token is from a different Azure tenant than the one required by their subscription.

Changes:

  • Added a new HandleRequestFailedException method to GlobalCommand that detects tenant mismatch errors (401 status with "InvalidAuthenticationTokenTenant" in the message) and provides a more helpful, actionable error message
  • The improved error message guides users to either specify the target tenant in their prompt or configure the AZURE_TOKEN_CREDENTIALS environment variable

Comment thread core/Microsoft.Mcp.Core/src/Commands/GlobalCommand.cs Outdated
Comment thread core/Microsoft.Mcp.Core/src/Commands/GlobalCommand.cs
Comment thread core/Microsoft.Mcp.Core/src/Commands/GlobalCommand.cs Outdated
Comment thread core/Microsoft.Mcp.Core/src/Commands/GlobalCommand.cs Outdated
Comment thread core/Microsoft.Mcp.Core/src/Commands/GlobalCommand.cs Outdated
Comment thread core/Microsoft.Mcp.Core/src/Commands/GlobalCommand.cs
Comment thread core/Microsoft.Mcp.Core/src/Commands/GlobalCommand.cs
@anannya03 anannya03 enabled auto-merge (squash) February 18, 2026 00:49
@anannya03 anannya03 merged commit 9c6476c into microsoft:main Feb 18, 2026
15 checks passed
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in Azure MCP Server Feb 18, 2026
colbytimm pushed a commit to colbytimm/microsoft-mcp that referenced this pull request Apr 20, 2026
* Improve error message for tenantMismatchError

* added null check

* dotnet format

* modified the error message

* dotnet format

* changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants