pub struct PolicyEnabledServer<H: ServerHandler> { /* private fields */ }Available on crate features
server and policy only.Expand description
A server handler wrapper that enforces policies transparently
This wrapper can be applied to any existing ServerHandler implementation to add policy enforcement without changing the MCP protocol or breaking backwards compatibility.
Implementations§
Source§impl<H: ServerHandler> PolicyEnabledServer<H>
impl<H: ServerHandler> PolicyEnabledServer<H>
Sourcepub fn with_policy(inner: H, policy: Policy) -> Result<Self, ErrorData>
pub fn with_policy(inner: H, policy: Policy) -> Result<Self, ErrorData>
Create a new policy-enabled server with a specific policy
Sourcepub fn with_compiled_policy(inner: H, policy: Arc<CompiledPolicy>) -> Self
pub fn with_compiled_policy(inner: H, policy: Arc<CompiledPolicy>) -> Self
Create from a pre-compiled policy
Sourcepub fn has_policy(&self) -> bool
pub fn has_policy(&self) -> bool
Check if policy enforcement is enabled
Trait Implementations§
Source§impl<H: Clone + ServerHandler> Clone for PolicyEnabledServer<H>
impl<H: Clone + ServerHandler> Clone for PolicyEnabledServer<H>
Source§fn clone(&self) -> PolicyEnabledServer<H>
fn clone(&self) -> PolicyEnabledServer<H>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<H: ServerHandler> ServerHandler for PolicyEnabledServer<H>
impl<H: ServerHandler> ServerHandler for PolicyEnabledServer<H>
async fn initialize( &self, params: InitializeRequestParams, context: RequestContext<RoleServer>, ) -> Result<InitializeResult, ErrorData>
async fn ping( &self, context: RequestContext<RoleServer>, ) -> Result<(), ErrorData>
async fn list_tools( &self, params: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> Result<ListToolsResult, ErrorData>
async fn call_tool( &self, params: CallToolRequestParams, context: RequestContext<RoleServer>, ) -> Result<CallToolResult, ErrorData>
async fn list_resources( &self, params: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> Result<ListResourcesResult, ErrorData>
async fn read_resource( &self, params: ReadResourceRequestParams, context: RequestContext<RoleServer>, ) -> Result<ReadResourceResult, ErrorData>
async fn list_prompts( &self, params: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> Result<ListPromptsResult, ErrorData>
async fn get_prompt( &self, params: GetPromptRequestParams, context: RequestContext<RoleServer>, ) -> Result<GetPromptResult, ErrorData>
async fn complete( &self, params: CompleteRequestParams, context: RequestContext<RoleServer>, ) -> Result<CompleteResult, ErrorData>
async fn set_level( &self, params: SetLevelRequestParams, context: RequestContext<RoleServer>, ) -> Result<(), ErrorData>
async fn list_resource_templates( &self, params: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> Result<ListResourceTemplatesResult, ErrorData>
async fn subscribe( &self, params: SubscribeRequestParams, context: RequestContext<RoleServer>, ) -> Result<(), ErrorData>
async fn unsubscribe( &self, params: UnsubscribeRequestParams, context: RequestContext<RoleServer>, ) -> Result<(), ErrorData>
async fn on_custom_request( &self, request: CustomRequest, context: RequestContext<RoleServer>, ) -> Result<CustomResult, ErrorData>
async fn on_initialized(&self, context: NotificationContext<RoleServer>)
async fn on_custom_notification( &self, notification: CustomNotification, context: NotificationContext<RoleServer>, )
fn enqueue_task( &self, _request: CallToolRequestParams, _context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CreateTaskResult, McpError>> + Send + '_
fn on_cancelled( &self, notification: CancelledNotificationParam, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + Send + '_
fn on_progress( &self, notification: ProgressNotificationParam, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + Send + '_
fn on_roots_list_changed( &self, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + Send + '_
fn get_info(&self) -> ServerInfo
fn list_tasks( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ListTasksResult, McpError>> + Send + '_
fn get_task_info( &self, request: GetTaskInfoParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<GetTaskInfoResult, McpError>> + Send + '_
fn get_task_result( &self, request: GetTaskResultParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<TaskResult, McpError>> + Send + '_
fn cancel_task( &self, request: CancelTaskParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), McpError>> + Send + '_
Auto Trait Implementations§
impl<H> Freeze for PolicyEnabledServer<H>where
H: Freeze,
impl<H> RefUnwindSafe for PolicyEnabledServer<H>where
H: RefUnwindSafe,
impl<H> Send for PolicyEnabledServer<H>
impl<H> Sync for PolicyEnabledServer<H>
impl<H> Unpin for PolicyEnabledServer<H>where
H: Unpin,
impl<H> UnwindSafe for PolicyEnabledServer<H>where
H: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<R, S> DynService<R> for Swhere
R: ServiceRole,
S: Service<R>,
impl<R, S> DynService<R> for Swhere
R: ServiceRole,
S: Service<R>,
Source§fn handle_request(
&self,
request: <R as ServiceRole>::PeerReq,
context: RequestContext<R>,
) -> Pin<Box<dyn Future<Output = Result<<R as ServiceRole>::Resp, ErrorData>> + Send + '_>>
fn handle_request( &self, request: <R as ServiceRole>::PeerReq, context: RequestContext<R>, ) -> Pin<Box<dyn Future<Output = Result<<R as ServiceRole>::Resp, ErrorData>> + Send + '_>>
Available on crate features
client or server only.Source§fn handle_notification(
&self,
notification: <R as ServiceRole>::PeerNot,
context: NotificationContext<R>,
) -> Pin<Box<dyn Future<Output = Result<(), ErrorData>> + Send + '_>>
fn handle_notification( &self, notification: <R as ServiceRole>::PeerNot, context: NotificationContext<R>, ) -> Pin<Box<dyn Future<Output = Result<(), ErrorData>> + Send + '_>>
Available on crate features
client or server only.Source§fn get_info(&self) -> <R as ServiceRole>::Info
fn get_info(&self) -> <R as ServiceRole>::Info
Available on crate features
client or server only.Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
Query the “status” flags for the
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
Set the “status” flags for the
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<H> Service<RoleServer> for Hwhere
H: ServerHandler,
impl<H> Service<RoleServer> for Hwhere
H: ServerHandler,
Source§async fn handle_request(
&self,
request: <RoleServer as ServiceRole>::PeerReq,
context: RequestContext<RoleServer>,
) -> Result<<RoleServer as ServiceRole>::Resp, ErrorData>
async fn handle_request( &self, request: <RoleServer as ServiceRole>::PeerReq, context: RequestContext<RoleServer>, ) -> Result<<RoleServer as ServiceRole>::Resp, ErrorData>
Available on crate features
client or server only.Source§async fn handle_notification(
&self,
notification: <RoleServer as ServiceRole>::PeerNot,
context: NotificationContext<RoleServer>,
) -> Result<(), ErrorData>
async fn handle_notification( &self, notification: <RoleServer as ServiceRole>::PeerNot, context: NotificationContext<RoleServer>, ) -> Result<(), ErrorData>
Available on crate features
client or server only.Source§fn get_info(&self) -> <RoleServer as ServiceRole>::Info
fn get_info(&self) -> <RoleServer as ServiceRole>::Info
Available on crate features
client or server only.Source§impl<S> ServiceExt<RoleServer> for Swhere
S: Service<RoleServer>,
impl<S> ServiceExt<RoleServer> for Swhere
S: Service<RoleServer>,
Source§fn serve_with_ct<T, E, A>(
self,
transport: T,
ct: CancellationToken,
) -> impl Future<Output = Result<RunningService<RoleServer, S>, ServerInitializeError>> + Send
fn serve_with_ct<T, E, A>( self, transport: T, ct: CancellationToken, ) -> impl Future<Output = Result<RunningService<RoleServer, S>, ServerInitializeError>> + Send
Available on crate features
client or server only.Source§fn into_dyn(self) -> Box<dyn DynService<R>>
fn into_dyn(self) -> Box<dyn DynService<R>>
Available on crate features
client or server only.Convert this service to a dynamic boxed service Read more
Source§fn serve<T, E, A>(
self,
transport: T,
) -> impl Future<Output = Result<RunningService<R, Self>, R::InitializeError>> + Send
fn serve<T, E, A>( self, transport: T, ) -> impl Future<Output = Result<RunningService<R, Self>, R::InitializeError>> + Send
Available on crate features
client or server only.