-
Notifications
You must be signed in to change notification settings - Fork 5k
Description
Library name and version
Azure.AI.Agents.Persistent 1.2.0-beta.5
Describe the bug
I'm creating an agent linked to a MCP server which requires authentication (a key in the header).
Although the framework allow us to pass this information to the Agent, the information is not honored and the MCP fail with permission denied.
I don't think this kind of authentication should be a directly responsibility of the client (when starting the run), because it breaks encapsulating and forces the client to understand what's underlying the agent.
using Azure.AI.Agents.Persistent;
using Azure.Identity;
using Microsoft.Identity.Client.Platforms.Features.DesktopOs.Kerberos;
Console.WriteLine("Hello, World!");
var mcp_server_url = "https://datasamplemcp.azurewebsites.net/runtime/webhooks/mcp/sse";
var mcp_server_label = "products";
var credential = new InteractiveBrowserCredential();
// Create MCP tool definition
MCPToolDefinition mcpTool = new(mcp_server_label, mcp_server_url);
mcpTool.AllowedTools.Add("list_categories");
mcpTool.AllowedTools.Add("list_products");
mcpTool.AllowedTools.Add("list_productbycategory");
var tools = new List();
tools.Add(mcpTool);
MCPToolResource mcpToolResource = new(mcp_server_label);
mcpToolResource.UpdateHeader("x-functions-key", "Sp1RjYId1RRc8SqHZxeNQg2b6ypIUqR3Mf60W3GPa73bAzFuYdd-TQ==");
mcpToolResource.RequireApproval = new MCPApproval("never");
ToolResources toolResources = mcpToolResource.ToToolResources();
//Create a PersistentAgentsClient and PersistentAgent.
PersistentAgentsClient client = new("https://myfoundyowrc.services.ai.azure.com/api/projects/mytokagentsowrc", credential);
//Give PersistentAgent a tool to execute code using CodeInterpreterToolDefinition.
PersistentAgent agent = client.Administration.CreateAgent(
model: "gpt-4o",
name: "my-mcp-agent",
instructions: "You are an agent capable to use the MCP tools attached to answer questions about products and product categories. You are capable to analyse the data returned in order to answer the questions correctly",
tools: tools,
toolResources: toolResources
);
Console.WriteLine("Agent Created!");
Expected behavior
The agent should hold the authentication and make the connection to the MCP as needed
Actual behavior

Reproduction Steps
Create a MCP Server (I used the extension for azure functions - https://devblogs.microsoft.com/dotnet/build-mcp-remote-servers-with-azure-functions/)
Create the agent linked to the MCP server using a code similar to the one provided
Try to use the agent in the Foundry playground
Environment
No response