Skip to content

Commit c47ce7f

Browse files
nick863adarcejsquire
authored
Fix MCP deserialization (#51590)
* Update for KeyVault CODEOWNERS (#51578) * Update for KeyVault CODEOWNERS This adds the `azure-sdk-write-keyvault` team as code owners. * Update .github/CODEOWNERS * Update .github/CODEOWNERS --------- Co-authored-by: Jesse Squire <jesse.squire@gmail.com> * Fix the deserialization of MCP tool resource * Regenerate code --------- Co-authored-by: Adriano Arce <adarce@users.noreply.github.com> Co-authored-by: Jesse Squire <jesse.squire@gmail.com>
1 parent a1b09f1 commit c47ce7f

18 files changed

+584
-105
lines changed

sdk/ai/Azure.AI.Agents.Persistent/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
### Bugs Fixed
1212

13+
- Fixed the deserialization issue, when agent service returns the customized lists of trusted and requiring authentication MCP tools.
14+
1315
### Other Changes
1416

1517
### Sample updates

sdk/ai/Azure.AI.Agents.Persistent/api/Azure.AI.Agents.Persistent.net8.0.cs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,18 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer
538538
public static bool operator !=(Azure.AI.Agents.Persistent.ListSortOrder left, Azure.AI.Agents.Persistent.ListSortOrder right) { throw null; }
539539
public override string ToString() { throw null; }
540540
}
541+
public partial class MCPApprovalPerTool : System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPApprovalPerTool>, System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPApprovalPerTool>
542+
{
543+
public MCPApprovalPerTool() { }
544+
public Azure.AI.Agents.Persistent.MCPToolList Always { get { throw null; } set { } }
545+
public Azure.AI.Agents.Persistent.MCPToolList Never { get { throw null; } set { } }
546+
protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
547+
Azure.AI.Agents.Persistent.MCPApprovalPerTool System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPApprovalPerTool>.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
548+
void System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPApprovalPerTool>.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
549+
Azure.AI.Agents.Persistent.MCPApprovalPerTool System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPApprovalPerTool>.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
550+
string System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPApprovalPerTool>.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
551+
System.BinaryData System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPApprovalPerTool>.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
552+
}
541553
public partial class MCPToolDefinition : Azure.AI.Agents.Persistent.ToolDefinition, System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPToolDefinition>, System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolDefinition>
542554
{
543555
public MCPToolDefinition(string serverLabel, string serverUrl) { }
@@ -551,12 +563,23 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write
551563
string System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolDefinition>.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
552564
System.BinaryData System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolDefinition>.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
553565
}
566+
public partial class MCPToolList : System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPToolList>, System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolList>
567+
{
568+
public MCPToolList(System.Collections.Generic.IEnumerable<string> toolNames) { }
569+
public System.Collections.Generic.IList<string> ToolNames { get { throw null; } }
570+
protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
571+
Azure.AI.Agents.Persistent.MCPToolList System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPToolList>.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
572+
void System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPToolList>.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
573+
Azure.AI.Agents.Persistent.MCPToolList System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolList>.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
574+
string System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolList>.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
575+
System.BinaryData System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolList>.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
576+
}
554577
public partial class MCPToolResource : System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPToolResource>, System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolResource>
555578
{
556579
public MCPToolResource(string serverLabel) { }
557580
public MCPToolResource(string serverLabel, System.Collections.Generic.IDictionary<string, string> headers) { }
558581
public System.Collections.Generic.IDictionary<string, string> Headers { get { throw null; } }
559-
public Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval? RequireApproval { get { throw null; } set { } }
582+
public System.BinaryData RequireApproval { get { throw null; } set { } }
560583
public string ServerLabel { get { throw null; } set { } }
561584
protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
562585
Azure.AI.Agents.Persistent.MCPToolResource System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPToolResource>.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
@@ -567,24 +590,6 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer
567590
public Azure.AI.Agents.Persistent.ToolResources ToToolResources() { throw null; }
568591
public void UpdateHeader(string key, string value) { }
569592
}
570-
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
571-
public readonly partial struct MCPToolResourceRequireApproval : System.IEquatable<Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval>
572-
{
573-
private readonly object _dummy;
574-
private readonly int _dummyPrimitive;
575-
public MCPToolResourceRequireApproval(string value) { throw null; }
576-
public static Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval Always { get { throw null; } }
577-
public static Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval Never { get { throw null; } }
578-
public bool Equals(Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval other) { throw null; }
579-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
580-
public override bool Equals(object obj) { throw null; }
581-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
582-
public override int GetHashCode() { throw null; }
583-
public static bool operator ==(Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval left, Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval right) { throw null; }
584-
public static implicit operator Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval (string value) { throw null; }
585-
public static bool operator !=(Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval left, Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval right) { throw null; }
586-
public override string ToString() { throw null; }
587-
}
588593
public partial class MessageAttachment : System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MessageAttachment>, System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MessageAttachment>
589594
{
590595
public MessageAttachment(Azure.AI.Agents.Persistent.VectorStoreDataSource ds, System.Collections.Generic.List<Azure.AI.Agents.Persistent.ToolDefinition> tools) { }

sdk/ai/Azure.AI.Agents.Persistent/api/Azure.AI.Agents.Persistent.netstandard2.0.cs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,18 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer
538538
public static bool operator !=(Azure.AI.Agents.Persistent.ListSortOrder left, Azure.AI.Agents.Persistent.ListSortOrder right) { throw null; }
539539
public override string ToString() { throw null; }
540540
}
541+
public partial class MCPApprovalPerTool : System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPApprovalPerTool>, System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPApprovalPerTool>
542+
{
543+
public MCPApprovalPerTool() { }
544+
public Azure.AI.Agents.Persistent.MCPToolList Always { get { throw null; } set { } }
545+
public Azure.AI.Agents.Persistent.MCPToolList Never { get { throw null; } set { } }
546+
protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
547+
Azure.AI.Agents.Persistent.MCPApprovalPerTool System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPApprovalPerTool>.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
548+
void System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPApprovalPerTool>.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
549+
Azure.AI.Agents.Persistent.MCPApprovalPerTool System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPApprovalPerTool>.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
550+
string System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPApprovalPerTool>.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
551+
System.BinaryData System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPApprovalPerTool>.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
552+
}
541553
public partial class MCPToolDefinition : Azure.AI.Agents.Persistent.ToolDefinition, System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPToolDefinition>, System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolDefinition>
542554
{
543555
public MCPToolDefinition(string serverLabel, string serverUrl) { }
@@ -551,12 +563,23 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write
551563
string System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolDefinition>.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
552564
System.BinaryData System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolDefinition>.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
553565
}
566+
public partial class MCPToolList : System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPToolList>, System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolList>
567+
{
568+
public MCPToolList(System.Collections.Generic.IEnumerable<string> toolNames) { }
569+
public System.Collections.Generic.IList<string> ToolNames { get { throw null; } }
570+
protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
571+
Azure.AI.Agents.Persistent.MCPToolList System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPToolList>.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
572+
void System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPToolList>.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
573+
Azure.AI.Agents.Persistent.MCPToolList System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolList>.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
574+
string System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolList>.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
575+
System.BinaryData System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolList>.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
576+
}
554577
public partial class MCPToolResource : System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPToolResource>, System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MCPToolResource>
555578
{
556579
public MCPToolResource(string serverLabel) { }
557580
public MCPToolResource(string serverLabel, System.Collections.Generic.IDictionary<string, string> headers) { }
558581
public System.Collections.Generic.IDictionary<string, string> Headers { get { throw null; } }
559-
public Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval? RequireApproval { get { throw null; } set { } }
582+
public System.BinaryData RequireApproval { get { throw null; } set { } }
560583
public string ServerLabel { get { throw null; } set { } }
561584
protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
562585
Azure.AI.Agents.Persistent.MCPToolResource System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MCPToolResource>.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
@@ -567,24 +590,6 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer
567590
public Azure.AI.Agents.Persistent.ToolResources ToToolResources() { throw null; }
568591
public void UpdateHeader(string key, string value) { }
569592
}
570-
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
571-
public readonly partial struct MCPToolResourceRequireApproval : System.IEquatable<Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval>
572-
{
573-
private readonly object _dummy;
574-
private readonly int _dummyPrimitive;
575-
public MCPToolResourceRequireApproval(string value) { throw null; }
576-
public static Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval Always { get { throw null; } }
577-
public static Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval Never { get { throw null; } }
578-
public bool Equals(Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval other) { throw null; }
579-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
580-
public override bool Equals(object obj) { throw null; }
581-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
582-
public override int GetHashCode() { throw null; }
583-
public static bool operator ==(Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval left, Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval right) { throw null; }
584-
public static implicit operator Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval (string value) { throw null; }
585-
public static bool operator !=(Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval left, Azure.AI.Agents.Persistent.MCPToolResourceRequireApproval right) { throw null; }
586-
public override string ToString() { throw null; }
587-
}
588593
public partial class MessageAttachment : System.ClientModel.Primitives.IJsonModel<Azure.AI.Agents.Persistent.MessageAttachment>, System.ClientModel.Primitives.IPersistableModel<Azure.AI.Agents.Persistent.MessageAttachment>
589594
{
590595
public MessageAttachment(Azure.AI.Agents.Persistent.VectorStoreDataSource ds, System.Collections.Generic.List<Azure.AI.Agents.Persistent.ToolDefinition> tools) { }

sdk/ai/Azure.AI.Agents.Persistent/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/ai/Azure.AI.Agents.Persistent",
5-
"Tag": "net/ai/Azure.AI.Agents.Persistent_1bbfa82f8b"
5+
"Tag": "net/ai/Azure.AI.Agents.Persistent_824188de68"
66
}

sdk/ai/Azure.AI.Agents.Persistent/samples/Sample26_PersistentAgents_MCP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ while (run.Status == RunStatus.Queued || run.Status == RunStatus.InProgress || r
7575
{
7676
if (toolCall is RequiredMcpToolCall mcpToolCall)
7777
{
78-
Console.WriteLine($"Approving MCP tool call: {mcpToolCall.Name}");
78+
Console.WriteLine($"Approving MCP tool call: {mcpToolCall.Name}, Arguments: {mcpToolCall.Arguments}");
7979
toolApprovals.Add(new ToolApproval(mcpToolCall.Id, approve: true)
8080
{
8181
Headers = { ["SuperSecret"] = "123456" }

0 commit comments

Comments
 (0)