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.
- Inspect the container runtime environment, such as the Python version, installed packages, or working directory.
- Run scripts and process files in an isolated execution environment.
- Automate tasks that require shell access without exposing your network.
toolboxes.create_version(tools=[...]). You can’t add ShellToolboxTool directly to PromptAgentDefinition(tools=[...]). Instead, the prompt agent accesses the shell tool through an MCPTool that’s configured to connect to the toolbox’s MCP endpoint.
Shell toolbox tool and Responses API shell tool are different tools.Although they have similar names, they’re used in different ways:
ShellToolboxToolis added to a toolbox and accessed by agents through the toolbox’s MCP endpoint.- The Responses API shell tool is provided directly in a Responses API request and doesn’t require a toolbox or MCP endpoint.
Prerequisites
- A Foundry project with a deployed model.
- Azure CLI installed and authenticated:
az login - Python SDK installed at the required minimum version:
pip install "azure-ai-projects>=2.6.0" azure-identity
Create a toolbox with the shell tool
Create a toolbox version that includesShellToolboxTool. Foundry provisions the container environment automatically when you use ToolboxShellContainerAutoEnvironment. Set allow_preview=True on the client because ShellToolboxTool is a preview feature. The tools=[shell_tool] parameter populates the toolbox’s tool list — this list is separate from an agent’s tools list, which accepts only agent-level tools like MCPTool.
ShellToolboxTool supports the following parameters:
Connect a prompt agent to the toolbox
Create a prompt agent that reaches the shell tool throughMCPTool. The agent authenticates to the toolbox MCP endpoint by using an Entra token. After you create the agent version, configure the agent endpoint to route traffic to that version. Replace TOOLBOX_VERSION with the version printed in the previous step.
Send a request and read the output
Send a request to the agent and iterate over the response output items. The Responses API returns structured output items as the model interacts with the MCP server. Two item types are relevant for the shell tool:mcp_list_tools: The MCP server sends the list of available tools at the start of the session. Use this item to confirm that the shell tool is reachable.mcp_call: Each call to the shell tool. The item includes the tool name, the arguments the model passed, the command output, and any error.
Container environment options
Theenvironment parameter on ShellToolboxTool controls how the container is provisioned.
Auto-provisioned container
ToolboxShellContainerAutoEnvironment is the default choice. Foundry provisions and manages the container for you — no container image or registry configuration required.
ToolboxShellContainerAutoEnvironment accepts these optional properties:
The following snippet sets a 4 GB memory limit:
Use an existing container
ToolboxShellContainerReferenceEnvironment lets you point the shell tool at a container you already provisioned. Pass the container’s ID as container_id — that’s the only property this class takes.
Network isolation
The shell tool’s container runs without outbound network access by default. This behavior is documented: when you omitnetwork_policy on ToolboxShellContainerAutoEnvironment, the service defaults to disabled outbound access. This default prevents the shell tool from making outbound calls to arbitrary endpoints and limits the impact of any command the model issues.
The toolbox shell tool currently exposes one network policy class:
ToolboxShellNetworkPolicyDisabled(wire value `“disabled”“): Disables outbound network access from the container. This policy matches the service default.
Unlike the code-interpreter container policy, the toolbox shell tool doesn’t offer an allowlist option.
"disabled" is the only available network policy.