Class ResourcesCapability
- Namespace
- ModelContextProtocol.Protocol
- Assembly
- ModelContextProtocol.Core.dll
Represents the resources capability configuration.
public class ResourcesCapability
- Inheritance
-
ResourcesCapability
- Inherited Members
Remarks
See the schema for details.
Properties
ListChanged
Gets or sets whether this server supports notifications for changes to the resource list.
[JsonPropertyName("listChanged")]
public bool? ListChanged { get; set; }
Property Value
- bool?
Remarks
When set to true, the server will send notifications using ResourceListChangedNotification when resources are added, removed, or modified. Clients can register handlers for these notifications to refresh their resource cache.
ListResourceTemplatesHandler
Gets or sets the handler for ResourcesTemplatesList requests.
[JsonIgnore]
public Func<RequestContext<ListResourceTemplatesRequestParams>, CancellationToken, ValueTask<ListResourceTemplatesResult>>? ListResourceTemplatesHandler { get; set; }
Property Value
- Func<RequestContext<ListResourceTemplatesRequestParams>, CancellationToken, ValueTask<ListResourceTemplatesResult>>
Remarks
This handler is called when clients request available resource templates that can be used to create resources within the Model Context Protocol server. Resource templates define the structure and URI patterns for resources accessible in the system, allowing clients to discover available resource types and their access patterns.
ListResourcesHandler
Gets or sets the handler for ResourcesList requests.
[JsonIgnore]
public Func<RequestContext<ListResourcesRequestParams>, CancellationToken, ValueTask<ListResourcesResult>>? ListResourcesHandler { get; set; }
Property Value
Remarks
This handler responds to client requests for available resources and returns information about resources accessible through the server. The implementation should return a ListResourcesResult with the matching resources.
ReadResourceHandler
Gets or sets the handler for ResourcesRead requests.
[JsonIgnore]
public Func<RequestContext<ReadResourceRequestParams>, CancellationToken, ValueTask<ReadResourceResult>>? ReadResourceHandler { get; set; }
Property Value
Remarks
This handler is responsible for retrieving the content of a specific resource identified by its URI in the Model Context Protocol. When a client sends a resources/read request, this handler is invoked with the resource URI. The handler should implement logic to locate and retrieve the requested resource, then return its contents in a ReadResourceResult object.
ResourceCollection
Gets or sets a collection of resources served by the server.
[JsonIgnore]
public McpServerPrimitiveCollection<McpServerResource>? ResourceCollection { get; set; }
Property Value
Remarks
Resources specified via ResourceCollection augment the ListResourcesHandler, ListResourceTemplatesHandler and ReadResourceHandler handlers, if provided. Resources with template expressions in their URI templates are considered resource templates and are listed via ListResourceTemplate, whereas resources without template parameters are considered static resources and are listed with ListResources.
ReadResource requests will first check the ResourceCollection for the exact resource being requested. If no match is found, they'll proceed to try to match the resource against each resource template in ResourceCollection. If no match is still found, the request will fall back to any handler registered for ReadResourceHandler.
Subscribe
Gets or sets whether this server supports subscribing to resource updates.
[JsonPropertyName("subscribe")]
public bool? Subscribe { get; set; }
Property Value
- bool?
SubscribeToResourcesHandler
Gets or sets the handler for ResourcesSubscribe requests.
[JsonIgnore]
public Func<RequestContext<SubscribeRequestParams>, CancellationToken, ValueTask<EmptyResult>>? SubscribeToResourcesHandler { get; set; }
Property Value
Remarks
When a client sends a ResourcesSubscribe request, this handler is invoked with the resource URI to be subscribed to. The implementation should register the client's interest in receiving updates for the specified resource. Subscriptions allow clients to receive real-time notifications when resources change, without requiring polling.
UnsubscribeFromResourcesHandler
Gets or sets the handler for ResourcesUnsubscribe requests.
[JsonIgnore]
public Func<RequestContext<UnsubscribeRequestParams>, CancellationToken, ValueTask<EmptyResult>>? UnsubscribeFromResourcesHandler { get; set; }
Property Value
Remarks
When a client sends a ResourcesUnsubscribe request, this handler is invoked with the resource URI to be unsubscribed from. The implementation should remove the client's registration for receiving updates about the specified resource.