pub struct ToolConfig {
pub modules: ModuleConfig,
pub tools: ToolFilterConfig,
}Expand description
Runtime configuration for enabling/disabling modules and individual tools.
Tools are gated at two levels:
- Compile-time - Cargo feature flags (e.g.,
--no-default-features --features "filesystem,git") - Runtime - This config, via CLI flags or a JSON config file
A tool is available only if its module is both compiled in AND runtime-enabled.
Fields§
§modules: ModuleConfigPer-module enable/disable toggles
tools: ToolFilterConfigTool-level filtering (applied after module filtering)
Implementations§
Source§impl ToolConfig
impl ToolConfig
Sourcepub fn only(modules: &[&str]) -> Self
pub fn only(modules: &[&str]) -> Self
Config with only the specified modules enabled (all others disabled).
Accepts full names or aliases: fs, diag, net, ctx, clip.
use poly_mcp::ToolConfig;
let cfg = ToolConfig::only(&["fs", "git"]);
assert!(cfg.modules.filesystem);
assert!(cfg.modules.git);
assert!(!cfg.modules.network);Sourcepub fn without(modules: &[&str]) -> Self
pub fn without(modules: &[&str]) -> Self
Config with all modules enabled except the specified ones.
use poly_mcp::ToolConfig;
let cfg = ToolConfig::without(&["silent", "input"]);
assert!(cfg.modules.filesystem);
assert!(!cfg.modules.silent);Sourcepub fn enable_module(self, name: &str) -> Self
pub fn enable_module(self, name: &str) -> Self
Enable a module by name. Chainable.
Sourcepub fn disable_module(self, name: &str) -> Self
pub fn disable_module(self, name: &str) -> Self
Disable a module by name. Chainable.
Sourcepub fn disable_tool(self, name: impl Into<String>) -> Self
pub fn disable_tool(self, name: impl Into<String>) -> Self
Add a tool to the blacklist. Chainable.
use poly_mcp::ToolConfig;
let cfg = ToolConfig::only(&["fs", "git"])
.disable_tool("fs_delete")
.disable_tool("git_tag");
assert!(!cfg.is_tool_enabled("fs_delete"));
assert!(cfg.is_tool_enabled("fs_read"));Sourcepub fn enable_only_tools(self, names: &[&str]) -> Self
pub fn enable_only_tools(self, names: &[&str]) -> Self
Set the tool whitelist: only these specific tools will be available (from their respective enabled modules). Chainable.
use poly_mcp::ToolConfig;
let cfg = ToolConfig::default()
.enable_only_tools(&["fs_read", "git_status"]);
assert!(cfg.is_tool_enabled("fs_read"));
assert!(!cfg.is_tool_enabled("fs_write"));Sourcepub fn apply_cli(
&mut self,
enable_modules: Option<&str>,
disable_modules: Option<&str>,
disable_tools: Option<&str>,
)
pub fn apply_cli( &mut self, enable_modules: Option<&str>, disable_modules: Option<&str>, disable_tools: Option<&str>, )
Apply CLI-style overrides on top of the current config.
enable_modules: comma-separated whitelist (disables all others)disable_modules: comma-separated blacklistdisable_tools: comma-separated tool blacklist
Sourcepub fn is_tool_enabled(&self, tool_name: &str) -> bool
pub fn is_tool_enabled(&self, tool_name: &str) -> bool
Check if a tool is available given both module and tool-level filters.
Sourcepub fn generate_default() -> String
pub fn generate_default() -> String
Pretty-print the default config as JSON.
Trait Implementations§
Source§impl Clone for ToolConfig
impl Clone for ToolConfig
Source§fn clone(&self) -> ToolConfig
fn clone(&self) -> ToolConfig
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 ToolConfig
impl Debug for ToolConfig
Source§impl Default for ToolConfig
impl Default for ToolConfig
Source§impl<'de> Deserialize<'de> for ToolConfig
impl<'de> Deserialize<'de> for ToolConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ToolConfig
impl RefUnwindSafe for ToolConfig
impl Send for ToolConfig
impl Sync for ToolConfig
impl Unpin for ToolConfig
impl UnsafeUnpin for ToolConfig
impl UnwindSafe for ToolConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().