What you are setting up
Prerequisites
- A Microsoft Foundry project with at least one agent, and permission to create app registrations in the same Entra tenant.
- An MCP server running in your Azure subscription that validates Entra JWTs. To write one, see Create an OAuth MCP server with Azure Entra.
- Azure CLI signed in to the tenant (
az login), plusjqanduuidgenfor the commands below. - Entra registered as an identity provider in TrueFoundry. See Identity Providers.
- An MCP Server Group in TrueFoundry. See MCP Gateway getting started.
Mapping an Entra Agent ID to a TrueFoundry agent
When you create an agent in Foundry, Entra mints an agent identity for it — a service principal that represents that agent, governed by an agent identity blueprint. Find its object ID in the Azure portal on your project or agent resource, under JSON view. To make the gateway aware of that agent, create an entry in the Agent Registry:- Scope tool access per agent — which MCP servers, and which tools on them, this agent may call.
- Control who it may act for — in on-behalf-of mode, which users this agent is allowed to represent.
- Attribute every call — the audit trail records the agent, not just the application that authenticated.
- Apply guardrails and limits per agent rather than per credential.
The blueprint, and governing agents as a class
Every agent identity is created from an agent identity blueprint — the governing template for a class of agents. Foundry provisions one for your project and creates each agent identity from it. The blueprint holds the credentials; the agent identities themselves hold none, which is why an agent identity cannot be used as a sign-in client. The blueprint is where class-level controls apply:- Conditional Access policies applied to the blueprint cover every agent created from it.
- Disable or revoke once to affect the whole class, rather than chasing individual agents.
- Audit and inventory agents by class as their number grows.
xms_par_app_azp claim. That gives you a tier-level check independent of any individual agent: a gateway policy or an MCP server can require that a caller was minted from your blueprint, rather than accepting any agent identity that happens to exist in the tenant.
The blueprint ID appears alongside the agent identity in the same JSON view on your project or agent resource. It is also what authorizes your agents against the agent-service audience in the first place — see step 5 of Part 1.
App registrations you need
Foundry creates the agent identity and its blueprint for you. You create the rest in Entra.agent-service, using its client secret. There is no TrueFoundry application registration in your tenant.Choosing between client credentials and on-behalf-of
Part 1: Client credentials
The agent authenticates with its own Entra agent identity. No user is involved, and the MCP server authorizes the call on an application permission.Create the two application registrations
Configure agent-service with an identifier URI, v2 tokens, and a scope
api://$AGENT_SVC as an audience anywhere else.Expose the application permission on mcp-api
Grant the permission to agent-service and admin-consent it
Authorize your agents on agent-service, through the blueprint
agent-service only if that audience authorizes it. List your blueprints, then pre-authorize them:AADSTS82014. Authorization is granted once at the class level, on the blueprint, and every agent identity created from it inherits the grant. Add an agent to the project later and it works with no further Entra change.This is the tier-level control in practice: the blueprint decides which agents may obtain a token for your agent tier at all, while the permission granted in the previous step decides what the gateway may then do downstream. The two are independent, and you need both.Give the gateway a credential
Configure the Foundry MCP connection
api://$AGENT_SVC, and the server URL to your TrueFoundry MCP Gateway URL.Register the MCP server in TrueFoundry
- Inbound: your Entra identity provider.
- Outbound: OAuth2 → Microsoft Entra → Client Credentials, with the
agent-serviceclient ID and secret, and scopeapi://$MCP_API/.default.
client_secret as a TrueFoundry Secret FQN rather than a raw value.Register the agent in TrueFoundry
What your MCP server receives
Tool.Invoke in roles.
What you can enforce
Part 2: On-behalf-of
A signed-in user consents once, and the agent then calls tools with that user’s delegated permissions. The token carries both the user and the agent, so the gateway can attribute and authorize on both.azp — the OAuth client that obtained the token. This is why on-behalf-of needs its own agent-client registration.
Part 2 builds on Part 1: complete steps 1 through 6 above first, then continue here.
Expose a delegated scope on mcp-api
Create the agent-client registration
Give agent-client its delegated permissions and consent them
offline_access is what yields a refresh token. Without it the user is re-prompted every time the access token expires.Pre-authorize agent-client on agent-service
Grant agent-service the delegated scope on mcp-api
Configure the Foundry MCP connection
agent-client ID and secret, and your tenant’s v2.0 endpoints:agent-service — your own registration — this is the supported shape.Register the MCP server in TrueFoundry
agent-service client ID and secret, and scopes api://$MCP_API/Tool.Write offline_access.For the full field reference on this auth type, see Microsoft Entra On-Behalf-Of for MCP.client_secret as a TrueFoundry Secret FQN rather than a raw value.Register the agent in TrueFoundry
agent-service / agent-client pair: agent-client is the OAuth client that signs the user in and therefore lands in azp, and agent-service is the audience it targets and the credential that performs the downstream exchange. Between them the pair stands in for the Foundry agent — one half naming it on the way in, the other acting for it on the way out.agent-client for delegated calls. Give them matching owners so the two legs of the same agent stay attributable to one team.What your MCP server receives
Tool.Write in scp. The user is in the standard claims — use oid as the stable key rather than sub, which is unique per application.
What you can enforce
Comparison, limits, and scale
One limit worth knowing
A single Entra token cannot carry both an end user and an Entra agent identity. Agent identities appear only in application tokens, where there is no user; a delegated token names its agent throughazp, which is an ordinary application registration.
If you need both, run the modes side by side — the gateway records the agent on every call in either case, so the two legs can be correlated in the audit trail.
Scaling to many agents
Point every agent at the sameagent-service audience. The audience identifies the tier of callers, while each agent is still distinguished by its own identity in the token, so the number of gateway registrations stays proportional to your MCP servers rather than to your agents. Adding an agent means one Agent Registry entry, not a new application registration.
Troubleshooting
Most failures in this chain surface a hop or two away from their cause.Next steps
- Restrict which tools an agent sees: MCP tool management
- Understand the governance model behind this setup: Agent Governance with Microsoft Entra
- Apply content and behavior policy per agent: Agent guardrails
- Trace and audit agent tool calls: Agent observability