[BUG] mcp-azuread: Intermittent 403 errors due to missing IP whitelisting

Resolved 💬 2 comments Opened Jan 8, 2026 by wailuen Closed Jan 8, 2026

Bug Description

Users report that Azure AD MCP server is not responding to email queries. The system responds with "I don't have access to your email inbox" instead of fetching emails via Microsoft Graph API.

Environment

Root Cause

The staging API (aihub2-api-staging) calls the MCP Azure AD server (aihub2-mcp-azuread-production) using one of 31 possible outbound IP addresses. Two of these IPs were not whitelisted in the MCP server's IP access restrictions:

| Missing IP | CIDR Added |
|------------|------------|
| 20.205.149.225 | 20.205.149.0/24 |
| 20.247.223.209 | 20.247.223.0/24 |

This caused intermittent 403 errors - requests succeeded when the API used a whitelisted IP, but failed when it randomly selected one of the missing IPs.

Evidence from Logs

Staging API log (03:31:31.766Z):

"Agentic endpoint returned 403 for azure-ad-mcp"

The 403 was returned by Azure Container Apps ingress before reaching the container (no corresponding log entry in MCP server).

Resolution

Added the missing IP ranges to the MCP Azure AD server access restrictions:

az containerapp ingress access-restriction set \
  --name aihub2-mcp-azuread-production \
  --resource-group rg-aihub2 \
  --rule-name "Allow-Staging-Outbound-14" \
  --ip-address "20.205.149.0/24" \
  --action Allow

az containerapp ingress access-restriction set \
  --name aihub2-mcp-azuread-production \
  --resource-group rg-aihub2 \
  --rule-name "Allow-Staging-Outbound-15" \
  --ip-address "20.247.223.0/24" \
  --action Allow

Prevention

Consider using Azure Private Endpoints or VNET integration to avoid managing IP whitelists, as Azure Container Apps can dynamically allocate new outbound IPs.

Labels

  • bug
  • production
  • mcp-azuread

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗