Steps at a glance
- Create app registrations
- Configure the identity provider
- Enable agent identity
- Add the MCP server to the gateway
- Grant the agent MCP access
- Point the connector at the gateway
- Update connector authentication to use OAuth2 OBO
Create app registrations
This section creates two kinds of Entra apps for the gateway hop:truefoundry-app: create this once, per tenant or gateway. It is the shared audience for all agents’ connector tokens.agent-client-<slug>: create one per Copilot Studio agent. It is the connector’s OAuth client. Its app ID appears as theazpclaim, which TrueFoundry uses to identify the agent.
az login and uuidgen.
Copilot Studio’s own Entra Agent ID does not appear in connector tokens.
agent-client, but all agents share truefoundry-app:
Create truefoundry-app (shared audience)
If the app already exists, skip this section.
aud claim is api://<TFY_APP>. The gateway accepts those tokens.
- Portal
- Azure CLI
- Go to Entra admin center → App registrations → New registration.
- Name the app
truefoundry-app, choose single tenant, leave the redirect empty, and select Register. Copy the Application (client) ID. This is$TFY_APP. - Go to Expose an API:
- Set the Application ID URI to
api://<TFY_APP>. - Add the scope
access_as_user(Admins and users, Enabled). It is a delegated User scope, not an app role.
- Set the Application ID URI to
- Under Authorized client applications, add
fe053c5f-3692-4f14-aef2-ee34fc081cae(Azure API Connections) withaccess_as_user. - In the manifest, set
api.requestedAccessTokenVersionto2. This makes tokens use the v2 format, which puts the agent’s app ID in theazpclaim. TrueFoundry needsazpto identify the agent. A v1 token doesn’t include it, so agent resolution fails. - Create a client secret for TrueFoundry. It is used for the gateway and MCP Auth Data, not the connector.
- No API permissions are needed here.
agent-clientrequests the refresh token (offline_access).
Without Azure API Connections pre-authorized on
access_as_user, users see an interactive sign-in on every connector call.Create agent-client (one per agent)
This is the connector’s OAuth client. Its app ID appears as the azp claim in tokens and as the agent’s Subject value. Don’t configure Expose an API on this app.
- Portal
- Azure CLI
- Select New registration, name it
agent-client-<slug>, and choose single tenant. - Under Authentication → Web, add the redirect URI
https://global.consent.azure-apim.net/redirect. If the connector’s Security tab shows an extra redirect URI after you create the connector, add it here too. - Under API permissions (Delegated), add
truefoundry-app→access_as_userand Graph →offline_access. Then select Grant admin consent. - Create a client secret for the Power Apps connector. Do not use it in TrueFoundry.
Optional: pre-authorize this
agent-client on truefoundry-app under Authorized client applications. Admin consent is enough on its own. Pre-authorization only reduces extra consent prompts.Configure the identity provider
Tell the gateway which Entra tokens to accept and how to resolve the agent fromazp.
- In TrueFoundry, go to Settings → Security & Access → Identity Providers.
- Open an existing Entra provider, or select Add Identity Provider.
- Set the following fields:
- Under Resolve Token To → agent, set:
Do not put
agent-client IDs in Allowed audiences. They belong in the agent’s Subject value.
For field details, see External JWT.
Enable agent identity
Map each agent’sagent-client so that the inbound azp claim resolves to the agent in TrueFoundry.
- In Agent Registry, open the agent.
- Enable Agent Identity:
- Grant Agent Access to the users or teams the agent may act for. This is required when the acting-on-behalf-of slug claim is set. Assign an owner team as well.
The Subject value must be the
agent-client app ID. It is not truefoundry-app, not the Copilot Studio AgentIdentityId, and not the connector’s display name.Add the MCP server to the gateway
Complete these steps for each MCP server added to the agent.Register the upstream MCP server
Register the MCP HTTPS endpoint in the gateway. The connector calls the gateway URL for this server.If the MCP server is already added to the gateway, skip this section. You still need its gateway URL for the connector step.
- If the MCP server isn’t registered yet, register it. Getting started: MCP Server Getting Started.
- If the MCP server authentication isn’t set yet, open Auth Data and select the method the upstream server expects: API Key, OAuth2, AWS SigV4, or Token Passthrough. See Outbound Authentication to choose.
- Save the MCP server.
- Copy the gateway URL for the server from How To Use section. You need it in the connector step below.
Create a Virtual MCP Server
You need a Virtual MCP Server only if the remote MCP server uses
grant_type: authorization_code. Otherwise, skip this section.- Go to MCP Gateway → Virtual MCP Servers → Create.
- Enter a Name and turn on Best Effort Mode.
- Add the upstream MCP server as a source, and select the tools the agent should see.
- Save, then copy the URL from How To Use section. You use it in Point the connector at the gateway.
Grant the agent MCP access
Registering the server does not authorize tool calls. Grant the agent access to the MCP Server (and Virtual MCP Server) that the connector calls.- In Agent Registry, find the agent.
- Go to ⋯ → Manage Permissions.
- Select Add Permission → MCP Servers, select the role MCP Server User, select the MCP Server, and save.
- Optional: If you created a Virtual MCP Server, repeat step 3 and select the Virtual MCP Server instead.
Point the connector at the gateway
Create a new custom connector for each agent. It points at this server’s gateway URL and uses this agent’sagent-client. Don’t reuse or change another agent’s connector. TrueFoundry identifies the agent from the token’s azp claim, which comes from the connector’s client ID, so a shared connector gives every agent the same identity.
When you build the connector:
- Use the gateway URL for this server. If you created a Virtual MCP Server, use its URL from How To Use.
- Split
https://<gateway-host>/<gateway-path>into swaggerhost=<gateway-host>and path =/<gateway-path>, withbasePath: /. - Build the connector in Power Apps, not in the Copilot Studio MCP wizard.
Keep
basePath: / and put the full path under paths:. If you put the path only in basePath, the import succeeds but the server isn’t registered as an MCP operation, so the tool list stays empty.Create the new gateway connector
- Portal
- Azure CLI / Power Apps API
- Go to Power Apps → Custom connectors → New → Import an OpenAPI file.
- Use this definition:
- Set the Security tab as described in Update connector authentication to use OAuth2 OBO.
- Select Create.
- In Copilot Studio, open the agent and go to Tools → Add a tool → MCP. Search for the new connector, select it and create a connection.
- Test the new connector. If the agent already had an older connector for this server, remove it from the agent. Then select Publish to apply the changes.
- Delete the old connector in Power Apps → Custom connectors only if no other agent uses it.
Update connector authentication to use OAuth2 OBO
Configure the connector so Power Platform issues a token withaud = truefoundry-app and azp = agent-client.
Before you continue, confirm two things:
- Azure API Connections is pre-authorized on
truefoundry-app. agent-clientlists this connector’s redirect URL.
- Portal
- Azure CLI / Power Apps API
- Go to Power Apps → Custom connectors → Security.
- Fill in the table above, then select Update connector.
- If the connector’s Redirect URL is missing from
agent-client, add it. - In Copilot Studio, reconnect (or recreate the connection) so tokens use the new client.
- Check the sign-in prompt. A short consent card means on-behalf-of is on. A full sign-in page means it is still off.
FAQ
What goes in Allowed audiences?
What goes in Allowed audiences?
Only
api://<TFY_APP> and <TFY_APP>. Put each agent-client app ID on the agent as the Subject value, not in Allowed audiences.What goes in Subject value?
What goes in Subject value?
The
agent-client Application (client) ID, which is the value in the token’s azp claim. Don’t use the Copilot Studio AgentIdentityId.Which access token version should truefoundry-app use?
Which access token version should truefoundry-app use?
2. This gives the issuer
login.microsoftonline.com/<tenant_id>/v2.0 and puts the agent identity in azp.Should On-behalf-of login be on?
Should On-behalf-of login be on?
Yes. With it on, users see a short consent card, and user claims flow to the gateway. With it off, users see a full sign-in page.