Share via


MCPTool Class

Definition

Give the model access to additional tools via remote Model Context Protocol (MCP) servers. Learn more about MCP.

public class MCPTool : Azure.AI.AgentServer.Contracts.Generated.OpenAI.Tool, System.ClientModel.Primitives.IJsonModel<Azure.AI.AgentServer.Contracts.Generated.OpenAI.MCPTool>, System.ClientModel.Primitives.IPersistableModel<Azure.AI.AgentServer.Contracts.Generated.OpenAI.MCPTool>
type MCPTool = class
    inherit Tool
    interface IUtf8JsonSerializable
    interface IJsonModel<MCPTool>
    interface IPersistableModel<MCPTool>
Public Class MCPTool
Inherits Tool
Implements IJsonModel(Of MCPTool), IPersistableModel(Of MCPTool)
Inheritance
MCPTool
Implements

Constructors

Name Description
MCPTool()

Initializes a new instance of MCPTool for deserialization.

MCPTool(String, String)

Initializes a new instance of MCPTool.

MCPTool(ToolType, IDictionary<String,BinaryData>, String, String, IDictionary<String,String>, BinaryData, BinaryData, String)

Initializes a new instance of MCPTool.

Properties

Name Description
AllowedTools

List of allowed tool names or a filter object.

To assign an object to this property use FromObjectAsJson<T>(T, JsonSerializerOptions).

To assign an already formatted json string to this property use FromString(String).

<remarks> Supported types:

</remarks> Examples:
  • BinaryData.FromObjectAsJson("foo"): Creates a payload of "foo".
  • BinaryData.FromString("\"foo\""): Creates a payload of "foo".
  • BinaryData.FromObjectAsJson(new { key = "value" }): Creates a payload of { "key": "value" }.
  • BinaryData.FromString("{\"key\": \"value\"}"): Creates a payload of { "key": "value" }.

Headers

Optional HTTP headers to send to the MCP server. Use for authentication or other purposes.

ProjectConnectionId

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.

RequireApproval

Specify which of the MCP server's tools require approval.

To assign an object to this property use FromObjectAsJson<T>(T, JsonSerializerOptions).

To assign an already formatted json string to this property use FromString(String).

<remarks> Supported types:

</remarks> Examples:
  • BinaryData.FromObjectAsJson("foo"): Creates a payload of "foo".
  • BinaryData.FromString("\"foo\""): Creates a payload of "foo".
  • BinaryData.FromObjectAsJson(new { key = "value" }): Creates a payload of { "key": "value" }.
  • BinaryData.FromString("{\"key\": \"value\"}"): Creates a payload of { "key": "value" }.

ServerLabel

A label for this MCP server, used to identify it in tool calls.

ServerUrl

The URL for the MCP server.

Type

Gets or sets the type.

(Inherited from Tool)

Methods

Name Description
DeserializeMCPTool(JsonElement, ModelReaderWriterOptions)
FromResponse(Response)

Deserializes the model from a raw response.

JsonModelWriteCore(Utf8JsonWriter, ModelReaderWriterOptions)
ToRequestContent()

Convert into a RequestContent.

Explicit Interface Implementations

Name Description
IJsonModel<MCPTool>.Create(Utf8JsonReader, ModelReaderWriterOptions)

Reads one JSON value (including objects or arrays) from the provided reader and converts it to a model.

IJsonModel<MCPTool>.Write(Utf8JsonWriter, ModelReaderWriterOptions)

Writes the model to the provided Utf8JsonWriter.

IJsonModel<Tool>.Create(Utf8JsonReader, ModelReaderWriterOptions)

Reads one JSON value (including objects or arrays) from the provided reader and converts it to a model.

(Inherited from Tool)
IJsonModel<Tool>.Write(Utf8JsonWriter, ModelReaderWriterOptions)

Writes the model to the provided Utf8JsonWriter.

(Inherited from Tool)
IPersistableModel<MCPTool>.Create(BinaryData, ModelReaderWriterOptions)

Converts the provided BinaryData into a model.

IPersistableModel<MCPTool>.GetFormatFromOptions(ModelReaderWriterOptions)

Gets the data interchange format (JSON, Xml, etc) that the model uses when communicating with the service.

IPersistableModel<MCPTool>.Write(ModelReaderWriterOptions)

Writes the model into a BinaryData.

IPersistableModel<Tool>.Create(BinaryData, ModelReaderWriterOptions)

Converts the provided BinaryData into a model.

(Inherited from Tool)
IPersistableModel<Tool>.GetFormatFromOptions(ModelReaderWriterOptions)

Gets the data interchange format (JSON, Xml, etc) that the model uses when communicating with the service.

(Inherited from Tool)
IPersistableModel<Tool>.Write(ModelReaderWriterOptions)

Writes the model into a BinaryData.

(Inherited from Tool)
IUtf8JsonSerializable.Write(Utf8JsonWriter)

Applies to