Skip to content

Add ResourceType and Resource for defining resources #72

Closed
@aaronpowell

Description

@aaronpowell

Is your feature request related to a problem? Please describe.
Similar to #70.

The API for McpToolType and McpTool (combined with the WithTools method) makes it really easy to define tools. It'd be great to have a comparable API for Resources.

Describe the solution you'd like
I'd like to be able to have code like this:

[ResourceType]
public static class SampleResource {
  [Resource("text/plain"), Description("This is a sample resource")]
  public static string Sample() => "test://static/resource/sample.txt";
}

// in program.cs
builder.Services
    .AddMcpServer()
    .WithStdioServerTransport()
    .WithTools()
    .WithResources();

Describe alternatives you've considered
Currently, the only solution would be to implement this via WithListResourcesHandler and WithReadResourceHandler.

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