Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
Microsoft Foundry Toolbox, kod yorumlayıcı, dosya arama, görüntü oluşturma, MCP ve web araması gibi barındırılan araç yapılandırmalarının adlandırılmış, sürümlenmiş sunucu tarafı paketidir. Araç kutuları, Foundry'de bir kez araç yapılandırmasını yönetmenize ve aracılar arasında yeniden kullanmanıza olanak tanır.
Agent Framework, Toolbox tüketimini kapsar. Toolbox sürümlerini Foundry portalı veya SDK aracılığıyla oluşturun ve güncelleştirin azure-ai-projects .
Important
FoundryToolbox beta agent-framework-foundry-hosting paketi tarafından sağlanır ve kararlı sürümden önce değişebilir.
Hizmet tarafından yönetilen FoundryAgentbir için, Araç Kutusu'nu Foundry'deki aracı tanımına ekleyin. İstemci tarafı .NET Araç Kutusu kullanım kılavuzu şu anda belgelenmemiştir.
Paketleri yükleme
pip install agent-framework-foundry-hosting agent-framework-foundry --pre
FoundryToolbox ,'den agent_framework.foundry içeri aktarılır ve tarafından agent-framework-foundry-hostingsağlanır.
Araç Kutusunu Yapılandırma
Açık bir Toolbox MCP uç noktası ayarlayın:
TOOLBOX_ENDPOINT="https://<account>.services.ai.azure.com/api/projects/<project>/toolboxes/<name>/mcp?api-version=v1"
Veya uç noktayı oluşturmasına izin verin FoundryToolbox :
FOUNDRY_PROJECT_ENDPOINT="https://<account>.services.ai.azure.com/api/projects/<project>"
TOOLBOX_NAME="<toolbox-name>"
Barındırılan aracı örnekleri için FoundryChatClientde kullanılırAZURE_AI_MODEL_DEPLOYMENT_NAME.
Barındırılan aracıyla kullanma FoundryToolbox
FoundryToolboxuç noktasını çözümler, sağlanan Azure kimlik bilgileriyle her MCP isteğinin kimliğini doğrular, istek başına Foundry çağrı kimliğini iletir ve aracının bağlantı yaşam döngüsüne katılır.
import asyncio
import os
from agent_framework import Agent
from agent_framework.foundry import FoundryChatClient, 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()
Araç Kutusu becerilerini kullanıma sunma
Araç Kutusu, MCP üzerinden Aracı Becerilerini kullanıma açabilir. Yalnızca becerilerin model tarafından görünür olması gerektiğinde ayarlayın load_tools=False , ardından MCP oturumunun bağlanıp bağlam sağlayıcısı olarak kullanması as_skills_provider() için Araç Kutusu'nu bir araç olarak ekleyin.
import asyncio
import os
from agent_framework import Agent
from agent_framework.foundry import FoundryChatClient, FoundryToolbox, ResponsesHostServer
from azure.identity import DefaultAzureCredential
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
async def main() -> None:
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 forwards the platform per-request
# call-id. ``load_tools=False`` keeps the toolbox's tools hidden so only its
# Agent Skills (SEP-2640) are surfaced; passing it via ``tools=`` connects the
# MCP session that ``as_skills_provider()`` reads from.
toolbox = FoundryToolbox(credential, load_tools=False)
# as_skills_provider() discovers skills from skill://index.json on the toolbox
# MCP session and exposes them as an agent context provider; SKILL.md bodies are
# fetched on demand via resources/read. disable_load_skill_approval=True registers
# the load_skill tool with approval_mode="never_require" so this unattended agent
# can load skills without an approval round-trip -- the Responses host runs the
# agent without an AgentSession, which the default approval flow requires.
skills_provider = toolbox.as_skills_provider(disable_load_skill_approval=True)
client = FoundryChatClient(
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
credential=credential,
)
agent = Agent(
client=client,
name=os.environ.get("AGENT_NAME", "hosted-toolbox-mcp-skills"),
instructions="You are a helpful assistant.",
tools=toolbox,
context_providers=[skills_provider],
# 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()
Onay, beceri işlemleri için varsayılan olarak etkin kalır. Yalnızca güvenilen, katılımsız senaryolar için tek tek onayları devre dışı bırakın.
Ile Araç Kutusu kullanma FoundryAgent
Araç Kutusunu, Foundry'deki İstem veya Barındırılan Aracı tanımına ekleyin.
FoundryAgent depolanan araç yapılandırmasını kullanır; Araç Kutusu istemci tarafı geçirilirse yönetilen aracıya eklenemez.
Ham MCP üzerinden bağlanma
Uygulama barındırma sarmalayıcısını FoundryToolbox kullanmadığında doğrudan kullanınMCPStreamableHTTPTool. Aracılığıyla Araç Kutusu uç noktasını ve Entra ID taşıyıcı belirtecini sağlayınheader_provider.
import asyncio
import os
from collections.abc import Callable
from typing import Any, cast
from agent_framework import Agent, MCPStreamableHTTPTool
from agent_framework.foundry import FoundryChatClient
from azure.core.credentials import TokenCredential
from azure.identity import AzureCliCredential, DefaultAzureCredential, get_bearer_token_provider
from dotenv import load_dotenv
def make_toolbox_header_provider(credential: TokenCredential) -> Callable[[dict[str, Any]], dict[str, str]]:
"""Build a header_provider that injects a fresh Azure AI bearer token on every MCP request."""
get_token = get_bearer_token_provider(credential, "https://ai.azure.com/.default")
def provide(_kwargs: dict[str, Any]) -> dict[str, str]:
return {
"Authorization": f"Bearer {get_token()}",
}
return provide
async def main() -> None:
credential = DefaultAzureCredential()
toolbox_tool = MCPStreamableHTTPTool(
name="foundry_toolbox",
description="Tools exposed by the configured Foundry toolbox",
url=os.environ["FOUNDRY_TOOLBOX_ENDPOINT"],
header_provider=make_toolbox_header_provider(credential),
load_prompts=False,
)
async with Agent(
client=FoundryChatClient(
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
model=os.environ["FOUNDRY_MODEL"],
credential=credential,
),
instructions="You are a helpful assistant. Use the available toolbox tools to answer the user.",
tools=toolbox_tool,
) as agent:
query = "What tools do you have access to?"
print(f"User: {query}")
result = await agent.run(query)
print(f"Assistant: {result}")
Alt düzey örnek kullanır FOUNDRY_TOOLBOX_ENDPOINT. Toolbox becerileri örneği kullanırFOUNDRY_TOOLBOX_MCP_SERVER_URL; bu adlar bu örneklere aittir ve sınıfın TOOLBOX_ENDPOINT ve TOOLBOX_NAME ayarlarından FoundryToolbox ayrıdır.
Limitations
- Araç Kutusu içindeki MCP araçları, Bir Foundry
project_connection_idaracılığıyla sunucu tarafı kimlik doğrulaması kullanır; Agent Framework istemcisi yukarı akış MCP taşıyıcı belirtecini tutmaz. - Bir Araç Kutusu'nu MCP sunucusu olarak kullanmak, Toolbox uç noktası için istemci tarafı Entra ID kimlik doğrulaması gerektirir.
- gibi
CONSENT_REQUIREDonay akışı yanıtları, Araç Kutusu bağlantısı oluşturulurken değil aracı çalışırken işlenir.
Samples
| Sample | Description |
|---|---|
| foundry_toolbox/main.py |
FoundryToolbox barındırılan Yanıtlar aracısı ile |
| foundry_toolbox_mcp_skills/main.py | Araç Kutusu Destekli Aracı Becerileri |
| foundry_chat_client_with_toolbox.py | ile araç kutusu MCP tüketimi MCPStreamableHTTPTool |
| foundry_chat_client_with_toolbox_skills.py | Araç kutusu destekli beceri yapılandırması |
| invoke_foundry_toolbox_mcp | İş akışı tarafı MCP tüketimi |
Go şu anda bir Döküm Aracı Kutusu yardımcısı sunmaz. Foundry aracılığıyla Araç Kutularını yapılandırın ve Go aracıları için desteklenen yerel veya barındırılan araç bildirimlerini kullanın.