Skip to main content

ToolConfig

Struct ToolConfig 

Source
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:

  1. Compile-time - Cargo feature flags (e.g., --no-default-features --features "filesystem,git")
  2. 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: ModuleConfig

Per-module enable/disable toggles

§tools: ToolFilterConfig

Tool-level filtering (applied after module filtering)

Implementations§

Source§

impl ToolConfig

Source

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);
Source

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);
Source

pub fn enable_module(self, name: &str) -> Self

Enable a module by name. Chainable.

Source

pub fn disable_module(self, name: &str) -> Self

Disable a module by name. Chainable.

Source

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"));
Source

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"));
Source

pub fn from_file(path: &Path) -> Result<Self>

Load config from a JSON file.

Source

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 blacklist
  • disable_tools: comma-separated tool blacklist
Source

pub fn is_tool_enabled(&self, tool_name: &str) -> bool

Check if a tool is available given both module and tool-level filters.

Source

pub fn generate_default() -> String

Pretty-print the default config as JSON.

Trait Implementations§

Source§

impl Clone for ToolConfig

Source§

fn clone(&self) -> ToolConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ToolConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ToolConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ToolConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ToolConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more