Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub upstream: UpstreamConfig,
    pub filters: FilterConfig,
    pub tracking: TrackingConfig,
    pub preset: Option<String>,
}
Expand description

Top-level configuration for mcp-rtk.

§Examples

let config = Config::from_upstream(&["npx", "@nicepkg/gitlab-mcp"], None)?;
let rules = config.get_tool_rules("list_merge_requests");
assert!(!rules.keep_fields.is_empty());

Fields§

§upstream: UpstreamConfig

Upstream MCP server command and environment.

§filters: FilterConfig

Filter rules (default + preset + user overrides).

§tracking: TrackingConfig

Token-savings tracking configuration.

§preset: Option<String>

Name of the detected/selected preset, if any.

Implementations§

Source§

impl Config

Source

pub fn from_upstream( upstream_args: &[&str], config_path: Option<&Path>, ) -> Result<Self>

Build configuration from upstream command args with optional user config.

This is the primary entry point. The upstream command is taken from upstream_args (e.g. ["npx", "@nicepkg/gitlab-mcp"]). A preset is auto-detected from the command (including external presets from ~/.local/share/mcp-rtk/presets/), and an optional user config file provides overrides.

§Errors

Returns an error if the user config file cannot be read or parsed.

Source

pub fn build( upstream_args: &[&str], config_path: Option<&Path>, preset_override: Option<&str>, ) -> Result<Self>

Build a complete config with optional preset override.

Convenience wrapper around from_upstream that also applies a --preset override. Used by both initial startup and hot reload to avoid duplicating the override logic.

Source

pub fn load_for_gain(config_path: Option<&Path>) -> Result<Self>

Load configuration for the gain subcommand (no upstream needed).

§Errors

Returns an error if the user config file cannot be read or parsed.

Source

pub fn load_preset_by_name( name: &str, ) -> Option<HashMap<String, ToolFilterRules>>

Load a preset’s tool rules by name (embedded + external).

Returns the tool-specific filter rules from the preset, or None if the preset name is unknown.

Source

pub fn load_external_presets() -> Vec<ExternalPreset>

Scan ~/.local/share/mcp-rtk/presets/ for external preset TOML files.

Each .toml file is parsed as a PresetConfig. The preset name is derived from the filename (without extension). An optional [meta] section provides detection keywords for auto-discovery.

Invalid files are silently skipped.

Source

pub fn get_tool_rules(&self, tool_name: &str) -> MergedRules

Return the merged filter rules for a given tool name.

Tool-specific rules override the defaults. Lists (strip_fields, custom_transforms) are concatenated; scalars use the tool value if present, otherwise the default.

Lookup order:

  1. Exact match by tool name (fast path).
  2. Glob pattern match — keys containing * or ? are tested against the tool name using [glob_match].
Source

pub fn available_presets() -> Vec<String>

List all available preset names (embedded + external).

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

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

Formats the value using the given formatter. 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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