Remove server back-references from protocol DTO types (#1345)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
This commit is contained in:
Copilot 2026-02-23 14:17:54 -05:00 • committed by GitHub
commit 74622d0c9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 195 additions and 96 deletions

View file

@ -1,7 +1,6 @@
using System.Diagnostics;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using ModelContextProtocol.Server;
namespace ModelContextProtocol.Protocol;
@ -72,12 +71,6 @@ public sealed class Prompt : IBaseMetadata
[JsonPropertyName("_meta")]
public JsonObject? Meta { get; set; }
/// <summary>
/// Gets or sets the callable server prompt corresponding to this metadata if any.
/// </summary>
[JsonIgnore]
public McpServerPrompt? McpServerPrompt { get; set; }
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string DebuggerDisplay
{

View file

@ -2,7 +2,6 @@ using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using ModelContextProtocol.Server;
namespace ModelContextProtocol.Protocol;
@ -101,10 +100,4 @@ public sealed class Resource : IBaseMetadata
/// </remarks>
[JsonPropertyName("_meta")]
public JsonObject? Meta { get; set; }
/// <summary>
/// Gets or sets the callable server resource corresponding to this metadata if any.
/// </summary>
[JsonIgnore]
public McpServerResource? McpServerResource { get; set; }
}

View file

@ -1,6 +1,5 @@
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using ModelContextProtocol.Server;
namespace ModelContextProtocol.Protocol;
@ -94,12 +93,6 @@ public sealed class ResourceTemplate : IBaseMetadata
[JsonIgnore]
public bool IsTemplated => UriTemplate.Contains('{');
/// <summary>
/// Gets or sets the callable server resource corresponding to this metadata, if any.
/// </summary>
[JsonIgnore]
public McpServerResource? McpServerResource { get; set; }
/// <summary>Converts the <see cref="ResourceTemplate"/> into a <see cref="Resource"/>.</summary>
/// <returns>A <see cref="Resource"/> if <see cref="IsTemplated"/> is <see langword="false"/>; otherwise, <see langword="null"/>.</returns>
public Resource? AsResource()
@ -119,7 +112,6 @@ public sealed class ResourceTemplate : IBaseMetadata
Annotations = Annotations,
Icons = Icons,
Meta = Meta,
McpServerResource = McpServerResource,
};
}
}

View file

@ -1,4 +1,3 @@
using ModelContextProtocol.Server;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
@ -158,12 +157,6 @@ public sealed class Tool : IBaseMetadata
[JsonPropertyName("_meta")]
public JsonObject? Meta { get; set; }
/// <summary>
/// Gets or sets the callable server tool corresponding to this metadata if any.
/// </summary>
[JsonIgnore]
public McpServerTool? McpServerTool { get; set; }
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string DebuggerDisplay
{

View file

@ -182,7 +182,6 @@ internal sealed class AIFunctionMcpServerPrompt : McpServerPrompt
{
AIFunction = function;
ProtocolPrompt = prompt;
ProtocolPrompt.McpServerPrompt = this;
_metadata = metadata;
}

View file

@ -294,7 +294,6 @@ internal sealed class AIFunctionMcpServerResource : McpServerResource
{
AIFunction = function;
ProtocolResourceTemplate = resourceTemplate;
ProtocolResourceTemplate.McpServerResource = this;
ProtocolResource = resourceTemplate.AsResource();
_metadata = metadata;

View file

@ -234,7 +234,6 @@ internal sealed partial class AIFunctionMcpServerTool : McpServerTool
AIFunction = function;
ProtocolTool = tool;
ProtocolTool.McpServerTool = this;
_structuredOutputRequiresWrapping = structuredOutputRequiresWrapping;
_metadata = metadata;