Description
Describe the bug
If one uses the WithResources to add the resource (like it is done in samples\EverythingServer) then the mcp-server in the initialization doesn't list the resources in the capabilities. An explicit WithListResourcesHandler & WithReadResourceHandler works fine.
To Reproduce
Steps to reproduce the behavior:
- Clone the csharp-sdk repo with preview.13
- Build the samples\EverythingServer
- Run npx @modelcontextprotocol/inspector dotnet run --project d:/tmp/mcp/csharp-sdk/samples/EverythingServer --no-build
- In the inspector tool Resources tab is disabled
- The output of initialize is {
"capabilities": {
"logging": {},
"completions": {},
"prompts": {
"listChanged": true
},
"tools": {
"listChanged": true
}
},
"serverInfo": {
"name": "EverythingServer",
"version": "1.0.0.0"
}
}
Expected behavior
The resource should be listed in the capabilities, and one should be able to list and read the resources.
Logs
Not needed. The issue can be reproduced from the samples.
Additional context
In the claude desktop app. I see the following logs regarding this issue for the EverythingServer sample
2025-05-13T05:56:29.887Z [EverythingServer] [info] Message from client: {"method":"resources/list","params":{},"jsonrpc":"2.0","id":9}
warn: ModelContextProtocol.Server.McpServer[2049951654]
Server (EverythingServer 1.0.0.0), Client (claude-ai 0.1.0) received request for method 'resources/list', but no handler is available.
warn: ModelContextProtocol.Server.McpServer[975074943]
Server (EverythingServer 1.0.0.0), Client (claude-ai 0.1.0) method 'resources/list' request handler failed.
ModelContextProtocol.McpException: Method 'resources/list' is not available.
at ModelContextProtocol.Shared.McpSession.HandleRequest(JsonRpcRequest request, CancellationToken cancellationToken) in D:\tmp\mcp\csharp-sdk\src\ModelContextProtocol\Shared\McpSession.cs:line 301
at ModelContextProtocol.Shared.McpSession.HandleMessageAsync(JsonRpcMessage message, CancellationToken cancellationToken) in D:\tmp\mcp\csharp-sdk\src\ModelContextProtocol\Shared\McpSession.cs:line 232
at ModelContextProtocol.Shared.McpSession.<>c__DisplayClass21_1.<g__ProcessMessageAsync|0>d.MoveNext() in D:\tmp\mcp\csharp-sdk\src\ModelContextProtocol\Shared\McpSession.cs:line 133
2025-05-13T05:56:29.890Z [EverythingServer] [info] Message from server: {"jsonrpc":"2.0","id":9,"error":{"code":-32601,"message":"Method 'resources/list' is not available."}}