chore: import upstream snapshot with attribution
CodeQL / Analyze (csharp) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:39:25 +08:00
commit db620d33df
5151 changed files with 925932 additions and 0 deletions
@@ -0,0 +1,6 @@
agent.manifest.yaml
agent.yaml
.env.example
.env
toolbox.yaml
./scripts
@@ -0,0 +1,7 @@
.venv
__pycache__
*.pyc
*.pyo
*.pyd
.Python
.env
@@ -0,0 +1,3 @@
FOUNDRY_PROJECT_ENDPOINT="..."
AZURE_AI_MODEL_DEPLOYMENT_NAME="..."
TOOLBOX_ENDPOINT="..."
@@ -0,0 +1,18 @@
FROM python:3.12-slim
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY . user_agent/
WORKDIR /app/user_agent
RUN if [ -f requirements.txt ]; then \
pip install -r requirements.txt; \
else \
echo "No requirements.txt found"; \
fi
EXPOSE 8088
CMD ["python", "main.py"]
@@ -0,0 +1,275 @@
# Agent with Foundry Toolbox (Responses Protocol)
An [Agent Framework](https://github.com/microsoft/agent-framework) agent that uses **Foundry Toolbox** for tool discovery, hosted on Microsoft Foundry using the **Responses protocol**. Foundry Toolbox is a managed tool registry in Microsoft Foundry that lets you define tools centrally and share them across agents.
## Creating a Foundry Toolbox
You can create a Foundry Toolbox by code. Refer to this sample for an example: [Foundry Toolbox CRUD Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-projects/samples/hosted_agents/sample_toolboxes_crud.py).
You can also create a Foundry Toolbox in the Foundry portal. Read more about it [in the Foundry toolbox documentation](https://learn.microsoft.com/en-us/azure/foundry/agents/how-to/tools/toolbox).
This sample consumes a toolbox over its MCP endpoint. It bundles a [`toolbox.yaml`](toolbox.yaml) that defines 6 tools behind one endpoint:
- **Web search**, which grounds responses in real-time public web results.
- **Code interpreter**, which executes Python code in a secure sandbox and returns the output.
- **Azure Specs MCP**, which demonstrates connecting to an MCP server that doesn't require authentication.
- **GitHub MCP**, which demonstrates connecting to the GitHub MCP server using either a Personal Access Token (PAT) or OAuth2 (switch by changing the `project_connection_id` in `toolbox.yaml`).
- **Azure Language MCP with agent identity**, which demonstrates connecting to the Azure Language MCP server using agent identity for authentication.
- **Microsoft Foundry MCP with Entra pass-through**, which demonstrates connecting to the Microsoft Foundry MCP server using Entra pass-through for authentication.
### Authentication Methods
You can connect to MCP servers in Foundry Toolbox that use different authentication methods. This sample demonstrates the following authentication methods:
- [**No authentication**](https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/SUPPORTED_TOOLBOX_SCENARIOS.md#5-mcp-no-auth): The tool does not require any authentication. The agent can invoke the tool without providing any credentials. Sample MCP server: `https://gitmcp.io/Azure/azure-rest-api-specs`
- [**Key-based authentication**](https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/SUPPORTED_TOOLBOX_SCENARIOS.md#4-mcp-key-auth-github): The tool requires a key to authenticate. Sample MCP server: `https://api.githubcopilot.com/mcp` (GitHub MCP server) with a Personal Access Token (PAT) for authentication.
- [**OAuth2 authentication (managed)**](https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/SUPPORTED_TOOLBOX_SCENARIOS.md#6-mcp-oauth-managed-connector): The tool requires OAuth2 to authenticate. Sample MCP server: `https://api.githubcopilot.com/mcp` (GitHub MCP server) with OAuth2 for authentication.
- [**Agent identity authentication**](https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/SUPPORTED_TOOLBOX_SCENARIOS.md#8-mcp-agent-identity): The tool requires an agent identity token to authenticate. Sample MCP server: `https://{foundry-resource-name}.cognitiveservices.azure.com/language/mcp?api-version=2025-11-15-preview` ([Azure Language MCP server](https://learn.microsoft.com/en-us/azure/ai-services/language-service/concepts/foundry-tools-agents#azure-language-mcp-server-preview)) with agent identity for authentication.
- [**Entra Pass-through authentication**](https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/SUPPORTED_TOOLBOX_SCENARIOS.md#13-mcp-oauth-entra-passthrough): The tool requires an Entra pass-through token to authenticate; Foundry forwards the calling user's Entra token to the MCP server. Sample MCP server: the [Microsoft Foundry MCP server](https://learn.microsoft.com/en-us/azure/foundry/mcp/get-started?view=foundry&tabs=user), which exposes Foundry model-catalog, evaluation, agent, and session tools and requires only that the caller have access to the Foundry project (no extra license).
There are also Non-MCP tools in the toolbox that support different authentication methods. Learn more at the [Foundry sample repository](https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/SUPPORTED_TOOLBOX_SCENARIOS.md).
### Finding the Entra audience for an MCP server
An Entra pass-through connection requires an **audience** — the Entra resource that the MCP server validates tokens against. For the Microsoft Foundry MCP server (`https://mcp.ai.azure.com`), read it from the server's OAuth protected-resource metadata:
```bash
curl https://mcp.ai.azure.com/.well-known/oauth-protected-resource
```
```jsonc
{
"resource": "https://mcp.ai.azure.com",
"authorization_servers": ["https://login.microsoftonline.com/common/v2.0"],
"scopes_supported": ["https://mcp.ai.azure.com/Foundry.Mcp.Tools"]
}
```
Use the `resource` value (`https://mcp.ai.azure.com`) as the audience.
> For connector-backed MCP servers (for example Microsoft 365 / WorkIQ servers such as Outlook Mail), the audience is instead published in the Foundry Tools Catalog. Look it up with the helper scripts in [`scripts/`](scripts/): run `./scripts/list-foundry-connectors.ps1 -ConnectorName <name>` (or `./scripts/list-foundry-connectors.sh -n <name>`) and read `AzureActiveDirectoryResourceId` (equivalently `resourceUri`) under `properties.x-ms-connection-parameters`. Run the script with no connector name to list every connector with its name, title, and auth type.
### Creating Connections
Before creating the toolbox, create project connections for any tools that require authentication. The connection defines the authentication details and credentials for the tool, and the toolbox references the connection to authenticate tool invocations at runtime. The following connections are needed for this sample (used in `toolbox.yaml`):
For `ghmcppat`, run the following command to create a PAT-based connection to the GitHub MCP server:
```powershell
azd ai connection create ghmcppat --kind remote-tool --target https://api.githubcopilot.com/mcp --auth-type custom-keys --custom-key "Authorization=Bearer <github_pat>" -p https://<account>.services.ai.azure.com/api/projects/<project>
```
For `ghmcpoauth`, create an OAuth2-based connection to the GitHub MCP server:
```powershell
azd ai connection create ghmcpoauth --kind remote-tool --target https://api.githubcopilot.com/mcp --auth-type oauth2 --connector-name foundrygithubmcp -p https://<account>.services.ai.azure.com/api/projects/<project>
```
> This sample uses `ghmcppat` by default, but you can switch to `ghmcpoauth` in the `toolbox.yaml` file.
For `langmcpconn`, create an agent-identity-based connection to the Azure Language MCP server:
```powershell
azd ai connection create langmcpconn --kind remote-tool --target https://<language-service>.cognitiveservices.azure.com/language/mcp?api-version=2025-11-15-preview --auth-type project-managed-identity --audience https://cognitiveservices.azure.com/ -p https://<account>.services.ai.azure.com/api/projects/<project>
```
For `foundrymcpconn`, create an Entra pass-through connection to the Microsoft Foundry MCP server:
```powershell
azd ai connection create foundrymcpconn --kind remote-tool --target https://mcp.ai.azure.com --auth-type user-entra-token --audience https://mcp.ai.azure.com -p https://<account>.services.ai.azure.com/api/projects/<project>
```
### Creating the toolbox
You create the toolbox once from `toolbox.yaml`, then copy the versioned MCP endpoint it prints into the `TOOLBOX_ENDPOINT` environment variable. The agent connects to that endpoint at runtime.
```powershell
azd ai toolbox create agent-tools --from-file ./toolbox.yaml --project-endpoint https://<account>.services.ai.azure.com/api/projects/<project>
```
## How it works
### Model Integration
The agent uses `FoundryChatClient` from the Agent Framework to create an OpenAI-compatible Responses client. It connects to the toolbox's MCP endpoint via `MCPStreamableHTTPTool`, which discovers and invokes the toolbox's tools over MCP at runtime. The agent resolves the endpoint from the `TOOLBOX_ENDPOINT` environment variable. If that variable isn't set, it builds the unversioned (default-version) endpoint from `FOUNDRY_PROJECT_ENDPOINT` and `TOOLBOX_NAME`.
See [main.py](main.py) for the full implementation.
## Running the agent
### Option 1: Azure Developer CLI (`azd`)
#### Prerequisites
1. **Azure Developer CLI (`azd`)** — [Install azd](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd) (1.25 or later)
2. Install the unified Foundry CLI extension bundle (provides `azd ai agent`, `connection`, `inspector`, `project`, `routine`, `skill`, and `toolbox`):
```bash
# If you previously installed individual extensions, uninstall them first:
# azd ext uninstall azure.ai.agents
# azd ext uninstall azure.ai.toolboxes
azd ext install microsoft.foundry
```
3. Authenticate:
```bash
azd auth login
```
#### Initialize the agent project
No cloning required. Create a new folder and initialize from the manifest:
```bash
mkdir my-toolbox-agent && cd my-toolbox-agent
azd ai agent init -m https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/agent-framework/responses/04-foundry-toolbox/agent.manifest.yaml
```
Follow the prompts to configure your Foundry project and model deployment. If you don't have an existing Foundry project, `azd ai agent init` will guide you through creating one. Initializing also sets the selected project as the active project for the `azd ai` commands that follow.
#### Create the toolbox with `azd ai`
> [!TIP]
> If you use GitHub Copilot for Azure to scaffold a hosted agent that consumes this toolbox, the following skill references describe the same endpoint contract (env var, headers, MCP protocol, citation patterns, and troubleshooting) that the agent must implement:
>
> - [Toolbox reference](https://github.com/microsoft/GitHub-Copilot-for-Azure/blob/main/plugin/skills/microsoft-foundry/foundry-agent/create/references/toolbox-reference.md) — endpoint format, MCP protocol, OAuth consent handling, citation patterns, and troubleshooting.
> - [Use toolbox in a hosted agent](https://github.com/microsoft/GitHub-Copilot-for-Azure/blob/main/plugin/skills/microsoft-foundry/foundry-agent/create/references/use-toolbox-in-hosted-agent.md) — endpoint resolution, env-var contract, payload shape, code integration patterns, and tracing.
The agent reads the toolbox's MCP endpoint from `TOOLBOX_ENDPOINT`. Create the toolbox once from the bundled [`toolbox.yaml`](toolbox.yaml):
```bash
azd ai toolbox create agent-tools --from-file ./toolbox.yaml --project-endpoint https://<account>.services.ai.azure.com/api/projects/<project>
```
The first version becomes the default automatically. Use `azd ai toolbox list`, `azd ai toolbox show agent-tools`, and `azd ai toolbox version list agent-tools` to inspect, and `azd ai toolbox delete agent-tools --force` to remove it.
To stage incremental changes safely, use `azd ai toolbox connection add/remove` and `azd ai toolbox skill add/list/remove`; each creates a new toolbox version that carries forward existing connections and skills but **doesn't** change the default. Promote a version with `azd ai toolbox publish agent-tools <version>` when you're ready to make it active.
`azd ai toolbox create` prints the toolbox's versioned MCP endpoint. Copy that endpoint and store it in your `azd` environment so the agent connects to it:
```bash
azd env set TOOLBOX_ENDPOINT "https://<account>.services.ai.azure.com/api/projects/<project>/toolboxes/agent-tools/versions/1/mcp?api-version=v1"
```
#### Provision Azure resources (if needed)
If you don't already have a Foundry project and model deployment:
```bash
azd provision
```
#### Run the agent locally
```bash
azd ai agent run
```
The agent host will start on `http://localhost:8088`.
#### Invoke the local agent
In a separate terminal, from the project directory:
```bash
azd ai agent invoke --local "What tools do you have?"
```
#### Deploy to Foundry
Once tested locally, deploy to Microsoft Foundry:
```bash
azd deploy
```
For the full deployment guide, see [Deploy a hosted agent](https://learn.microsoft.com/en-us/azure/foundry/agents/how-to/deploy-hosted-agent).
#### Invoke the deployed agent
```bash
azd ai agent invoke "What tools do you have?"
```
### Option 2: VS Code (Foundry Toolkit)
#### Prerequisites
1. **VS Code** with the **[Foundry Toolkit](https://learn.microsoft.com/en-us/azure/foundry/how-to/develop/get-started-projects-vs-code)** extension installed.
2. Sign in to Azure in VS Code.
3. The `agent-tools` toolbox must exist in your Foundry project. Create it from the bundled [`toolbox.yaml`](toolbox.yaml) (`azd ai toolbox create agent-tools --from-file ./toolbox.yaml`) or in the Foundry portal before you run the agent.
#### Create the project
1. Open the Command Palette (`Ctrl+Shift+P`) and run **Foundry Toolkit: Create Hosted Agent**.
2. Select this sample from the gallery. The extension scaffolds the project into a new workspace and generates `agent.yaml`, `.env`, and `.vscode/tasks.json` + `launch.json` automatically.
3. Complete the **Foundry Project Setup** to pick the subscription and Foundry project (or create a new one).
#### Run and debug the agent
Press **F5** to start the agent in debug mode. The agent host will start on `http://localhost:8088`.
#### Test with Agent Inspector
1. Open the Command Palette (`Ctrl+Shift+P`) and run **Foundry Toolkit: Open Agent Inspector**.
2. The Inspector connects to the running agent. Send messages to chat and view streamed responses.
#### Deploy to Foundry
1. Open the Command Palette (`Ctrl+Shift+P`) and run **Foundry Toolkit: Deploy Hosted Agent**. The extension opens a **Deploy Hosted Agent** wizard and reads `agent.yaml` to auto-populate settings.
2. If prompted, complete **Foundry Project Setup** to select subscription and project.
3. On the **Basics** tab, choose deployment method (**Code** or **Container**) and confirm the agent name.
4. On **Review + Deploy**, confirm runtime details, pick **CPU and Memory** size, and click **Deploy**.
5. After deployment, invoke the agent in the Agent Playground and stream live logs from the **Logs** tab.
### Creating a Foundry Toolbox
You can create a Foundry Toolbox by code. Refer to this sample for an example: [Foundry Toolbox CRUD Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-projects/samples/hosted_agents/sample_toolboxes_crud.py).
You can also create a Foundry Toolbox in the Foundry portal. Read more about it [in the Foundry toolbox documentation](https://learn.microsoft.com/en-us/azure/foundry/agents/how-to/tools/toolbox).
## Troubleshooting
### A single failing MCP source can fail the whole agent
A toolbox aggregates every tool source behind one MCP endpoint. If **any** referenced MCP server fails while the toolbox enumerates tools (`tools/list`), the toolbox fails the entire enumeration, so the agent can't load its tools and every request returns an error (HTTP 500) until that source recovers.
For example, a flaky third-party MCP source can intermittently return `HTTP 502 (Bad Gateway)` during enumeration, which surfaces as:
```
tools/list failed for 1 tool source(s), succeeded for 5 tool source(s)
{"errors":[{"name":"<server_label>","type":"mcp","error":{"code":"HTTP_502", ...}}]}
```
This is an upstream/service hiccup, not a problem with the agent code. Mitigations:
- Retry the request — these failures are usually transient.
- If a source is persistently unavailable, temporarily remove its tool entry (and connection) from `toolbox.yaml`, recreate the toolbox, and update `TOOLBOX_ENDPOINT`.
- Inspect deployed agent logs with `azd ai agent monitor` to identify which source failed.
### Entra pass-through forwards the caller's identity
The Foundry MCP tool authenticates with **Entra pass-through** (`foundrymcpconn`): Foundry forwards the
calling user's Entra token to `https://mcp.ai.azure.com`. The token is forwarded both from the Foundry
portal **Agent Playground** (signed-in user) and by `azd ai agent invoke` (the developer's Entra token),
so the tools operate as that user and only act on resources the user can already access. The Foundry MCP
server requires no extra license — just access to the Foundry project.
Because the tool acts as a specific user, running the agent **locally** (`python main.py`) or calling the
endpoint with a raw token uses whatever identity that token represents (`az login` user locally, the
agent's managed identity when hosted). If that identity has no access to the target resources, the tool
returns an authorization error even though it is discovered and called correctly.
> Some other Entra pass-through MCP servers add their **own** entitlement checks on top of the token. For
> example, the Microsoft 365 / WorkIQ servers (Outlook Mail, Teams) require the caller to hold a
> **Microsoft 365 Copilot (Business Chat)** license; without it they fail with
> `WorkIQ license check failed. Required service plan(s): [M365_COPILOT_BUSINESS_CHAT]`. That is a
> property of those servers, not of Entra pass-through itself.
## Next steps
- [Quickstart: Create a hosted agent](https://learn.microsoft.com/en-us/azure/foundry/agents/quickstarts/quickstart-hosted-agent) — end-to-end walkthrough using `azd`
- [Tool catalog](https://learn.microsoft.com/en-us/azure/foundry/agents/concepts/tool-catalog) — browse available tools to extend your agent (Bing Search, Azure AI Search, file search, code interpreter, and more)
- [Manage hosted agents](https://learn.microsoft.com/en-us/azure/foundry/agents/how-to/manage-hosted-agent) — monitor and manage deployed agents
- [Basic agent](../01_basic/) — minimal agent with no tools
- [Add local tools](../02_tools/) — sample with locally-defined Python tool functions
- [Build multi-agent workflows](../05_workflows/) — sample with chained agent pipelines
@@ -0,0 +1,30 @@
name: agent-framework-agent-with-foundry-toolbox-responses
description: >
An Agent Framework agent with Foundry Toolbox integration.
metadata:
tags:
- Agent Framework
- AI Agent Hosting
- Azure AI AgentServer
- Responses Protocol
- Streaming
template:
name: agent-framework-agent-with-foundry-toolbox-responses
kind: hosted
protocols:
- protocol: responses
version: 2.0.0
environment_variables:
- name: AZURE_AI_MODEL_DEPLOYMENT_NAME
value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}"
- name: TOOLBOX_ENDPOINT
# Full MCP endpoint of the toolbox the agent consumes. Create the toolbox
# from the bundled toolbox.yaml, then copy the versioned endpoint it prints
# and store it in your azd environment before you run or deploy:
# azd ai toolbox create my-toolbox --from-file ./toolbox.yaml
# azd env set TOOLBOX_ENDPOINT "<endpoint-from-output>"
value: "{{TOOLBOX_ENDPOINT}}"
resources:
- kind: model
id: gpt-4.1
name: AZURE_AI_MODEL_DEPLOYMENT_NAME
@@ -0,0 +1,13 @@
kind: hosted
name: agent-framework-agent-with-foundry-toolbox-responses
protocols:
- protocol: responses
version: 2.0.0
resources:
cpu: "0.25"
memory: 0.5Gi
environment_variables:
- name: AZURE_AI_MODEL_DEPLOYMENT_NAME
value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME}
- name: TOOLBOX_ENDPOINT
value: ${TOOLBOX_ENDPOINT}
@@ -0,0 +1,48 @@
# Copyright (c) Microsoft. All rights reserved.
import asyncio
import os
from agent_framework import Agent
from agent_framework.foundry import FoundryChatClient
from agent_framework_foundry_hosting import FoundryToolbox, ResponsesHostServer
from azure.identity import DefaultAzureCredential
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
async def main():
credential = DefaultAzureCredential()
# FoundryToolbox resolves the toolbox endpoint from the environment
# (TOOLBOX_ENDPOINT, or FOUNDRY_PROJECT_ENDPOINT + TOOLBOX_NAME), authenticates
# every request with the credential, and transparently forwards the platform
# per-request call-id to the toolbox. The hosting server enters the agent, which
# connects the toolbox on first use and closes it at shutdown.
toolbox = FoundryToolbox(credential)
# Create the chat client
client = FoundryChatClient(
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
credential=credential,
)
agent = Agent(
client=client,
instructions="You are a friendly assistant. Keep your answers brief.",
tools=toolbox,
# History will be managed by the hosting infrastructure, thus there
# is no need to store history by the service. Learn more at:
# https://developers.openai.com/api/reference/resources/responses/methods/create
default_options={"store": False},
)
server = ResponsesHostServer(agent)
await server.run_async()
if __name__ == "__main__":
asyncio.run(main())
@@ -0,0 +1,2 @@
agent-framework-foundry
agent-framework-foundry-hosting>=1.0.0a260630
@@ -0,0 +1,105 @@
#!/usr/bin/env pwsh
<#
.SYNOPSIS
List Foundry Tools Catalog connectors, or fetch full details for one connector.
.DESCRIPTION
Queries the Azure AI Foundry Tools Catalog (asset-gallery) connectors registry.
- With no -ConnectorName: lists all connectors (name, title, detected auth type).
- With -ConnectorName: prints the full JSON details for that connector.
A bearer token for https://ai.azure.com is required. It is read from the
-Token parameter, then the CATALOG_TOKEN environment variable, and finally
acquired automatically via 'az account get-access-token' (requires 'az login').
.EXAMPLE
./list-foundry-connectors.ps1
Lists all connectors.
.EXAMPLE
./list-foundry-connectors.ps1 -ConnectorName a365outlookmailmcp
Prints full details for the Work IQ Mail MCP connector.
.EXAMPLE
./list-foundry-connectors.ps1 -PageSize 2000
Lists more connectors in a single page.
#>
[CmdletBinding()]
param(
# annotations/name of a connector to fetch full details for. Omit to list all.
[string]$ConnectorName,
# Azure ML region host prefix.
[string]$Region = "eastus",
# Number of results to request in one page.
[int]$PageSize = 100,
# Catalog bearer token (audience https://ai.azure.com). Defaults to $env:CATALOG_TOKEN, else acquired via az.
[string]$Token = $env:CATALOG_TOKEN
)
$ErrorActionPreference = "Stop"
if (-not $Token) {
Write-Verbose "No token supplied; acquiring via 'az account get-access-token'..."
$Token = az account get-access-token --resource https://ai.azure.com --query accessToken -o tsv
}
if (-not $Token) {
throw "Failed to acquire a catalog token. Run 'az login', or pass -Token / set `$env:CATALOG_TOKEN."
}
$uri = "https://$Region.api.azureml.ms/asset-gallery/v1.0/tools"
$headers = @{
"Authorization" = "Bearer $Token"
"Content-Type" = "application/json"
"x-ms-user-agent" = "AzureMachineLearningWorkspacePortal/12.0"
}
$filters = [System.Collections.ArrayList]@(
@{ field = "entityContainerId"; operator = "eq"; values = @("connectors-registry-prod-bl") }
@{ field = "type"; operator = "eq"; values = @("tools") }
@{ field = "kind"; operator = "eq"; values = @("Versioned") }
@{ field = "labels"; operator = "eq"; values = @("latest") }
)
if ($ConnectorName) {
[void]$filters.Add(@{ field = "annotations/name"; operator = "eq"; values = @($ConnectorName) })
}
$body = @{
freeTextSearch = "*"
filters = $filters
includeTotalResultCount = $true
pageSize = $PageSize
skip = 0
} | ConvertTo-Json -Depth 10
# The response can be several MB and may contain a property with an empty-string
# name, so read the raw content and parse with -AsHashtable.
$content = (Invoke-WebRequest -Method Post -Uri $uri -Headers $headers -Body $body).Content
$resp = $content | ConvertFrom-Json -AsHashtable -Depth 100
if ($ConnectorName) {
if ($resp.totalCount -eq 0) {
Write-Warning "No connector found with annotations/name '$ConnectorName'."
return
}
$resp.value | ConvertTo-Json -Depth 100
}
else {
Write-Host "Total connectors: $($resp.totalCount)"
$resp.value | ForEach-Object {
$params = $_.properties.'x-ms-connection-parameters'
$authType = if ($null -eq $params) {
"None"
}
else {
$types = $params.Values | ForEach-Object { $_.type }
if ($types -contains "oauthSetting") { "OAuth2" }
elseif ($types -contains "securestring") { "CustomKeys" }
else { "None" }
}
[pscustomobject]@{
Name = $_.annotations.name
Title = $_.properties.title
Auth = $authType
}
} | Format-Table -AutoSize
}
@@ -0,0 +1,106 @@
#!/usr/bin/env bash
#
# List Foundry Tools Catalog connectors, or fetch full details for one connector.
#
# - With no -n: lists all connectors (name, title, detected auth type).
# - With -n NAME: prints the full JSON details for that connector.
#
# A bearer token for https://ai.azure.com is required. It is read from the
# -t option, then the CATALOG_TOKEN environment variable, and finally acquired
# automatically via 'az account get-access-token' (requires 'az login').
#
# Requires: curl, jq (and optionally az).
#
# Examples:
# ./list-foundry-connectors.sh
# ./list-foundry-connectors.sh -n a365outlookmailmcp
# ./list-foundry-connectors.sh -p 2000
#
set -euo pipefail
CONNECTOR_NAME=""
REGION="eastus"
PAGE_SIZE=100
TOKEN="${CATALOG_TOKEN:-}"
usage() {
cat <<EOF
Usage: $0 [-n connector_name] [-r region] [-p page_size] [-t token]
-n Connector annotations/name to fetch full details for (e.g. a365outlookmailmcp).
If omitted, lists all connectors (name, title, auth type).
-r Azure ML region host prefix (default: ${REGION}).
-p Page size (default: ${PAGE_SIZE}).
-t Catalog bearer token (audience https://ai.azure.com).
Defaults to \$CATALOG_TOKEN, else acquired via 'az'.
-h Show this help.
EOF
}
while getopts ":n:r:p:t:h" opt; do
case "$opt" in
n) CONNECTOR_NAME="$OPTARG" ;;
r) REGION="$OPTARG" ;;
p) PAGE_SIZE="$OPTARG" ;;
t) TOKEN="$OPTARG" ;;
h) usage; exit 0 ;;
\?) echo "Invalid option: -$OPTARG" >&2; usage; exit 1 ;;
:) echo "Option -$OPTARG requires an argument." >&2; usage; exit 1 ;;
esac
done
if [[ -z "$TOKEN" ]]; then
TOKEN=$(az account get-access-token --resource https://ai.azure.com --query accessToken -o tsv)
fi
if [[ -z "$TOKEN" ]]; then
echo "Failed to acquire a catalog token. Run 'az login', or pass -t / set CATALOG_TOKEN." >&2
exit 1
fi
URI="https://${REGION}.api.azureml.ms/asset-gallery/v1.0/tools"
# Base filters; optionally narrow to a single connector by annotations/name.
FILTERS=$(jq -nc --arg connector "$CONNECTOR_NAME" '
[
{"field":"entityContainerId","operator":"eq","values":["connectors-registry-prod-bl"]},
{"field":"type", "operator":"eq","values":["tools"]},
{"field":"kind", "operator":"eq","values":["Versioned"]},
{"field":"labels", "operator":"eq","values":["latest"]}
] + ( ($connector | length) > 0
? [{"field":"annotations/name","operator":"eq","values":[$connector]}]
: [] )
')
BODY=$(cat <<EOF
{
"freeTextSearch": "*",
"filters": $FILTERS,
"includeTotalResultCount": true,
"pageSize": $PAGE_SIZE,
"skip": 0
}
EOF
)
RESPONSE=$(curl -sS -X POST "$URI" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "x-ms-user-agent: AzureMachineLearningWorkspacePortal/12.0" \
-d "$BODY")
if [[ -n "$CONNECTOR_NAME" ]]; then
# Full JSON details for the requested connector.
echo "$RESPONSE" | jq '.value'
else
# name, title, and detected auth type for each connector.
echo "$RESPONSE" | jq -r '
.totalCount as $total |
"Total connectors: \($total)",
(.value[] | "\(.annotations.name)\t\(.properties.title)\t\(
.properties["x-ms-connection-parameters"] |
if . == null then "None"
elif ([.[].type] | any(. == "oauthSetting")) then "OAuth2"
elif ([.[].type] | any(. == "securestring")) then "CustomKeys"
else "None" end
)")'
fi
@@ -0,0 +1,34 @@
# toolbox.yaml
# Defines the toolbox this agent consumes. Create it once with:
# azd ai toolbox create agent-tools --from-file ./toolbox.yaml
# After creating it, copy the versioned MCP endpoint the command prints and
# set it as the TOOLBOX_ENDPOINT environment variable. The agent connects to
# that endpoint at runtime.
description: Multiple MCP servers behind one endpoint
tools:
- type: web_search
name: web_search
require_approval: "never"
- type: code_interpreter
name: code_interpreter
require_approval: "never"
- type: mcp
# This MCP tool doesn't require authentication
server_label: noauth_mcp
server_url: "https://gitmcp.io/Azure/azure-rest-api-specs"
require_approval: "never"
- type: mcp
# This MCP tool uses the GitHub MCP server with a PAT for authentication or OAuth2
server_label: github
project_connection_id: ghmcppat # use `ghmcpoauth` for OAuth2 authentication
require_approval: "never"
- type: mcp
# This MCP tool uses the Azure Language MCP server with agent identity for authentication
server_label: language-mcp
project_connection_id: langmcpconn
require_approval: "never"
- type: mcp
# This MCP tool uses the Microsoft Foundry MCP server with Entra pass-through (user token) for authentication
server_label: foundry-mcp
project_connection_id: foundrymcpconn
require_approval: "never"