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: UpstreamConfigUpstream MCP server command and environment.
filters: FilterConfigFilter rules (default + preset + user overrides).
tracking: TrackingConfigToken-savings tracking configuration.
preset: Option<String>Name of the detected/selected preset, if any.
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_upstream(
upstream_args: &[&str],
config_path: Option<&Path>,
) -> Result<Self>
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.
Sourcepub fn build(
upstream_args: &[&str],
config_path: Option<&Path>,
preset_override: Option<&str>,
) -> Result<Self>
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.
Sourcepub fn load_for_gain(config_path: Option<&Path>) -> Result<Self>
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.
Sourcepub fn load_preset_by_name(
name: &str,
) -> Option<HashMap<String, ToolFilterRules>>
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.
Sourcepub fn load_external_presets() -> Vec<ExternalPreset>
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.
Sourcepub fn get_tool_rules(&self, tool_name: &str) -> MergedRules
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:
- Exact match by tool name (fast path).
- Glob pattern match — keys containing
*or?are tested against the tool name using [glob_match].
Sourcepub fn available_presets() -> Vec<String>
pub fn available_presets() -> Vec<String>
List all available preset names (embedded + external).