Skip to main content
A hosted agent runs your code in Foundry Agent Service. In this article, you connect that code to a toolbox so the agent discovers and calls the toolbox tools through one Model Context Protocol (MCP) endpoint. If you use a coding agent like GitHub Copilot, the Microsoft Foundry Skill can help connect the hosted agent to a toolbox endpoint and adapt the sample to your own tools.

Prerequisites

  • A toolbox with at least one tool and a default version.
  • A Microsoft Foundry project with a deployed model.
  • A hosted-agent project. To create the agent and toolbox together, complete the toolbox quickstart.
  • A development identity that can access the Foundry project. Sign in locally with az login or azd auth login before you run a sample.
  • Any permissions required by the services behind the toolbox tools. For tools that use OAuth or Microsoft Entra identity passthrough, review Toolbox authentication before you deploy the agent.

Choose the toolbox endpoint

Use the toolbox consumer endpoint for an agent that should follow the toolbox’s default_version:
When you promote another toolbox version to default, an agent that uses this endpoint gets the new version without an endpoint change or redeployment. Use a version-specific developer endpoint only when you need to test an immutable version before promotion:

Authenticate the agent to the toolbox

The agent authenticates to the toolbox endpoint with its Microsoft Entra identity and the https://ai.azure.com/.default scope. The connection for each toolbox tool determines which identity or credential reaches the downstream service. Don’t put downstream API keys or OAuth tokens in the agent code. Configure those credentials on the project connection that the toolbox tool references. For details about supported authentication types, consent, and role requirements, see Toolbox authentication.

Connect the hosted agent

Enforce tool approval

Each entry returned by MCP tools/list can contain a _meta.tool_configuration.require_approval value: The toolbox MCP endpoint doesn’t block tools/call when require_approval is always. Your agent runtime must enforce the setting before every invocation. A system-prompt instruction alone doesn’t enforce approval. Use require_approval: never unless your runtime can pause the pending tool call, collect the user’s decision, and resume or reject that exact call. To configure the value on a toolbox tool, see Configure tool approval.

Troubleshoot the connection