Items marked (preview) in this article are currently in public preview. This preview is provided without a service-level agreement, and we don’t recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
- Web search, which grounds responses in real-time public web results.
- The Microsoft Learn MCP server, which grounds responses in official Microsoft documentation. It’s a public endpoint that requires no authentication.
Prerequisites
This quickstart builds on the hosted-agent toolchain. Complete the Prerequisites in the hosted agent quickstart first, which cover the Azure subscription, project roles, Python, the Azure Developer CLI (azd), and the microsoft.foundry extension.
Step 1: Initialize the hosted agent
Initialize a hosted agent from the Foundry toolbox sample, which connects to a toolbox over MCP and exposes its tools to the model. You create the toolbox (my-toolbox) in the next step and point the agent at its endpoint. Run these commands in an empty directory.
--src flag scaffolds the agent into src/toolbox-agent.
Agent manifests (
agent.manifest.yaml) and standalone agent definitions (agent.yaml) are deprecated. As of the Foundry azd extensions (azure.ai.agents 1.0.0-beta.1), all hosted agent configuration lives in a single azure.yaml. See Author azure.yaml for hosted agents.Step 2: Create the toolbox
Create the toolbox, and then copy the MCP endpoint it returns. Set that endpoint as an environment variable in later steps. The sample’sazure.yaml defines the toolbox as an azure.ai.toolbox service and wires it to the hosted agent service with uses:. If you change the toolbox configuration, edit the toolbox service in azure.yaml, not src/toolbox-agent/agent.yaml.
First, point the toolbox commands at the Foundry project you selected during initialization. Reuse the endpoint that initialization already stored in your azd environment:
Step 3: Provision Azure resources
The agent reads the toolbox’s MCP endpoint from theTOOLBOX_ENDPOINT environment variable, which azure.yaml resolves from your azd environment. You set that value in the next steps. Provision the agent’s Azure resources:
Step 4: Run the agent locally
-
Point the local agent at your toolbox by setting these values in the
.envfile insrc/toolbox-agent. Paste the endpoint you copied in Step 2:azd ai agent runinjectsFOUNDRY_PROJECT_ENDPOINTand reads the.envfile for local runs. The sample handles the toolbox connection, headers, and authentication for you. -
Start the agent:
This command creates a virtual environment, installs dependencies, and serves the agent on
http://localhost:8088. Preview packages can produce pip warnings during setup. These warnings are nonblocking. -
In a separate terminal, send prompts that exercise the tools:
Step 5: Deploy to Foundry Agent Service
Store the endpoint you copied in Step 2 in yourazd environment, which azure.yaml resolves at deploy time. Then build and deploy the agent container:
Python SDK path
Use the following steps if you want to create the toolbox and deploy the hosted-agent version by using the Python SDK instead of the Azure Developer CLI or VS Code flow.1. Create or choose a Foundry project
- Open Foundry portal and create a Foundry project, or select an existing one.
- In the project, deploy a chat-capable model such as
gpt-5.4-mini. - Copy the project endpoint from Overview and the deployment name from Build > Deployments.
2. Download the toolbox hosted-agent sample
Clone the Foundry samples repo:.env file with these values:
Step 3: Create the toolbox with Python
Create a file namedcreate_toolbox.py in the same working folder as .env:
TOOLBOX_ENDPOINT
or from FOUNDRY_PROJECT_ENDPOINT plus TOOLBOX_NAME. This path uses
TOOLBOX_NAME, so you don’t need to store the versioned endpoint in .env.
4. Deploy the hosted agent with Python
Create a file nameddeploy_toolbox_agent.py in the same working folder as
.env:
5. Verify the toolbox-backed response
If you configure the toolbox correctly, the response shows that the hosted agent discovered the toolbox tools and answered by using Microsoft Learn documentation.Clean up resources
Delete the resources when you’re finished so you stop incurring charges.Troubleshooting
What you learned
In this quickstart, you:- Built a toolbox that combines web search and the Microsoft Learn MCP server behind one endpoint.
- Consumed the toolbox from a Python hosted agent that connects over the Model Context Protocol by using Azure Developer CLI or the Python SDK.
- Ran the agent locally or validated it remotely and deployed it to Foundry Agent Service.