Skip to content

Add ResourceTemplate and related attribute(s) for implementing resource template handlers #74

Closed
@Redth

Description

@Redth

Is your feature request related to a problem? Please describe.
Just like McpToolType and McpTool works today, it would be great to have a way to use attributes to define resource templates.

Describe the solution you'd like
Would be nice to annotate a type and method(s) to specify resource templates.

Resource URI Templates per the spec should conform to RFC6570. I'm not sure if this is what ASP.NET uses, but perhaps there is some way to leverage the route parsing logic within the SDK here?

[ResourceTemplateType]
public static class SampleResourceTemplates {

  // RFC6570 URI Template
  [ResourceTemplate("nuget://{packageId}/{version}")]
  public static byte[] NuGetPackage(string packageId, string version) {
    // Implement Handler logic to fetch and return
  }

}

// in Program.cs
builder.Services
  .AddMcpServer()
  .WithStdioServerTransport()
  .WithTools()
  .WithResourceTemplates();

Additional context
This probably should be considered with #72 so that methods could return actual types marked as ResourceType and have that handled automatically.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions