Expand description
Dynamic tool filtering based on request context.
This module provides the ToolFilter trait for controlling which tools are
visible and callable based on runtime context such as user permissions, scopes,
or other request-specific criteria.
§Example
ⓘ
use rmcp_openapi::{ToolFilter, Tool};
use rmcp::service::{RequestContext, RoleServer};
use async_trait::async_trait;
/// Filter that only allows read-only (GET) tools
struct ReadOnlyFilter;
#[async_trait]
impl ToolFilter for ReadOnlyFilter {
async fn allow(&self, tool: &Tool, _context: &RequestContext<RoleServer>) -> bool {
tool.metadata.method == "GET"
}
}Traits§
- Tool
Filter - Trait for dynamically filtering tools based on request context.