-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ResourceType
and Resource
for defining resources
#72
Comments
I opened #74 to track Resource Templates separately, but I think ideally they are related to the implementation which would happen for static Resources. |
Yep, looks like they are similar in theme. |
How do you provide the actual resource contents with this approach? |
This is how I imagine it to be: [McpServerResourceType]
public class MyResources {
[McpServerResource("file://myresource/foo.txt"), Description("This is a foo text file")]
public static string Foo(
Uri uri // this would be injected by the MCP server and map to `file://myresource/foo.txt` in this case
)
{
return """
This is a foo text file.
It could be multiple lines long.
""";
}
[McpServerResource("file://myresource/bar.png", MimeType = "image/png"), Description("This is a bar image")]
public static byte[] Bar(
Uri uri // this would be injected by the MCP server and map to `file://myresource/bar.png` in this case
)
{
return ... // PNG file content
}
[McpServerResource("file://myresource/baz.csv"), Description("This is a baz text file")]
public static DataContent Baz(
Uri uri // this would be injected by the MCP server and map to `file://myresource/baz.csv` in this case
)
{
return new DataContent {
MimeType = "text/csv",
Blob = ... // CSV file content
}
}
} These are obviously static resources routes, but the same approach could be applied to dynamic ones like |
How would you handle providing content from something like Azure Storage as a file provider (or any other valid URIs on alternative file systems?) Since we're already including the file provider apis in this project, why not do: builder.WithResources([fileInfo1, fileInfo2, ...otherFileInfos]); and just load the resources using the built-in apis for that? |
I added a PR that addresses my feedback around existing packages. @aaronpowell @Redth What do you all think? For reading resources, a default or custom handler could be registered using file provider APIs that require a file provider instance to be configured in the McpServer.ServiceProvider if a custom handler isn't registered. |
Is your feature request related to a problem? Please describe.
Similar to #70.
The API for
McpToolType
andMcpTool
(combined with theWithTools
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:
Describe alternatives you've considered
Currently, the only solution would be to implement this via
WithListResourcesHandler
andWithReadResourceHandler
.The text was updated successfully, but these errors were encountered: