Azure / Azure/azure-sdk-for-python

[BUG] Foundry Hosted Agent cannot use Agent 365 MCP tools through UserEntraToken

Open
#48,264 2 comments 1 reaction 0 assignees View on GitHub
Client customer-reported Hosted Agents needs-team-attention question Service Attention
Dominant language
Python
Stars
5.6k
Forks
3.4k
Avg merge
1d 21h
Merged PRs (30d)
193

Description

- **Package Name**: `azure-ai-agentserver-activity`, `azure-ai-agentserver-core`
- **Package Version**: `azure-ai-agentserver-activity==1.0.0b1`, `azure-ai-agentserver-core==2.0.0b8`
- **Operating System**: Linux container in Microsoft Foundry Hosted Agent
- **Python Version**: 3.13

**Describe the bug**

A Python Foundry Hosted Agent configured as an Agent 365 digital worker cannot initialize a versioned Foundry Toolbox when the toolbox contains Agent 365 MCP connections that use `UserEntraToken` / OAuth identity passthrough.

The hosted agent and agentic user can authenticate to the toolbox endpoint, but `tools/list` fails for the Agent 365 MCP connections with JSON-RPC error `-32007` / `CONNECTION_FAILED`. Toolbox enumeration is all-or-nothing, so unrelated tools in the same toolbox also become unavailable.

The Agent 365 agentic identity itself is valid. From the same hosted runtime, obtaining a downstream token through `get_agentic_user_token` for a scope such as `ea9ffc3e-8a23-4a7d-836d-234d7c7565c1/McpServers.Mail.All` and calling the Agent 365 MCP server directly succeeds.

**To Reproduce**

1. Use a Frontier tenant and create an Agent 365 digital worker hosted in Microsoft Foundry with `ActivityAgentServerHost(digital_worker=True)`.
2. Grant the agent registration an Agent 365 Tools delegated permission such as `McpServers.Mail.All`, then grant tenant admin consent.
3. Create a versioned Foundry Toolbox containing:
- One tool that does not require user identity passthrough.
- An Agent 365 MCP connection, such as the Outlook Mail MCP server, configured with `UserEntraToken` / OAuth identity passthrough.
4. Deploy the Python Hosted Agent and authenticate the toolbox request as its Agent 365 agentic user.
5. Initialize the toolbox or invoke `tools/list`.
6. Observe `-32007` / `CONNECTION_FAILED` for the Agent 365 connection and failure to load every tool in the toolbox.
7. As a control, remove the Agent 365 connection from the toolbox. The remaining toolbox tools load successfully.
8. As a second control, obtain the scoped token with the Agent 365 connection's `get_agentic_user_token` method and call `https://agent365.svc.cloud.microsoft/agents/servers/mcp_MailTools` directly. `tools/list` succeeds.

**Expected behavior**

Foundry Toolbox should support Agent 365 agentic-user token acquisition for Agent 365 MCP connections, or surface the OAuth consent/authentication flow required to complete it. A valid agentic identity with the required delegated scope and admin consent should be able to discover and invoke the MCP tools from a Hosted Agent.

**Additional context**

The current workaround is to keep Agent 365 MCP connections out of the Foundry Toolbox and register each MCP server directly in the hosted application, using `get_agentic_user_token` for its required `McpServers.*.All` scope.

This appears specific to the Hosted Agent and Toolbox identity-passthrough path rather than the Agent 365 MCP servers or agentic identity, because the direct scoped-token path works from the same runtime.

Relevant documentation: https://learn.microsoft.com/en-us/azure/foundry/agents/how-to/mcp-authentication

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.