# AzureAIProjectToolbox

> **Class** in `langchain_azure_ai`

📖 [View in docs](https://reference.langchain.com/python/langchain-azure-ai/tools/_toolbox/AzureAIProjectToolbox)

Load tools from an Azure AI Foundry Toolbox and use them via MCP.

Azure AI Foundry Toolbox is a managed multi-MCP server that aggregates
multiple configured tools behind a single MCP endpoint. This class wraps
``MultiServerMCPClient`` (from ``langchain-mcp-adapters``) and adds:

- Azure Identity Bearer-token auth via ``get_bearer_token_provider``.
- ``Foundry-Features`` header injection required by the Foundry MCP gateway.
- Graceful OAuth consent-error handling: returns a fallback tool with the
  consent URL instead of raising, so the agent can surface it to the user.
- Automatic tool-schema sanitization for MCP servers that emit incomplete
  JSON Schemas (missing ``properties`` on ``object`` types).
- ``handle_tool_error = True`` on every tool so tool-call failures are
  returned as tool messages rather than propagating ``ToolException``.

Each ``get_tools()`` call is **stateless** — it opens a fresh MCP session,
loads tools, and returns, mirroring ``MultiServerMCPClient.get_tools()``.
``async with`` is supported as a convenience but does not change behavior.

Primary usage::

    from azure.identity import DefaultAzureCredential
    from langchain.chat_models import init_chat_model
    from langchain.agents import create_agent
    from langchain.messages import HumanMessage
    from langchain_azure_ai.tools import AzureAIProjectToolbox

    async def main():
        toolbox = AzureAIProjectToolbox(
            project_endpoint=(
                "https://<resource>.services.ai.azure.com/api/projects/<project>"
            ),
            toolbox_name="my-toolbox",
        )
        tools = await toolbox.get_tools()
        model = init_chat_model("azure_ai:gpt-5.4")
        agent = create_agent(
            model=model.bind_tools(tools),
            tools=tools
        )
        return await agent.ainvoke({"messages": [HumanMessage("What can you do?")]})

You can also rely on environment variables for configuration instead of passing
constructor arguments::

    # Set in the environment / agent.manifest.yaml:
    # FOUNDRY_PROJECT_ENDPOINT=https://<resource>.../api/projects/<project>

    toolbox = AzureAIProjectToolbox(toolbox_name="my-toolbox")
    tools = await toolbox.get_tools()

``async with`` is also accepted (same behavior, returns self)::

    async with AzureAIProjectToolbox(toolbox_name="my-toolbox") as toolbox:
        tools = await toolbox.get_tools()

Toolbox skills are exposed as MCP resources (URIs of the form
``skill://{name}``) and can be loaded as LangChain ``Blob`` objects with
``get_resources`` / ``aget_resources``::

    toolbox = AzureAIProjectToolbox(toolbox_name="my-toolbox")
    skill_blobs = toolbox.get_resources(scheme="skills")
    for blob in skill_blobs:
        backend.write(
            path=f"skills/{blob.source}/SKILL.md",
            content=blob.as_string(),
            encoding="utf-8",
        )

For ``deepagents`` users, ``get_skills`` / ``aget_skills`` removes that
boilerplate by returning a ready-to-use ``files`` mapping for
``create_deep_agent``::

    from deepagents import create_deep_agent
    from deepagents.backends import StateBackend

    toolbox = AzureAIProjectToolbox(toolbox_name="my-toolbox")
    skill_files = toolbox.get_skills()

    agent = create_deep_agent(
        model="azure_ai:gpt-5.2",
        backend=StateBackend(),
        skills=["/skills/"],
    )
    agent.invoke({"messages": [...], "files": skill_files})

## Signature

```python
AzureAIProjectToolbox()
```

## Description

**Note:**

Requires ``langchain-mcp-adapters`` and ``httpx``::

pip install langchain-mcp-adapters httpx

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `project_endpoint` | `unknown` | Yes | Azure AI Foundry project endpoint, e.g. ``https://<resource>.services.ai.azure.com/api/projects/<project>``. Falls back to the ``AZURE_AI_PROJECT_ENDPOINT`` or ``FOUNDRY_PROJECT_ENDPOINT`` environment variables. |
| `toolbox_name` | `unknown` | Yes | Name of the toolbox as configured in Azure AI Foundry. This parameter is required. |
| `api_version` | `unknown` | Yes | Toolbox API version appended to the MCP URL. Defaults to ``"v1"``. |
| `credential` | `unknown` | Yes | Azure credential used to obtain Bearer tokens. Accepts a plain string (static Bearer token), any ``TokenCredential`` such as ``DefaultAzureCredential`` or ``ManagedIdentityCredential``. Defaults to ``DefaultAzureCredential()``. |
| `extra_headers` | `unknown` | Yes | Additional HTTP headers to include in MCP requests. The ``Foundry-Features`` header is automatically added with the default value unless already present in ``extra_headers``. Defaults to ``{}``. |

## Extends

- `BaseModel`

## Properties

- `project_endpoint`
- `toolbox_name`
- `api_version`
- `credential`
- `extra_headers`
- `model_config`
- `toolbox_endpoint`

## Methods

- [`get_tools()`](https://reference.langchain.com/python/langchain-azure-ai/tools/_toolbox/AzureAIProjectToolbox/get_tools)
- [`get_tools_requiring_approval()`](https://reference.langchain.com/python/langchain-azure-ai/tools/_toolbox/AzureAIProjectToolbox/get_tools_requiring_approval)
- [`aget_tools()`](https://reference.langchain.com/python/langchain-azure-ai/tools/_toolbox/AzureAIProjectToolbox/aget_tools)
- [`aget_resources()`](https://reference.langchain.com/python/langchain-azure-ai/tools/_toolbox/AzureAIProjectToolbox/aget_resources)
- [`get_resources()`](https://reference.langchain.com/python/langchain-azure-ai/tools/_toolbox/AzureAIProjectToolbox/get_resources)
- [`aget_skills()`](https://reference.langchain.com/python/langchain-azure-ai/tools/_toolbox/AzureAIProjectToolbox/aget_skills)
- [`get_skills()`](https://reference.langchain.com/python/langchain-azure-ai/tools/_toolbox/AzureAIProjectToolbox/get_skills)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-azure/blob/7a6a664d617264df8dcb12fcfb1bacc09f21d504/libs/azure-ai/langchain_azure_ai/tools/_toolbox.py#L376)