pub trait ResourceHandler: Send + Sync {
// Required methods
fn read_resource<'life0, 'async_trait>(
&'life0 self,
request: ReadResourceRequest,
) -> Pin<Box<dyn Future<Output = MCPResult<ReadResourceResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn list_resources<'life0, 'async_trait>(
&'life0 self,
request: ListResourcesRequest,
) -> Pin<Box<dyn Future<Output = MCPResult<ListResourcesResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn list_resource_templates<'life0, 'async_trait>(
&'life0 self,
request: ListResourceTemplatesRequest,
) -> Pin<Box<dyn Future<Output = MCPResult<ListResourceTemplatesResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn validate_resource_access<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uri: &'life1 str,
operation: RootOperation,
roots: &'life2 [Root],
) -> Pin<Box<dyn Future<Output = MCPResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Resource handler trait for managing resources
Required Methods§
Sourcefn read_resource<'life0, 'async_trait>(
&'life0 self,
request: ReadResourceRequest,
) -> Pin<Box<dyn Future<Output = MCPResult<ReadResourceResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read_resource<'life0, 'async_trait>(
&'life0 self,
request: ReadResourceRequest,
) -> Pin<Box<dyn Future<Output = MCPResult<ReadResourceResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Read a resource
Sourcefn list_resources<'life0, 'async_trait>(
&'life0 self,
request: ListResourcesRequest,
) -> Pin<Box<dyn Future<Output = MCPResult<ListResourcesResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_resources<'life0, 'async_trait>(
&'life0 self,
request: ListResourcesRequest,
) -> Pin<Box<dyn Future<Output = MCPResult<ListResourcesResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List available resources
Sourcefn list_resource_templates<'life0, 'async_trait>(
&'life0 self,
request: ListResourceTemplatesRequest,
) -> Pin<Box<dyn Future<Output = MCPResult<ListResourceTemplatesResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_resource_templates<'life0, 'async_trait>(
&'life0 self,
request: ListResourceTemplatesRequest,
) -> Pin<Box<dyn Future<Output = MCPResult<ListResourceTemplatesResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List resource templates
Sourcefn validate_resource_access<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uri: &'life1 str,
operation: RootOperation,
roots: &'life2 [Root],
) -> Pin<Box<dyn Future<Output = MCPResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn validate_resource_access<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uri: &'life1 str,
operation: RootOperation,
roots: &'life2 [Root],
) -> Pin<Box<dyn Future<Output = MCPResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Validate resource access against roots (optional implementation) According to MCP specification, roots are informational and not strictly enforcing. This method provides advisory validation but does not block access if no root matches.