A fully managed platform in Microsoft Foundry for hosting, scaling, and securing AI agents built with any supported framework or model
Hosted agents and Prompt agents currently share the same MCP authentication primitives, but the context only documents OAuth identity passthrough for tools configured in Foundry (Prompt agents and MCP tools added via the portal), not for code-first hosted agents.
From the available documentation:
- OAuth identity passthrough is a tool-level/project-connection feature that Foundry Agent Service drives when a tool is configured with OAuth identity passthrough. On first use, Agent Service generates a consent link (
oauth_consent_request) and, after consent, uses the user’s token to call the MCP server. - This flow is described for MCP tools configured in the Foundry portal and for MCP servers hosted on Azure Functions, where the tool is created with Authentication = OAuth Identity Passthrough and the OAuth app details (client ID/secret, auth URL, token URL, refresh URL, scopes) are provided. After configuration, Foundry gives a redirect URL that must be added to the Entra app registration so Agent Service can complete the OAuth flow.
- The OAuth identity passthrough scope is explicitly “per tool (connection) name per Foundry project,” and the consent link is surfaced by Agent Service in
response.output_itemas anoauth_consent_requestitem when a user first tries to use a new tool. - The docs also state that for MCP servers, the supported auth modes are key-based, Microsoft Entra (agent or project managed identity), and OAuth identity passthrough, all configured as part of the tool/connection definition in Foundry.
The context does not document any of the following for hosted agents:
- A way for container code to bind to or consume a project connection of type “RemoteTool” with OAuth identity passthrough and read the user’s token at runtime.
- A mechanism for hosted agent code to emit an
oauth_consent_requestitem itself or otherwise trigger the same consent-link UX that Agent Service provides automatically for portal-configured tools. - An API that hosted agent code can call to obtain a token on behalf of the caller for an arbitrary audience (such as
api://<custom-app-id>/.default). The documented patterns for MCP auth are:- Key-based (API key / function key) via project connections.
- Microsoft Entra identity using agent identity or project managed identity, where the service requests a token automatically.
- OAuth identity passthrough, driven by Agent Service when the tool is configured that way.
- Any capability to configure the Foundry-managed agent identity (
agentIdentityBlueprint) with additional credentials or to use it as a confidential client for OBO.
The only documented way to get per-user OAuth identity passthrough today is to configure the MCP server as a tool with OAuth identity passthrough in Foundry (for example, via the portal or as an MCP tool definition) and let Agent Service manage the consent flow and token storage. In that model, Agent Service:
- Prompts the user with a consent link on first use of the tool.
- Stores and refreshes the user’s OAuth credentials.
- Uses the user’s token when invoking the MCP server.
For Azure Functions–hosted MCP servers, the documentation explicitly shows how to configure this (client ID/secret, token URL, auth URL, refresh URL, scopes) and notes that OAuth identity passthrough is supported and intended for “production when each user must authenticate with their own identity and user context must be persisted.”
The context does not provide:
- Documentation that hosted agents can directly plug into that OAuth identity passthrough connection model.
- A supported pattern for hosted agents to perform OBO or arbitrary audience token acquisition on behalf of the user.
- Roadmap or interim guidance specific to hosted agents for per-user authorization to downstream MCP servers.
Given the available information, the supported pattern for per-user authorization is:
- Configure the MCP server as an MCP tool in Foundry with OAuth identity passthrough so that Agent Service manages the user consent and token handling.
- Use key-based or Microsoft Entra authentication (agent or project managed identity) when the agent itself, not the end user, should be the security principal.
The context does not state that hosted agents can currently achieve the same per-user OAuth identity passthrough behavior programmatically from inside container code, nor does it describe any API or configuration that would enable the five requested behaviors for hosted agents.
References:
- Set up authentication for Model Context Protocol (MCP) tools
- Connect agents to Model Context Protocol servers (python)
- Connect agents to Model Context Protocol servers (rest)
- Build and register a Model Context Protocol (MCP) server
- Connect an MCP server on Azure Functions to a Foundry Agent Service agent
- Agent tools overview for Foundry Agent Service