Static resources whose URIs differ only in the fragment or user info collapse into one
Maintainer thường phản hồi trong vòng 1 ngày
@halter73 đang làm issue này rồi.
Từ ngày 11/11/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu với UriTemplateComparer trong UriTemplate.cs quanh các dòng 502-519 và các kiểm thử host-case hiện có của nó; thay đổi được đề xuất thêm so sánh fragment và user-info. Sau đó kiểm tra đường dẫn đăng ký resource trong McpServerOptionsSetup.cs:63 và các cách dùng ở hạ nguồn của comparer trong AIFunctionMcpServerResource.cs:325 và McpClient.Methods.cs:832. Thêm một kiểm thử hồi quy trong McpServerResourceTests với hai tài nguyên chỉ khác nhau ở fragment và một lần đọc tài nguyên thứ hai; hoàn tất khi cả hai được liệt kê và mỗi lần đọc trả về body riêng của nó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Two static resources whose URIs differ only in the fragment collapse into one. WithResources silently drops the second, and reading it returns the first.
Repro at 5221939, in-process over two Pipes:
services.AddMcpServer().WithResources([
McpServerResource.Create(() => "intro text", new() { UriTemplate = "docs://guide#intro", Name = "intro" }),
McpServerResource.Create(() => "setup text", new() { UriTemplate = "docs://guide#setup", Name = "setup" }),
]);
// ...McpServer.Create over StreamServerTransport, McpClient.CreateAsync over StreamClientTransport
foreach (var r in await client.ListResourcesAsync()) Console.WriteLine($"listed: {r.Uri}");
var read = await client.ReadResourceAsync("docs://guide#setup");
$ dotnet run -c Release # net10.0, SDK 10.0.403, ProjectReference to src/ModelContextProtocol at 5221939
listed: docs://guide#intro
read docs://guide#setup -> intro text
Expected: both listed, and the read returns setup text. A server exposing one resource per heading anchor loses every section after the first, with no error. The spec says each resource "is uniquely identified by a URI" (server/resources), and RFC 3986 section 3 puts the fragment in it. Section 3.5 strips it for dereference, not for two entries a server registered.
UriTemplateComparer (UriTemplate.cs:502) says it uses "regular System.Uri equality comparison (host name is case insensitive)", and its tests cover host case only. Uri.Equals also ignores UserInfo and Fragment, so docs://alice@host/x and docs://bob@host/x collide too. McpServerOptionsSetup.cs:63 uses TryAdd, so nothing throws.
I'd keep System.Uri and add && uri1.UserInfo == uri2.UserInfo && uri1.Fragment == uri2.Fragment at line 519:
$ dotnet run -c Release # same app, with that change at UriTemplate.cs:519
listed: docs://guide#intro
listed: docs://guide#setup
read docs://guide#setup -> setup text
# not run: test suite with the change
The comparer also backs IsMatch (AIFunctionMcpServerResource.cs:325) and the SubscribeToResourceAsync filter (McpClient.Methods.cs:832), so a read or update for docs://guide#x would stop matching a static docs://guide. That fits the spec but changes behavior for clients sending fragments today. Shall I open that pull request with a test in McpServerResourceTests?
- Ngôn ngữ chính
- C#
- Star
- 4.6k
- Fork
- 849
- Merge trung bình
- 1 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 24
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/csharp-sdk
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
modelcontextprotocol/csharp-sdk#2031 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
POST /mcp with a missing or unparseable Content-Type returns HTTP 500 instead of a 4xxCó thể đã có người làm @halter73 đã nhận 9 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelcontextprotocol/csharp-sdk#1966 · 5 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Reserved URI-template expansion throws for supplementary Unicode charactersCó thể đã có người làm @tarekgh đã nhận 2 ngày trước. Đang mởP3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
modelcontextprotocol/csharp-sdk#1913 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ClaimsPrincipal parameter injection sample requestCó thể đã có người làm @utsavjain2809 đã nhận 48 ngày trước. Đang mởhelp wanted P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
modelcontextprotocol/csharp-sdk#1899 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Document ClientOAuthOptions.ScopeSelector usageCó thể đã có người làm @z0rimo đã nhận 71 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
modelcontextprotocol/csharp-sdk#1867 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/csharp-sdk
Issue tương tự
-
account bug effort:S P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
nightscout/nocturne#3745 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
jsboige/CoursIA#27768 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
martin-stromberg/FinanceManager#562 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
:eyeglasses: status: needs review needs-area-label
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
gitextensions/gitextensions#13469 ·
Maintainer thường phản hồi trong vòng 2 ngày