#[non_exhaustive]pub struct ArgumentAllowlist {
pub tool: String,
pub argument: String,
pub allowed: Vec<String>,
pub required: bool,
}Expand description
Per-tool argument allowlist entry.
When the middleware sees a tools/call for tool, it extracts the
string value at argument from the call’s arguments object and checks
its first token against allowed. If the token is not in the list
the call is rejected with 403.
By default this constrains the value only when the argument is
present – omitting it entirely skips the check. Set
required to also demand the argument be supplied.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.tool: StringTool name to match (exact or glob, e.g. "run_query").
argument: StringArgument key whose value is checked (e.g. "cmd", "query").
allowed: Vec<String>Permitted first-token values. Empty means unrestricted.
required: boolRequire the argument to be present and string-valued.
Defaults to false, preserving the historical semantics: an
allowlist constrains the value when the argument is supplied, and a
caller omitting it passes unchecked. That is safe when the tool’s
input schema already marks the argument required, but fails open
when the handler substitutes a default for a missing value.
When true, a call that omits the argument – or supplies a
non-string – is denied with 403, independently of allowed. Setting
required with an empty allowed therefore means “must be supplied
as a string, any value accepted”.
Implementations§
Source§impl ArgumentAllowlist
impl ArgumentAllowlist
Sourcepub fn new(
tool: impl Into<String>,
argument: impl Into<String>,
allowed: Vec<String>,
) -> Self
pub fn new( tool: impl Into<String>, argument: impl Into<String>, allowed: Vec<String>, ) -> Self
Create an argument allowlist for a tool.
The argument is optional by default; use
with_required to demand its presence.
Sourcepub const fn with_required(self, required: bool) -> Self
pub const fn with_required(self, required: bool) -> Self
Require the argument to be present and string-valued.
Trait Implementations§
Source§impl Clone for ArgumentAllowlist
impl Clone for ArgumentAllowlist
Source§fn clone(&self) -> ArgumentAllowlist
fn clone(&self) -> ArgumentAllowlist
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more