Skip to content

.NET: [Bug]: OAuth MCP Tool Consent Required Flow not supported by toolbox for Hosted Agents #6562

Description

@bilal-fj

Description

When using a Foundry Toolbox with an MCP tool configured for OAuth identity passthrough within a hosted agent, the toolbox fails to connect as the tool raises a CONSENT_REQUIRED error. This link is not surfaced within the Foundry Portal (however is shown in the logs) or when consuming the agent via

ProjectResponsesClient projectResponsesClientEP = aiProjectClient.GetProjectOpenAIClient().GetProjectResponsesClientForAgentEndpoint(agentName); 

raises a session_not_ready error.

The current Agent Framework sample for Tool Box Auth (Hosted-Toolbox/AuthPaths) does not appear to handle this flow explicitly.

Code Sample

Error Messages / Stack Traces

info: Azure.AI.AgentServer.Responses.Internal.ResponsesStartupLogger[0]
      Responses protocol configuration: StorageProvider=InMemoryResponsesProvider DefaultModel=(not set) DefaultFetchHistoryCount=100 EventStreamTtl=00:10:00
info: Microsoft.Agents.AI.Foundry.Hosting.FoundryToolboxService[0]
      Connecting to toolbox 'ToolboxName' at [project-endpoint].
fail: Microsoft.Agents.AI.Foundry.Hosting.FoundryToolboxService[0]
      Failed to connect to toolbox 'ToolboxName'. Tools from this toolbox will not be available.
      ModelContextProtocol.McpProtocolException: Request failed (remote): tools/list failed for 1 tool source(s), succeeded for 0 tool source(s) {"errors":[{"name":"ToolName","type":"mcp","error":{"code":"CONSENT_REQUIRED","message":"https://logic-swedencentral-001.consent.azure-apihub.net/login?data=[redacted]"}}]}
         at ModelContextProtocol.McpSessionHandler.SendRequestAsync(JsonRpcRequest request, CancellationToken cancellationToken)
         at ModelContextProtocol.McpSession.SendRequestAsync[TParameters,TResult](String method, TParameters parameters, JsonTypeInfo`1 parametersTypeInfo, JsonTypeInfo`1 resultTypeInfo, RequestId requestId, CancellationToken cancellationToken)
         at ModelContextProtocol.Client.McpClient.ListToolsAsync(RequestOptions options, CancellationToken cancellationToken)
         at Microsoft.Agents.AI.Foundry.Hosting.FoundryToolboxService.OpenToolboxAsync(String toolboxName, String version, CancellationToken cancellationToken)
         at Microsoft.Agents.AI.Foundry.Hosting.FoundryToolboxService.StartAsync(CancellationToken cancellationToken)
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: Samples\Hosted-Toolbox

Package Versions

Azure.AI.Projects: 2.1.0-beta.3, Azure.AI.Projects.OpenAI: 2.0.0-beta.1, Azure.Identity: 1.21.0, DotNetEnv: 3.2.0, Microsoft.Agents.AI: 1.10.0, Microsoft.Agents.AI.Foundry: 1.10.0-preview.260610.1, Microsoft.Agents.AI.Foundry.Hosting: 1.10.0-preview.260610.1

.NET Version

.NET 10

Additional Context

No response

Metadata

Metadata

Assignees

Labels

.NETUsage: [Issues, PRs], Target: .NetreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow

Type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions