McpTool Class
- java.
lang. Object - com.
azure. ai. agents. models. Tool - com.
azure. ai. agents. models. McpTool
- com.
- com.
public final class McpTool
extends Tool
MCP tool Give the model access to additional tools via remote Model Context Protocol (MCP) servers. [Learn more about MCP](https://developers.openai.com/api/docs/guides/tools-connectors-mcp).
Constructor Summary
| Constructor | Description |
|---|---|
| McpTool(String serverLabel) |
Creates an instance of Mcp |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
static
Mcp |
fromJson(JsonReader jsonReader)
Reads an instance of Mcp |
|
List<Callable |
getAllowedCallers()
Get the allowed |
|
Mcp |
getAllowedToolsAsMcpToolFilter()
Get the allowed |
| List<String> |
getAllowedToolsAsStringList()
Get the allowed |
| String |
getAuthorization()
Get the authorization property: An OAuth access token that can be used with a remote MCP server, either with a custom MCP server URL or a service connector. |
|
Mcp |
getConnectorType()
Get the connector |
| Map<String,String> |
getHeaders()
Get the headers property: The headers property. |
| String |
getProjectConnectionId()
Get the project |
|
Mcp |
getRequireApprovalAsMcpToolRequireApproval()
Get the require |
| String |
getRequireApprovalAsString()
Get the require |
| String |
getServerDescription()
Get the server |
| String |
getServerLabel()
Get the server |
| String |
getServerUrl()
Get the server |
|
Map<String,Tool |
getToolConfigs()
Get the tool |
| String |
getTunnelId()
Get the tunnel |
|
Tool |
getType()
Get the type property: The type property. |
| Boolean |
isDeferLoading()
Get the defer |
|
Mcp |
setAllowedCallers(List<CallableToolAllowedCaller> allowedCallers)
Set the allowed |
|
Mcp |
setAllowedTools(List<String> allowedTools)
Set the allowed |
|
Mcp |
setAllowedTools(McpToolFilter allowedTools)
Set the allowed |
|
Mcp |
setAuthorization(String authorization)
Set the authorization property: An OAuth access token that can be used with a remote MCP server, either with a custom MCP server URL or a service connector. |
|
Mcp |
setConnectorType(McpToolConnectorId connectorType)
Set the connector |
|
Mcp |
setDeferLoading(Boolean deferLoading)
Set the defer |
|
Mcp |
setHeaders(Map<String,String> headers)
Set the headers property: The headers property. |
|
Mcp |
setProjectConnectionId(String projectConnectionId)
Set the project |
|
Mcp |
setRequireApproval(McpToolRequireApproval requireApproval)
Set the require |
|
Mcp |
setRequireApproval(String requireApproval)
Set the require |
|
Mcp |
setServerDescription(String serverDescription)
Set the server |
|
Mcp |
setServerUrl(String serverUrl)
Set the server |
|
Mcp |
setToolConfigs(Map<String,ToolConfig> toolConfigs)
Set the tool |
|
Mcp |
setTunnelId(String tunnelId)
Set the tunnel |
|
Json |
toJson(JsonWriter jsonWriter) |
Methods inherited from Tool
Methods inherited from java.lang.Object
Constructor Details
McpTool
public McpTool(String serverLabel)
Creates an instance of McpTool class.
Parameters:
Method Details
fromJson
public static McpTool fromJson(JsonReader jsonReader)
Reads an instance of McpTool from the JsonReader.
Parameters:
Returns:
Throws:
getAllowedCallers
public List<CallableToolAllowedCaller> getAllowedCallers()
Get the allowedCallers property: The allowed_callers property.
Returns:
getAllowedToolsAsMcpToolFilter
public McpToolFilter getAllowedToolsAsMcpToolFilter()
Get the allowedTools property: The allowed_tools property.
Returns:
getAllowedToolsAsStringList
public List<String> getAllowedToolsAsStringList()
Get the allowedTools property: The allowed_tools property.
Returns:
getAuthorization
public String getAuthorization()
Get the authorization property: An OAuth access token that can be used with a remote MCP server, either with a custom MCP server URL or a service connector. Your application must handle the OAuth authorization flow and provide the token here.
Returns:
getConnectorType
public McpToolConnectorId getConnectorType()
Get the connectorType property: Identifier for service connectors, like those available in ChatGPT. One of `server_url`, `connector_id`, or `tunnel_id` must be provided. Learn more about service connectors [here](https://developers.openai.com/api/docs/guides/tools-connectors-mcp\#connectors). This field is deprecated for models released after September 1, 2026. Use `server_url` to connect to a remote MCP server, or `tunnel_id` to connect through a Secure MCP Tunnel. Currently supported `connector_id` values are: - Dropbox: `connector_dropbox` - Gmail: `connector_gmail` - Google Calendar: `connector_googlecalendar` - Google Drive: `connector_googledrive` - Microsoft Teams: `connector_microsoftteams` - Outlook Calendar: `connector_outlookcalendar` - Outlook Email: `connector_outlookemail` - SharePoint: `connector_sharepoint`.
Returns:
getHeaders
public Map<String,String> getHeaders()
Get the headers property: The headers property.
Returns:
getProjectConnectionId
public String getProjectConnectionId()
Get the projectConnectionId property: The connection ID in the project for the MCP server. The connection stores authentication and other connection details needed to connect to the MCP server.
Returns:
getRequireApprovalAsMcpToolRequireApproval
public McpToolRequireApproval getRequireApprovalAsMcpToolRequireApproval()
Get the requireApproval property: The require_approval property.
Returns:
getRequireApprovalAsString
public String getRequireApprovalAsString()
Get the requireApproval property: The require_approval property.
Returns:
getServerDescription
public String getServerDescription()
Get the serverDescription property: Optional description of the MCP server, used to provide more context.
Returns:
getServerLabel
public String getServerLabel()
Get the serverLabel property: A label for this MCP server, used to identify it in tool calls.
Returns:
getServerUrl
public String getServerUrl()
Get the serverUrl property: The URL for the MCP server. One of `server_url`, `connector_id`, or `tunnel_id` must be provided.
Returns:
getToolConfigs
public Map<String,ToolConfig> getToolConfigs()
Get the toolConfigs property: Deprecated. This property is deprecated and will be removed in a future version.
Returns:
getTunnelId
public String getTunnelId()
Get the tunnelId property: The Secure MCP Tunnel ID to use instead of a direct server URL. One of `server_url`, `connector_id`, or `tunnel_id` must be provided.
Returns:
getType
public ToolType getType()
Get the type property: The type property.
Overrides:
McpTool.getType()Returns:
isDeferLoading
public Boolean isDeferLoading()
Get the deferLoading property: Whether this MCP tool is deferred and discovered via tool search.
Returns:
setAllowedCallers
public McpTool setAllowedCallers(List<CallableToolAllowedCaller> allowedCallers)
Set the allowedCallers property: The allowed_callers property.
Parameters:
Returns:
setAllowedTools
public McpTool setAllowedTools(List<String> allowedTools)
Set the allowedTools property: The allowed_tools property.
Parameters:
Returns:
setAllowedTools
public McpTool setAllowedTools(McpToolFilter allowedTools)
Set the allowedTools property: The allowed_tools property.
Parameters:
Returns:
setAuthorization
public McpTool setAuthorization(String authorization)
Set the authorization property: An OAuth access token that can be used with a remote MCP server, either with a custom MCP server URL or a service connector. Your application must handle the OAuth authorization flow and provide the token here.
Parameters:
Returns:
setConnectorType
public McpTool setConnectorType(McpToolConnectorId connectorType)
Set the connectorType property: Identifier for service connectors, like those available in ChatGPT. One of `server_url`, `connector_id`, or `tunnel_id` must be provided. Learn more about service connectors [here](https://developers.openai.com/api/docs/guides/tools-connectors-mcp\#connectors). This field is deprecated for models released after September 1, 2026. Use `server_url` to connect to a remote MCP server, or `tunnel_id` to connect through a Secure MCP Tunnel. Currently supported `connector_id` values are: - Dropbox: `connector_dropbox` - Gmail: `connector_gmail` - Google Calendar: `connector_googlecalendar` - Google Drive: `connector_googledrive` - Microsoft Teams: `connector_microsoftteams` - Outlook Calendar: `connector_outlookcalendar` - Outlook Email: `connector_outlookemail` - SharePoint: `connector_sharepoint`.
Parameters:
Returns:
setDeferLoading
public McpTool setDeferLoading(Boolean deferLoading)
Set the deferLoading property: Whether this MCP tool is deferred and discovered via tool search.
Parameters:
Returns:
setHeaders
public McpTool setHeaders(Map<String,String> headers)
Set the headers property: The headers property.
Parameters:
Returns:
setProjectConnectionId
public McpTool setProjectConnectionId(String projectConnectionId)
Set the projectConnectionId property: The connection ID in the project for the MCP server. The connection stores authentication and other connection details needed to connect to the MCP server.
Parameters:
Returns:
setRequireApproval
public McpTool setRequireApproval(McpToolRequireApproval requireApproval)
Set the requireApproval property: The require_approval property.
Parameters:
Returns:
setRequireApproval
public McpTool setRequireApproval(String requireApproval)
Set the requireApproval property: The require_approval property.
Parameters:
Returns:
setServerDescription
public McpTool setServerDescription(String serverDescription)
Set the serverDescription property: Optional description of the MCP server, used to provide more context.
Parameters:
Returns:
setServerUrl
public McpTool setServerUrl(String serverUrl)
Set the serverUrl property: The URL for the MCP server. One of `server_url`, `connector_id`, or `tunnel_id` must be provided.
Parameters:
Returns:
setToolConfigs
public McpTool setToolConfigs(Map<String,ToolConfig> toolConfigs)
Set the toolConfigs property: Deprecated. This property is deprecated and will be removed in a future version.
Parameters:
Returns:
setTunnelId
public McpTool setTunnelId(String tunnelId)
Set the tunnelId property: The Secure MCP Tunnel ID to use instead of a direct server URL. One of `server_url`, `connector_id`, or `tunnel_id` must be provided.
Parameters:
Returns:
toJson
public JsonWriter toJson(JsonWriter jsonWriter)
Overrides:
McpTool.toJson(JsonWriter jsonWriter)Parameters:
Throws: