Skip to content

MCP client resources/read calls corrupt certain template URIs #251941

Open
@eiriktsarpalis

Description

@eiriktsarpalis

Type: Bug

Hi, I maintain the official C# SDK and I am currently investigating customer reports that certain resources/read calls from the VS Code MCP client to C# MCP servers are failing. I have been able to create the following minimal reproduction:

using ModelContextProtocol.Server;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMcpServer()
    .WithHttpTransport()
    .WithResources<SimpleResourceType>();

var app = builder.Build();
app.MapMcp();
app.Run();

[McpServerResourceType]
public class SimpleResourceType
{
    [McpServerResource(UriTemplate = "resource:///DirectTextResource", MimeType = "text/plain")]
    public static string DirectTextResource() => "This is a direct resource";
}

The issue appears to be caused by the fact that the VS Code client is normalizing the reported resource:///DirectTextResource URI to resource://directtextresource, i.e:

  1. It trims the third / character, making its name part of the host segment of the uri when in fact it was part of its path.
  2. It converts the name to all-lowercase, even though URI paths are case sensitive.

This effectively changes the URI, meaning that the server responds with an error because it cannot find the requested resource.

VS Code version: Code 1.101.1 (18e3a1e, 2025-06-18T13:35:12.605Z)
OS version: Windows_NT arm64 10.0.26100
Modes:

System Info
Item Value
CPUs Apple Silicon (8 x 3200)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: unavailable_off
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 19.99GB (3.47GB free)
Process Argv --disable-extensions --crash-reporter-id bcbd6c16-914e-4ec8-9d99-80056caf9469
Screen Reader no
VM 100%
Extensions disabled
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vscod805cf:30301675
binariesv615:30325510
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dwnewjupyter:31046869
pythonrstrctxt:31112756
nativeloc2:31192216
5fd0e150:31155592
dwcopilot:31170013
471b6256:31240254
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
hdaa2157:31222309
copilot_t_ci:31222730
e5gg6876:31282496
pythoneinst12:31285622
bgtreat:31268568
4gafe986:31271826
c7cif404:31314491
e77a2192:31326280
6gi0g917:31259952
996jf627:31283433
pythonrdcb7cf:31303019
usemplatestapi:31297334
0aa6g176:31307128
7bj51361:31289155
747dc170:31275177
aj953862:31281341
generatesymbolt:31295002
convertfstringf:31295003
pylancequickfixt:31329274
d784b465:31327030
usemarketplace:31331644
nesew2to15:31330639
1292j425:31329156
agentclaude:31331946
048e0538:31329543

cc @stephentoub @halter73

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions