你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

ToolSet Class

A collection of tools that can be used by an synchronize agent.

Constructor

ToolSet()

Methods

add

Add a tool to the tool set.

execute_tool_calls

Execute a tool of the specified type with the provided tool calls.

get_definitions_and_resources

Get the definitions and resources for all tools in the tool set.

get_tool

Get a tool of the specified type from the tool set. For McpTool, if 'server_label' is provided, returns the MCP tool with that specific server label. If there are multiple MCP tools and no server_label is provided, raises an error. Otherwise, returns the first (or only) tool of the specified type.

remove

Remove a tool of the specified type from the tool set. For OpenApiTool, if 'name' is provided, removes a specific API definition by name. For McpTool, if 'server_label' is provided, removes a specific MCP tool by server label. For McpTool without server_label, removes ALL MCP tools from the toolset. Otherwise, removes the entire tool from the toolset.

validate_tool_type

Validate the type of the tool.

add

Add a tool to the tool set.

add(tool: Tool)

Parameters

Name Description
tool
Required

The tool to add.

Exceptions

Type Description

If a tool of the same type already exists, or if an MCP tool with the same server label already exists.

execute_tool_calls

Execute a tool of the specified type with the provided tool calls.

execute_tool_calls(tool_calls: List[Any]) -> Any

Parameters

Name Description
tool_calls
Required

A list of tool calls to execute.

Returns

Type Description
Any

The output of the tool operations.

get_definitions_and_resources

Get the definitions and resources for all tools in the tool set.

get_definitions_and_resources() -> Dict[str, Any]

Returns

Type Description

A dictionary containing the tool resources and definitions.

get_tool

Get a tool of the specified type from the tool set. For McpTool, if 'server_label' is provided, returns the MCP tool with that specific server label. If there are multiple MCP tools and no server_label is provided, raises an error. Otherwise, returns the first (or only) tool of the specified type.

get_tool(tool_type: Type[ToolT], *, server_label: str | None = None) -> ToolT

Parameters

Name Description
tool_type
Required

The type of tool to get.

Keyword-Only Parameters

Name Description
server_label

The server label of the specific MCP tool to get.

Default value: None

Returns

Type Description

The tool of the specified type.

Exceptions

Type Description

If a tool of the specified type is not found, if no McpTool with the specified server_label is found, or if there are multiple MCP tools but no server_label is provided.

remove

Remove a tool of the specified type from the tool set. For OpenApiTool, if 'name' is provided, removes a specific API definition by name. For McpTool, if 'server_label' is provided, removes a specific MCP tool by server label. For McpTool without server_label, removes ALL MCP tools from the toolset. Otherwise, removes the entire tool from the toolset.

remove(tool_type: Type[Tool], *, name: str | None = None, server_label: str | None = None) -> None

Parameters

Name Description
tool_type
Required

The type of tool to remove.

Keyword-Only Parameters

Name Description
name
str

The name of the OpenAPI definition to remove from the tool.

Default value: None
server_label

The unique server label identifying the MCP tool to remove.

Default value: None

Returns

Type Description

None

Exceptions

Type Description

If a tool of the specified type is not found.

validate_tool_type

Validate the type of the tool.

validate_tool_type(tool: Tool) -> None

Parameters

Name Description
tool
Required

The type of the tool to validate.

Exceptions

Type Description

If the tool type is not a subclass of Tool.

Attributes

definitions

Get the definitions for all tools in the tool set.

Returns

Type Description

resources

Get the resources for all tools in the tool set.

Returns

Type Description