Remove server back-references from protocol DTO types#1345
Open
Remove server back-references from protocol DTO types#1345
Conversation
…izationFilterSetup to use collection-based lookups Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Remove back-reference properties from DTO types
Remove server back-references from protocol DTO types
Feb 21, 2026
stephentoub
approved these changes
Feb 21, 2026
Contributor
stephentoub
left a comment
There was a problem hiding this comment.
@copilot are there tests fully validating all of these modified code paths? If not, please augment existing tests / test classes to provide full coverage, e.g. when collections are and are not available, when the primitives are and are not in the collection, etc.
| @@ -102,9 +101,4 @@ public sealed class Resource : IBaseMetadata | |||
| [JsonPropertyName("_meta")] | |||
| public JsonObject? Meta { get; set; } | |||
|
|
|||
…ests for null collections and primitives not in collections Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Contributor
Author
Added 5 new tests in
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The protocol DTOs (
Tool,Prompt,Resource,ResourceTemplate) each had a[JsonIgnore]property referencing their corresponding server primitive (McpServerTool,McpServerPrompt,McpServerResource), coupling the protocol layer to server-side concerns.Changes
Protocol DTOs — Removed
McpServerTool,McpServerPrompt, andMcpServerResourceback-reference properties and the now-unusedusing ModelContextProtocol.Serverimports fromTool.cs,Prompt.cs,Resource.cs, andResourceTemplate.cs. Also removed theMcpServerResource = McpServerResourcecopy inResourceTemplate.AsResource().AIFunction constructors* — Removed the back-reference assignments (
ProtocolTool.McpServerTool = this, etc.) fromAIFunctionMcpServerTool,AIFunctionMcpServerPrompt, andAIFunctionMcpServerResource.AuthorizationFilterSetup— Replaced back-reference navigation (tool.McpServerTool,prompt.McpServerPrompt,resource.McpServerResource) with O(1) name-based lookups against the collections already available onMcpServerOptions:The
CallTool,GetPrompt, andReadResourcefilters are unchanged — they already usecontext.MatchedPrimitiveset directly by the server infrastructure.AuthorizeAttributeTestscovering the new authorization filter code paths:ToolCollection/PromptCollection/ResourceCollectionis null (custom handler only), items are not filtered since no collection lookup is possible.ToolCollection, it is not subject to auth filtering; only items found in the collection are checked.Original prompt
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.