Skip to content

How to implement a resource provider with v0.3.0-preview.3? #716

@Kaexburli

Description

@Kaexburli

Hello,

I am migrating a project from ModelContextProtocol version 0.2.0-preview.3 to
0.3.0-preview.3 and I'm facing issues with my custom resource provider implementation.

In the previous version, I had a class that implemented IResourceProvider and used a
Resource type, both from the ModelContextProtocol.Server namespace.

My code looked like this:

DocumentationResourceProvider.cs

1 using ModelContextProtocol.Server;
2 using System.Collections.Generic;
3 using System.IO;
4 using System.Threading.Tasks;
5
6 namespace MCPServer
7 {
8     public class DocumentationResourceProvider : IResourceProvider
9     {

10 public async Task<IEnumerable> GetResourcesAsync()
11 {
12 // ... implementation to read .md files and return them
13 }
14 }
15 }

Program.cs (Old Syntax)

1 services.AddMcpServer(mcp =>
2 {
3 mcp.AddResourceProvider();
4 });

After updating the package to 0.3.0-preview.3, the build fails because the
IResourceProvider and Resource types can no longer be found. I noticed the server
configuration syntax has changed to a fluent API, and I've updated my code accordingly:

Program.cs (New Syntax)

1 services.AddMcpServer()
2 .WithResourceProvider()
3 .WithStdioServerTransport();

However, the issue remains because the types themselves seem to have been moved or
removed.

My question is: What is the new way to implement and register a custom resource provider
in version 0.3.0-preview.3? Have the IResourceProvider and Resource types been renamed or
replaced by a new mechanism?

Thanks for your help.

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions