Describe the bug
I just defined two resources to test,
[McpServerResource(MimeType = "text/json",UriTemplate ="KBInfo://summary"), Description("Get this mcp's Knowledge summary info")]
public static string KBSummary()
{
var allReadme = Directory.GetFiles("./KB", "x.md", SearchOption.AllDirectories);
var res = new List<KBItemResponse>();
foreach (var item in allReadme)
{
res.Add(new()
{
FilePath = $"{Path.GetRelativePath(".", item)}",
SummaryInfo = File.ReadAllText(item)
});
}
return System.Text.Json.JsonSerializer.Serialize(res);
}
[McpServerResource(MimeType = "text/markdown", UriTemplate = "KBInfo://{path}"), Description("Get some knowledge's detailinfo")]
public static string GetKnowledgeDetailInfo(string path)
{
return string.Empty;
}
To Reproduce
Use AI VS code like the Roo Code etc.
Ask some question wants to use this resource.
Expected behavior
Error accessing MCP resource:
MCP error -32602: Unknown resource URI: 'KBInfo://KB/docs2/topic-auth.md'
Logs
ModelContextProtocol.McpException: Unknown resource URI: 'KBInfo://KB/docs2/topic-auth.md'
at ModelContextProtocol.Server.McpServerImpl.<>c.<<ConfigureResources>b__48_2>d.MoveNext()
--- End of stack trace from previous location ---
at ModelContextProtocol.Server.McpServerImpl.<>c__DisplayClass48_1.<<ConfigureResources>b__8>d.MoveNext()
--- End of stack trace from previous location ---
at ModelContextProtocol.AspNetCore.AuthorizationFilterSetup.<>c__DisplayClass14_0.<<CheckReadResourceFilter>b__1>d.MoveNext()
--- End of stack trace from previous location ---
at ModelContextProtocol.Server.McpServerImpl.<>c__DisplayClass48_2.<<ConfigureResources>b__9>d.MoveNext()
--- End of stack trace from previous location ---
at ModelContextProtocol.Server.McpServerImpl.<InvokeHandlerAsync>g__InvokeScopedAsync|52_0[TParams,TResult](McpRequestHandler`2 handler, TParams args, JsonRpcRequest jsonRpcRequest, CancellationToken cancellationToken)
at ModelContextProtocol.Server.McpServerImpl.<InvokeHandlerAsync>g__InvokeScopedAsync|52_0[TParams,TResult](McpRequestHandler`2 handler, TParams args, JsonRpcRequest jsonRpcRequest, CancellationToken cancellationToken)
at ModelContextProtocol.RequestHandlers.<>c__DisplayClass0_0`2.<<Set>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at ModelContextProtocol.McpSessionHandler.HandleRequest(JsonRpcRequest request, CancellationToken cancellationToken)
at ModelContextProtocol.McpSessionHandler.HandleMessageAsync(JsonRpcMessage message, CancellationToken cancellationToken)
at ModelContextProtocol.McpSessionHandler.<>c__DisplayClass26_1.<<ProcessMessagesCoreAsync>g__ProcessMessageAsync|1>d.MoveNext()
Additional context
None
Describe the bug
I just defined two resources to test,
To Reproduce
Use AI VS code like the Roo Code etc.
Ask some question wants to use this resource.
Expected behavior
Error accessing MCP resource:
MCP error -32602: Unknown resource URI: 'KBInfo://KB/docs2/topic-auth.md'
Logs
Additional context
None