Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion api/OpenAI.net8.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4898,9 +4898,13 @@ public class FunctionTool : ResponseTool, IJsonModel<FunctionTool>, IPersistable
}
[Experimental("OPENAI001")]
public class McpTool : ResponseTool, IJsonModel<McpTool>, IPersistableModel<McpTool> {
public McpTool(string serverLabel, McpToolConnectorId connectorId);
public McpTool(string serverLabel, Uri serverUri);
public McpToolFilter AllowedTools { get; set; }
public string AuthorizationToken { get; set; }
public McpToolConnectorId? ConnectorId { get; set; }
public IDictionary<string, string> Headers { get; set; }
public string ServerDescription { get; set; }
public string ServerLabel { get; set; }
public Uri ServerUri { get; set; }
public McpToolCallApprovalPolicy ToolCallApprovalPolicy { get; set; }
Expand Down Expand Up @@ -4956,6 +4960,28 @@ public class McpToolCallItem : ResponseItem, IJsonModel<McpToolCallItem>, IPersi
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
[Experimental("OPENAI001")]
public readonly partial struct McpToolConnectorId : IEquatable<McpToolConnectorId> {
public McpToolConnectorId(string value);
public static McpToolConnectorId Dropbox { get; }
public static McpToolConnectorId Gmail { get; }
public static McpToolConnectorId GoogleCalendar { get; }
public static McpToolConnectorId GoogleDrive { get; }
public static McpToolConnectorId MicrosoftTeams { get; }
public static McpToolConnectorId OutlookCalendar { get; }
public static McpToolConnectorId OutlookEmail { get; }
public static McpToolConnectorId SharePoint { get; }
public readonly bool Equals(McpToolConnectorId other);
[EditorBrowsable(EditorBrowsableState.Never)]
public override readonly bool Equals(object obj);
[EditorBrowsable(EditorBrowsableState.Never)]
public override readonly int GetHashCode();
public static bool operator ==(McpToolConnectorId left, McpToolConnectorId right);
public static implicit operator McpToolConnectorId(string value);
public static implicit operator McpToolConnectorId?(string value);
public static bool operator !=(McpToolConnectorId left, McpToolConnectorId right);
public override readonly string ToString();
}
[Experimental("OPENAI001")]
public class McpToolDefinition : IJsonModel<McpToolDefinition>, IPersistableModel<McpToolDefinition> {
public McpToolDefinition(string name, BinaryData inputSchema);
public BinaryData Annotations { get; set; }
Expand All @@ -4980,6 +5006,7 @@ public class McpToolDefinitionListItem : ResponseItem, IJsonModel<McpToolDefinit
}
[Experimental("OPENAI001")]
public class McpToolFilter : IJsonModel<McpToolFilter>, IPersistableModel<McpToolFilter> {
public bool? IsReadOnly { get; set; }
public IList<string> ToolNames { get; }
protected virtual McpToolFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
Expand Down Expand Up @@ -5053,6 +5080,8 @@ public class OpenAIResponseClient {
public OpenAIResponseClient(string model, string apiKey);
[Experimental("OPENAI001")]
public Uri Endpoint { get; }
[Experimental("OPENAI001")]
public string Model { get; }
public ClientPipeline Pipeline { get; }
public virtual ClientResult CancelResponse(string responseId, RequestOptions options);
public virtual ClientResult<OpenAIResponse> CancelResponse(string responseId, CancellationToken cancellationToken = default);
Expand Down Expand Up @@ -5491,7 +5520,8 @@ public class ResponseTool : IJsonModel<ResponseTool>, IPersistableModel<Response
public static ComputerTool CreateComputerTool(ComputerToolEnvironment environment, int displayWidth, int displayHeight);
public static FileSearchTool CreateFileSearchTool(IEnumerable<string> vectorStoreIds, int? maxResultCount = null, FileSearchToolRankingOptions rankingOptions = null, BinaryData filters = null);
public static FunctionTool CreateFunctionTool(string functionName, BinaryData functionParameters, bool? strictModeEnabled, string functionDescription = null);
public static McpTool CreateMcpTool(string serverLabel, Uri serverUri, IDictionary<string, string> headers = null, McpToolFilter allowedTools = null, McpToolCallApprovalPolicy toolCallApprovalPolicy = null);
public static McpTool CreateMcpTool(string serverLabel, McpToolConnectorId connectorId, string authorizationToken = null, string serverDescription = null, IDictionary<string, string> headers = null, McpToolFilter allowedTools = null, McpToolCallApprovalPolicy toolCallApprovalPolicy = null);
public static McpTool CreateMcpTool(string serverLabel, Uri serverUri, string authorizationToken = null, string serverDescription = null, IDictionary<string, string> headers = null, McpToolFilter allowedTools = null, McpToolCallApprovalPolicy toolCallApprovalPolicy = null);
public static WebSearchTool CreateWebSearchTool(WebSearchToolLocation userLocation = null, WebSearchToolContextSize? searchContextSize = null);
protected virtual ResponseTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
Expand Down Expand Up @@ -5679,13 +5709,17 @@ public class StreamingResponseMcpCallArgumentsDoneUpdate : StreamingResponseUpda
}
[Experimental("OPENAI001")]
public class StreamingResponseMcpCallCompletedUpdate : StreamingResponseUpdate, IJsonModel<StreamingResponseMcpCallCompletedUpdate>, IPersistableModel<StreamingResponseMcpCallCompletedUpdate> {
public string ItemId { get; }
public int OutputIndex { get; }
protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
[Experimental("OPENAI001")]
public class StreamingResponseMcpCallFailedUpdate : StreamingResponseUpdate, IJsonModel<StreamingResponseMcpCallFailedUpdate>, IPersistableModel<StreamingResponseMcpCallFailedUpdate> {
public string ItemId { get; }
public int OutputIndex { get; }
protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
Expand All @@ -5702,20 +5736,26 @@ public class StreamingResponseMcpCallInProgressUpdate : StreamingResponseUpdate,
}
[Experimental("OPENAI001")]
public class StreamingResponseMcpListToolsCompletedUpdate : StreamingResponseUpdate, IJsonModel<StreamingResponseMcpListToolsCompletedUpdate>, IPersistableModel<StreamingResponseMcpListToolsCompletedUpdate> {
public string ItemId { get; }
public int OutputIndex { get; }
protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
[Experimental("OPENAI001")]
public class StreamingResponseMcpListToolsFailedUpdate : StreamingResponseUpdate, IJsonModel<StreamingResponseMcpListToolsFailedUpdate>, IPersistableModel<StreamingResponseMcpListToolsFailedUpdate> {
public string ItemId { get; }
public int OutputIndex { get; }
protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
[Experimental("OPENAI001")]
public class StreamingResponseMcpListToolsInProgressUpdate : StreamingResponseUpdate, IJsonModel<StreamingResponseMcpListToolsInProgressUpdate>, IPersistableModel<StreamingResponseMcpListToolsInProgressUpdate> {
public string ItemId { get; }
public int OutputIndex { get; }
protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
Expand Down
40 changes: 39 additions & 1 deletion api/OpenAI.netstandard2.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4304,9 +4304,13 @@ public class FunctionTool : ResponseTool, IJsonModel<FunctionTool>, IPersistable
public override readonly string ToString();
}
public class McpTool : ResponseTool, IJsonModel<McpTool>, IPersistableModel<McpTool> {
public McpTool(string serverLabel, McpToolConnectorId connectorId);
public McpTool(string serverLabel, Uri serverUri);
public McpToolFilter AllowedTools { get; set; }
public string AuthorizationToken { get; set; }
public McpToolConnectorId? ConnectorId { get; set; }
public IDictionary<string, string> Headers { get; set; }
public string ServerDescription { get; set; }
public string ServerLabel { get; set; }
public Uri ServerUri { get; set; }
public McpToolCallApprovalPolicy ToolCallApprovalPolicy { get; set; }
Expand Down Expand Up @@ -4357,6 +4361,27 @@ public class McpToolCallItem : ResponseItem, IJsonModel<McpToolCallItem>, IPersi
protected override ResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
public readonly partial struct McpToolConnectorId : IEquatable<McpToolConnectorId> {
public McpToolConnectorId(string value);
public static McpToolConnectorId Dropbox { get; }
public static McpToolConnectorId Gmail { get; }
public static McpToolConnectorId GoogleCalendar { get; }
public static McpToolConnectorId GoogleDrive { get; }
public static McpToolConnectorId MicrosoftTeams { get; }
public static McpToolConnectorId OutlookCalendar { get; }
public static McpToolConnectorId OutlookEmail { get; }
public static McpToolConnectorId SharePoint { get; }
public readonly bool Equals(McpToolConnectorId other);
[EditorBrowsable(EditorBrowsableState.Never)]
public override readonly bool Equals(object obj);
[EditorBrowsable(EditorBrowsableState.Never)]
public override readonly int GetHashCode();
public static bool operator ==(McpToolConnectorId left, McpToolConnectorId right);
public static implicit operator McpToolConnectorId(string value);
public static implicit operator McpToolConnectorId?(string value);
public static bool operator !=(McpToolConnectorId left, McpToolConnectorId right);
public override readonly string ToString();
}
public class McpToolDefinition : IJsonModel<McpToolDefinition>, IPersistableModel<McpToolDefinition> {
public McpToolDefinition(string name, BinaryData inputSchema);
public BinaryData Annotations { get; set; }
Expand All @@ -4379,6 +4404,7 @@ public class McpToolDefinitionListItem : ResponseItem, IJsonModel<McpToolDefinit
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
public class McpToolFilter : IJsonModel<McpToolFilter>, IPersistableModel<McpToolFilter> {
public bool? IsReadOnly { get; set; }
public IList<string> ToolNames { get; }
protected virtual McpToolFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
Expand Down Expand Up @@ -4446,6 +4472,7 @@ public class OpenAIResponseClient {
public OpenAIResponseClient(string model, AuthenticationPolicy authenticationPolicy);
public OpenAIResponseClient(string model, string apiKey);
public Uri Endpoint { get; }
public string Model { get; }
public ClientPipeline Pipeline { get; }
public virtual ClientResult CancelResponse(string responseId, RequestOptions options);
public virtual ClientResult<OpenAIResponse> CancelResponse(string responseId, CancellationToken cancellationToken = default);
Expand Down Expand Up @@ -4849,7 +4876,8 @@ public class ResponseTool : IJsonModel<ResponseTool>, IPersistableModel<Response
public static ComputerTool CreateComputerTool(ComputerToolEnvironment environment, int displayWidth, int displayHeight);
public static FileSearchTool CreateFileSearchTool(IEnumerable<string> vectorStoreIds, int? maxResultCount = null, FileSearchToolRankingOptions rankingOptions = null, BinaryData filters = null);
public static FunctionTool CreateFunctionTool(string functionName, BinaryData functionParameters, bool? strictModeEnabled, string functionDescription = null);
public static McpTool CreateMcpTool(string serverLabel, Uri serverUri, IDictionary<string, string> headers = null, McpToolFilter allowedTools = null, McpToolCallApprovalPolicy toolCallApprovalPolicy = null);
public static McpTool CreateMcpTool(string serverLabel, McpToolConnectorId connectorId, string authorizationToken = null, string serverDescription = null, IDictionary<string, string> headers = null, McpToolFilter allowedTools = null, McpToolCallApprovalPolicy toolCallApprovalPolicy = null);
public static McpTool CreateMcpTool(string serverLabel, Uri serverUri, string authorizationToken = null, string serverDescription = null, IDictionary<string, string> headers = null, McpToolFilter allowedTools = null, McpToolCallApprovalPolicy toolCallApprovalPolicy = null);
public static WebSearchTool CreateWebSearchTool(WebSearchToolLocation userLocation = null, WebSearchToolContextSize? searchContextSize = null);
protected virtual ResponseTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
Expand Down Expand Up @@ -5017,12 +5045,16 @@ public class StreamingResponseMcpCallArgumentsDoneUpdate : StreamingResponseUpda
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
public class StreamingResponseMcpCallCompletedUpdate : StreamingResponseUpdate, IJsonModel<StreamingResponseMcpCallCompletedUpdate>, IPersistableModel<StreamingResponseMcpCallCompletedUpdate> {
public string ItemId { get; }
public int OutputIndex { get; }
protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
public class StreamingResponseMcpCallFailedUpdate : StreamingResponseUpdate, IJsonModel<StreamingResponseMcpCallFailedUpdate>, IPersistableModel<StreamingResponseMcpCallFailedUpdate> {
public string ItemId { get; }
public int OutputIndex { get; }
protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
Expand All @@ -5037,18 +5069,24 @@ public class StreamingResponseMcpCallInProgressUpdate : StreamingResponseUpdate,
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
public class StreamingResponseMcpListToolsCompletedUpdate : StreamingResponseUpdate, IJsonModel<StreamingResponseMcpListToolsCompletedUpdate>, IPersistableModel<StreamingResponseMcpListToolsCompletedUpdate> {
public string ItemId { get; }
public int OutputIndex { get; }
protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
public class StreamingResponseMcpListToolsFailedUpdate : StreamingResponseUpdate, IJsonModel<StreamingResponseMcpListToolsFailedUpdate>, IPersistableModel<StreamingResponseMcpListToolsFailedUpdate> {
public string ItemId { get; }
public int OutputIndex { get; }
protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
public class StreamingResponseMcpListToolsInProgressUpdate : StreamingResponseUpdate, IJsonModel<StreamingResponseMcpListToolsInProgressUpdate>, IPersistableModel<StreamingResponseMcpListToolsInProgressUpdate> {
public string ItemId { get; }
public int OutputIndex { get; }
protected override StreamingResponseUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected override StreamingResponseUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
Expand Down
11 changes: 3 additions & 8 deletions examples/Responses/Example05_RemoteMcp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@ public partial class ResponseExamples
[Test]
public void Example05_RemoteMcp()
{
// This is a dice rolling MCP server.
string serverLabel = "dmcp";
Uri serverUri = new Uri("https://dmcp-server.deno.dev/sse");

McpToolCallApprovalPolicy approvalPolicy = new McpToolCallApprovalPolicy(GlobalMcpToolCallApprovalPolicy.NeverRequireApproval);

ResponseCreationOptions options = new()
{
Tools = {
new McpTool(serverLabel, serverUri)
new McpTool(serverLabel: "dmcp", serverUri: new Uri("https://dmcp-server.deno.dev/sse"))
{
ToolCallApprovalPolicy = approvalPolicy
ServerDescription = "A Dungeons and Dragons MCP server to assist with dice rolling.",
ToolCallApprovalPolicy = new McpToolCallApprovalPolicy(GlobalMcpToolCallApprovalPolicy.NeverRequireApproval)
}
}
};
Expand Down
Loading