Share via


McpToolRegistrationService Class

Provides MCP tool registration services for Azure Foundry agents.

This service handles registration and management of MCP (Model Context Protocol) tool servers with Azure Foundry agents using the Azure AI SDK. It provides seamless integration between MCP servers and Azure Foundry's agent framework.

Features:

  • Automatic MCP server discovery and configuration
  • Azure identity integration with DefaultAzureCredential
  • Tool definitions and resources management
  • Support for both development (ToolingManifest.json) and production (gateway API) scenarios
  • Comprehensive error handling and logging

Initialize the MCP Tool Registration Service for Azure Foundry.

Constructor

McpToolRegistrationService(logger: Logger | None = None, credential: DefaultAzureCredential | None = None)

Parameters

Name Description
logger

Logger instance for logging operations.

Default value: None
credential

Azure credential for authentication. If None, DefaultAzureCredential will be used.

Default value: None

Examples


>>> service = McpToolRegistrationService()
>>> service.add_tool_servers_to_agent(project_client, agent_id, token)

Methods

add_tool_servers_to_agent

Adds MCP tool servers to an Azure Foundry agent.

add_tool_servers_to_agent

Adds MCP tool servers to an Azure Foundry agent.

async add_tool_servers_to_agent(project_client: AIProjectClient, auth: Authorization, auth_handler_name: str, context: TurnContext, auth_token: str | None = None) -> None

Parameters

Name Description
project_client
Required

The Azure Foundry AIProjectClient instance.

auth
Required

Authorization handler for token exchange.

auth_handler_name
Required

Name of the authorization handler.

context
Required

Turn context for the current operation.

auth_token

Authentication token to access the MCP servers.

Default value: None

Exceptions

Type Description

If project_client is None or required parameters are invalid.

If there's an error during MCP tool registration.