* Bump HostedAgents samples to AgentFramework beta.11 and pass credential to UseFoundryTools Update all 8 HostedAgents samples: - Azure.AI.AgentServer.AgentFramework -> 1.0.0-beta.11 - Microsoft.Agents.AI.OpenAI -> 1.0.0-rc4 - Microsoft.Agents.AI/AzureAI/Workflows -> 1.0.0-rc4 - Azure.AI.Projects -> 2.0.0-beta.1 - Fix Workflow.AsAgent() -> AsAIAgent() in FoundryMultiAgent - Pass credential to UseFoundryTools in AgentWithTools (resolves #56802) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove AgentWithTools sample (UseFoundryTools no longer supported) Remove the AgentWithTools hosted agent sample as the UseFoundryTools backend is no longer supported. Updated HostedAgents README and solution file to remove all references. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix AgentWithHostedMCP: downgrade Azure.AI.OpenAI to 2.8.0-beta.1 for rc4 compatibility Azure.AI.OpenAI 2.9.0-beta.1 has breaking changes (GetResponsesClient no longer accepts deployment name, ResponsesClient.Model removed) that are incompatible with Microsoft.Agents.AI.OpenAI rc4. Pin to 2.8.0-beta.1 and use GetResponsesClient(deploymentName).AsAIAgent() pattern. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
What this sample demonstrates
This sample demonstrates how to use a Hosted Model Context Protocol (MCP) server with an AI agent. The agent connects to the Microsoft Learn MCP server to search documentation and answer questions using official Microsoft content.
Key features:
- Configuring MCP tools with automatic approval (no user confirmation required)
- Filtering available tools from an MCP server
- Using Azure OpenAI Responses with MCP tools
For common prerequisites and setup instructions, see the Hosted Agent Samples README.
Prerequisites
Before running this sample, ensure you have:
- An Azure OpenAI endpoint configured
- A deployment of a chat model (e.g., gpt-4o-mini)
- Azure CLI installed and authenticated
Note: This sample uses DefaultAzureCredential for authentication, which probes multiple sources automatically. For local development, make sure you're logged in with az login and have access to the Azure OpenAI resource.
Environment Variables
Set the following environment variables:
# Replace with your Azure OpenAI endpoint
$env:AZURE_OPENAI_ENDPOINT="https://your-openai-resource.openai.azure.com/"
# Optional, defaults to gpt-4o-mini
$env:AZURE_OPENAI_DEPLOYMENT_NAME="gpt-4o-mini"
How It Works
The sample connects to the Microsoft Learn MCP server and uses its documentation search capabilities:
- The agent is configured with a HostedMcpServerTool pointing to
https://learn.microsoft.com/api/mcp - Only the
microsoft_docs_searchtool is enabled from the available MCP tools - Approval mode is set to
NeverRequire, allowing automatic tool execution - When you ask questions, Azure OpenAI Responses automatically invokes the MCP tool to search documentation
- The agent returns answers based on the Microsoft Learn content
In this configuration, the OpenAI Responses service manages tool invocation directly - the Agent Framework does not handle MCP tool calls.