Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
/*
* Foundry Toolbox (Server-Side Tools) — Agent Framework Responses agent for C#
*
* Hosted agent that loads a Foundry Toolbox and passes its tools to the agent as
* SERVER-SIDE tools. The Foundry platform handles tool discovery and invocation
* through the Responses API — the agent process does not connect to the toolbox
* MCP proxy or invoke tools locally.
* Hosted agent that consumes a Foundry Toolbox as server-side tools. The Agent
* Framework hosting layer connects to the toolbox's managed MCP proxy at startup,
* discovers its tools, and injects them into every request. Tool calls are brokered
* by the Foundry platform's toolbox proxy, so the agent never hard-codes or locally
* executes the tools.
*
* Required environment variables:
* FOUNDRY_PROJECT_ENDPOINT — Foundry project endpoint (auto-injected in hosted containers)
* AZURE_AI_MODEL_DEPLOYMENT_NAME — Model deployment name (declared in agent.manifest.yaml)
* TOOLBOX_NAME — Name of the Foundry Toolbox to load
*/

#pragma warning disable OPENAI001 // GetToolboxToolsAsync is experimental
#pragma warning disable OPENAI001 // Foundry Toolbox hosting APIs are experimental

using Azure.AI.AgentServer.Core;
using Azure.AI.Projects;
Expand All @@ -35,23 +36,26 @@
var toolboxName = Environment.GetEnvironmentVariable("TOOLBOX_NAME")
?? throw new InvalidOperationException("TOOLBOX_NAME environment variable is not set.");

// Fetch the toolbox's tools from Foundry. Omitting the version resolves the toolbox's
// current default version. The returned AITools are passed directly to the agent as
// server-side tools — Foundry will execute them on the agent's behalf.
var projectClient = new AIProjectClient(projectEndpoint, new DefaultAzureCredential());
var tools = await projectClient.GetToolboxToolsAsync(toolboxName);

AIAgent agent = projectClient
// Create the agent. No toolbox tools are wired up here: the hosting layer supplies them
// at request time (see AddFoundryToolboxes below).
AIAgent agent = new AIProjectClient(projectEndpoint, new DefaultAzureCredential())
.AsAIAgent(
model: deployment,
instructions: "You are a helpful assistant with access to Azure AI Foundry toolbox tools. "
+ "Use the available tools to help answer user questions. Be concise.",
name: "foundry-toolbox-server-side",
description: "Agent with Foundry Toolbox integration using server-side tools.",
tools: [.. tools]);
description: "Agent with Foundry Toolbox integration using server-side tools.");

var builder = AgentHost.CreateBuilder(args);
builder.Services.AddFoundryResponses(agent);

// Register the Foundry Toolbox. At startup the hosting layer connects to the toolbox's
// managed MCP proxy (derived from FOUNDRY_PROJECT_ENDPOINT), discovers its tools, and
// injects them into every request. Tool calls are brokered by the Foundry platform, so
// the agent process does not hard-code or locally execute the toolbox's tools. Omitting a
// version resolves the toolbox's current default version.
builder.Services.AddFoundryToolboxes(toolboxName);

builder.RegisterProtocol("responses", endpoints => endpoints.MapFoundryResponses());

var app = builder.Build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Foundry Toolbox — Server-Side Tools

An agent that loads a Foundry Toolbox and passes its tools to the agent as **server-side tools**. The Foundry platform handles tool discovery and invocation through the Responses API — the agent process does not connect to the toolbox MCP proxy or invoke tools locally.
An agent that consumes a Foundry Toolbox as **server-side tools**. The Agent Framework hosting layer connects to the toolbox's managed MCP proxy at startup, discovers its tools, and injects them into every request. Tool calls are brokered by the Foundry platform's toolbox proxy, so the agent never hard-codes or locally executes the tools.

`GetToolboxToolsAsync()` fetches the tool definitions from the configured toolbox and they are then passed to `AsAIAgent(..., tools: ...)`. At runtime the Foundry platform invokes those tools server-side on the agent's behalf, so the agent container only needs the control-plane call to fetch the definitions — it does not broker MCP connections.
`AddFoundryToolboxes(toolboxName)` registers the toolbox with the hosting layer. At startup the hosting layer connects to the toolbox's managed MCP proxy (derived from `FOUNDRY_PROJECT_ENDPOINT`), lists its tools, and caches them. Every incoming request then has those tools injected automatically, and the Foundry platform executes the tool calls through the proxy. The agent itself declares no toolbox tools.

## Creating a Foundry Toolbox

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
name: foundry-toolbox-server-side-dotnet-agent-framework
displayName: "Foundry Toolbox — Server-Side Tools (.NET, Agent Framework)"
description: >
Agent Framework agent that loads a Foundry Toolbox and passes its tools to the
agent as server-side tools. The Foundry platform executes tool calls through the
Responses API — the agent does not connect to the toolbox MCP proxy locally.
Agent Framework agent that consumes a Foundry Toolbox as server-side tools. The
hosting layer connects to the toolbox's managed MCP proxy at startup and injects its
tools into every request, and the Foundry platform executes the tool calls.
metadata:
tags:
- AI Agent Hosting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

<ItemGroup>
<!-- Agent Framework hosting — provides AgentHost, AddFoundryResponses, MapFoundryResponses,
and the GetToolboxToolsAsync extension on AIProjectClient. -->
<PackageReference Include="Microsoft.Agents.AI.Foundry.Hosting" Version="1.3.0-preview.260423.1" />
and AddFoundryToolboxes for consuming Foundry Toolboxes. -->
<PackageReference Include="Microsoft.Agents.AI.Foundry.Hosting" Version="1.11.0-preview.260623.1" />
<!-- Foundry SDK — provides AIProjectClient and AsAIAgent. -->
<PackageReference Include="Azure.AI.Projects" Version="2.1.0-beta.1" />
<PackageReference Include="Azure.AI.Projects" Version="2.1.0-beta.3" />
<!-- .env file support for local development. -->
<PackageReference Include="DotNetEnv" Version="3.1.1" />
</ItemGroup>
Expand Down
Loading