Skip to main content
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.
In this quickstart, you build a toolbox that combines two tools behind one managed endpoint:
  • 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.
You then consume the toolbox from a hosted agent written in Python. The toolbox exposes one MCP endpoint, so the agent connects to a single URL and discovers every tool at runtime. You can change the tools later without changing agent code.

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.
Follow the prompts to select your project and an existing model deployment. When you’re prompted to Select container resource allocation, choose 1 core, 2Gi memory. The agent’s container image needs more than the default tier. The --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’s azure.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 the TOOLBOX_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

  1. Point the local agent at your toolbox by setting these values in the .env file in src/toolbox-agent. Paste the endpoint you copied in Step 2:
    azd ai agent run injects FOUNDRY_PROJECT_ENDPOINT and reads the .env file for local runs. The sample handles the toolbox connection, headers, and authentication for you.
  2. 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.
  3. 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 your azd environment, which azure.yaml resolves at deploy time. Then build and deploy the agent container:
When the command finishes, the output shows links to the agent playground and the agent endpoint. Invoke the deployed agent:

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

  1. Open Foundry portal and create a Foundry project, or select an existing one.
  2. In the project, deploy a chat-capable model such as gpt-5.4-mini.
  3. 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:
Create a working folder for the deployment scripts. In that folder, create a .env file with these values:

Step 3: Create the toolbox with Python

Create a file named create_toolbox.py in the same working folder as .env:
Run the script:
The sample hosted agent can resolve the toolbox either from 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 named deploy_toolbox_agent.py in the same working folder as .env:
Run the script:
This script uploads the toolbox sample as a new hosted-agent version, points the hosted agent at that version temporarily, invokes it with a Microsoft Learn question, and restores the previous endpoint configuration when it finishes.

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.

Next step

Add a Foundry IQ knowledge base to a hosted agent