pub struct ClientFilters { /* private fields */ }Expand description
Per-client filter combining tool-visibility (name-level) and tool-callability (argument-level) rules. Driven by request headers (HTTP/WS) or environment variables (stdio).
Implementations§
Source§impl ClientFilters
impl ClientFilters
Sourcepub fn from_strings(
visibility_allow: Option<&str>,
visibility_deny: Option<&str>,
callable_allow_json: Option<&str>,
callable_deny_json: Option<&str>,
) -> Self
pub fn from_strings( visibility_allow: Option<&str>, visibility_deny: Option<&str>, callable_allow_json: Option<&str>, callable_deny_json: Option<&str>, ) -> Self
Build from raw strings. Callability inputs are JSON; malformed JSON is treated as no constraints (logged at WARN) — bricking a request on bad filter config would be a footgun for ops.
Sourcepub fn tool_visible(&self, name: &str) -> bool
pub fn tool_visible(&self, name: &str) -> bool
true if the tool name is visible to this client.
A false return means a tools/call against this name produces an
MCP Protocol Error (-32602, “Unknown tool: …”) and the tool is
omitted from tools/list / resources/list. Deny wins; an empty
allow list means “visible unless explicitly denied”.
Sourcepub fn meta_tool_visible(&self, name: &str) -> bool
pub fn meta_tool_visible(&self, name: &str) -> bool
true if the top-level search/execute/connection_status tools
are visible to this client — unlike tool_visible,
only deny applies; a non-empty allow list does not hide these.
These three are entry points, not operations: an operator’s allow
list is written in terms of operation names (report:Foo,
command:Bar) to scope which operations a client can reach — that
scoping is enforced separately, per call, inside search’s index
filtering and execute’s sandbox (both still call tool_visible on
the operation’s own {kind}_{id} name). If search/execute
themselves were gated by the same allow list, an operation-scoped
allow list with no explicit search/execute entry would hide both
tools entirely — making the server unreachable despite the
operator’s intent being to scope operations, not remove entry
points. Explicit deny still works normally for operators who want
to lock a client out of a tool entirely.
Sourcepub fn tool_callable(
&self,
tool_name: &str,
arguments: &Value,
) -> Result<(), String>
pub fn tool_callable( &self, tool_name: &str, arguments: &Value, ) -> Result<(), String>
Check whether a tools/call is callable for this client given its
JSON arguments.
Ok(()) if no callability constraints apply or every constraint
passes. Err(message) surfaces as an MCP Tool Execution Error
(isError: true content with the message), the spec’s
“Invalid input data” category.
Visibility is not re-checked here; callers run
tool_visible first.
Trait Implementations§
Source§impl Clone for ClientFilters
impl Clone for ClientFilters
Source§fn clone(&self) -> ClientFilters
fn clone(&self) -> ClientFilters
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ClientFilters
impl Debug for ClientFilters
Source§impl Default for ClientFilters
impl Default for ClientFilters
Source§fn default() -> ClientFilters
fn default() -> ClientFilters
Auto Trait Implementations§
impl Freeze for ClientFilters
impl RefUnwindSafe for ClientFilters
impl Send for ClientFilters
impl Sync for ClientFilters
impl Unpin for ClientFilters
impl UnsafeUnpin for ClientFilters
impl UnwindSafe for ClientFilters
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§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>
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>
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 more