Fix URI template derivation and lookup (#530)

* Use lowercase host in resource URI template derivation.

* Address feedback

* Add casing testing for non-templated resource lookups.

* Fix uri primitive lookup

* Use a hardcoded mcp hostname in derived resource template URIs and ensure built-in resources work with the VS Code client.

* Address feedback

* Fix equality comparison

* Use dedicated type for resource collections.
This commit is contained in:
Eirik Tsarpalis 2025-06-23 19:49:38 +03:00 • committed by GitHub
commit 0b26b7bf22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 174 additions and 75 deletions

View file

@ -2,12 +2,14 @@ using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
using TestServerWithHosting.Tools;
using TestServerWithHosting.Resources;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMcpServer()
.WithHttpTransport()
.WithTools<EchoTool>()
.WithTools<SampleLlmTool>();
.WithTools<SampleLlmTool>()
.WithResources<SimpleResourceType>();
builder.Services.AddOpenTelemetry()
.WithTracing(b => b.AddSource("*")

View file

@ -0,0 +1,12 @@
using ModelContextProtocol.Protocol;
using ModelContextProtocol.Server;
using System.ComponentModel;
namespace TestServerWithHosting.Resources;
[McpServerResourceType]
public class SimpleResourceType
{
[McpServerResource, Description("A direct text resource")]
public static string DirectTextResource() => "This is a direct resource";
}