foundry-mcp-auth-whoami-demo
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Foundry MCP auth demo: who does the tool see?
A tiny MCP server with one tool, whoami. It validates a real Microsoft Entra access token and tells
the caller what it sees: a user or only an application. That is the practical difference between
the MCP authentication methods in Microsoft Foundry.
Method in Foundry | What the MCP server sees |
Key based | A shared secret, no person |
Microsoft Entra, agent identity | An application, no person |
Microsoft Entra, project managed identity | An application, no person |
OAuth identity passthrough | The signed in user |
Source for the table: Set up authentication for MCP tools.
Run it locally with Docker (OrbStack) and your az login
az login # once
scripts/try_with_az.sh # builds, starts, calls as your az user, stopsOr step by step:
export TENANT_ID=$(az account show --query tenantId -o tsv)
docker compose up -d --build
uv run scripts/call_whoami.py user # token of your az account, expect callerType "user"
docker compose downFor the application side set AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET of a service
principal you already have and run uv run scripts/call_whoami.py app. Expect callerType application.
Identifiers are masked by default. Set MASK_IDENTIFIERS=false to see full values, and mask them again
before you publish a screenshot.
Related MCP server: mcp-keycloak
Tests
uv run pytestThe tests sign their own tokens, so they need no tenant and no network. They cover missing, garbage, expired, wrong audience, wrong tenant and wrongly signed tokens, plus the user and application cases.
Settings
Variable | Meaning | Default |
| Tenant whose tokens are accepted | required |
| Comma separated accepted | required |
| URL of the MCP endpoint |
|
| Mask ids and user names in the answer |
|
| Host headers to allow when it runs behind a real host name | localhost only |
| App role (or scope) a valid token must also carry, otherwise | off |
| Comma separated header names whose values appear in the audit line (experiments only, never credentials) | off |
| Client ID of the API app, for the on-behalf-of exchange (post 5) | off |
| Secret of the API app, keep it in a Container Apps secret | off |
|
| off |
| Override the key endpoint, for tests | tenant default |
On-behalf-of exchange (optional)
With OBO_CLIENT_ID, OBO_CLIENT_SECRET and OBO_TARGETS set, the server has a second tool,
whoami_downstream(target). It trades the incoming user token for one aimed at a downstream API
(Entra on-behalf-of, the jwt-bearer grant, not RFC 8693) and describes the new token: audience, scopes,
whether it is still the same user and whether an actor claim is present. The new token itself is never returned
or logged. Only the target names from OBO_TARGETS are accepted, never a scope chosen by the caller.
The demo reads the new token without validating it. A real service must not depend on that.
Read this before you reuse it
For the local test the accepted audience is the Azure Resource Manager (
https://management.azure.com), becauseazcan mint that token without an app registration. That is fine for a toy on your laptop. In a real deployment setAUDIENCESto your own API. Never accept tokens that were issued for another service.The Foundry docs say Agent Service blocks Microsoft audience tokens to custom MCP servers (
Cannot pass Microsoft token to untrusted MCP endpoint). Use your own app registration and an audience you control.Agent Service only reaches remote MCP endpoints. To try this server from a Foundry agent, host it on a public HTTPS endpoint such as Azure Container Apps. That is not part of this demo.
The server never logs or returns the token itself.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Prove end users to agents and apps: login-links, OIDC clients, and API keys over remote MCP
Prove end users to agents and apps: login-links, OIDC clients, and API keys over remote MCP
Remote MCP for A2A caller identity, scope policy, verdict receipts, and audit history.
The Stytch MCP server is a reference implementation that demonstrates remote MCP server authentication and authorization using Stytch Connected Apps. It provides OAuth 2.1-compliant authorization (including PKCE), Dynamic Client Registration, and validates Stytch-issued access tokens to enable AI agents to securely interact with external services through permissioned access, supporting scopes like openid, email, profile, and manage:project_data.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceImplements the on-behalf-of flow with Entra ID to enable authorized calls to Microsoft Graph API via MCP tools.9-
- FlicenseNot gradedqualityDmaintenanceEnables secure MCP tool calls (add and multiply numbers) by validating OAuth2 tokens via Keycloak token introspection.-
- AlicenseNot gradedqualityDmaintenanceEnables MCP clients to fetch the signed-in Microsoft Entra user's profile from Microsoft Graph via the GET /me endpoint using the provided bearer token.Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients to exchange an MCP-audience token for a Microsoft Graph token and call Graph as the signed-in user, with tools for identity verification and recent mail access.MIT