From 1e15bc31d54cf682003afb90e339b1968a8c9e88 Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Fri, 28 Aug 2026 11:35:45 -0600 Subject: [PATCH] style: applied uniform style across files --- src/config/mcp_tool_policy.rs | 18 +++--------------- src/config/request_context.rs | 3 ++- src/config/skill.rs | 3 ++- src/config/tool_scope.rs | 3 +++ src/function/jobs.rs | 3 --- src/graph/validator.rs | 6 +++--- 6 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/config/mcp_tool_policy.rs b/src/config/mcp_tool_policy.rs index ae2fa0d..ab2100e 100644 --- a/src/config/mcp_tool_policy.rs +++ b/src/config/mcp_tool_policy.rs @@ -34,7 +34,6 @@ impl fmt::Display for LayerSource { } impl LayerSource { - /// The bare level keyword, for compact diagnostics. pub fn short_label(&self) -> &'static str { match self { LayerSource::Global => "global", @@ -69,14 +68,12 @@ impl ToolFilter { }); } - /// Each layer's source and raw patterns, in application order. pub fn layers(&self) -> impl Iterator { self.layers .iter() .map(|layer| (&layer.source, layer.raw.as_slice())) } - /// A tool is allowed iff it matches at least one pattern in every layer. pub fn allows(&self, tool: &str) -> bool { self.layers.iter().all(|layer| { layer @@ -105,12 +102,7 @@ impl ToolFilter { Ok(matched) } - /// Context-layer patterns that match none of the advertised tools - /// surviving the global layer — dead weight, usually a typo. - pub fn dead_context_patterns<'a>( - &'a self, - advertised: &[String], - ) -> Vec<(&'a LayerSource, &'a str)> { + pub fn dead_context_patterns(&self, advertised: &[String]) -> Vec<(&LayerSource, &str)> { let surviving: Vec<&String> = advertised .iter() .filter(|name| { @@ -140,6 +132,7 @@ impl ToolFilter { } } } + dead } } @@ -280,10 +273,6 @@ fn push_level( } } -/// Expands map keys to server ids: a key that is a server id maps to itself; -/// a key that is an alias expands to every configured id in its -/// comma-separated value; anything else is dropped. Keys expanding to the -/// same server merge their pattern lists. fn expand_server_keys( mcp_config: &McpServersConfig, aliases: &IndexMap, @@ -308,11 +297,10 @@ fn expand_server_keys( } } } + expanded } -/// Expands a `mapping_mcp_servers` alias key into its comma-separated server -/// ids. A key with no alias entry expands to nothing. pub(crate) fn expand_mcp_server_alias( aliases: &IndexMap, key: &str, diff --git a/src/config/request_context.rs b/src/config/request_context.rs index 611190e..88a4c49 100644 --- a/src/config/request_context.rs +++ b/src/config/request_context.rs @@ -1229,6 +1229,7 @@ impl RequestContext { app.enabled_tools.clone(), app.enabled_mcp_servers.clone(), ); + role }; @@ -3063,7 +3064,6 @@ impl RequestContext { .any(|id| has_layers(id)) } - /// The `.list mcp-servers` output, or `None` when nothing is configured. pub fn mcp_servers_listing(&self) -> Option { let mut names: Vec = vec![]; if let Some(mcp_config) = &self.app.mcp_config { @@ -3108,6 +3108,7 @@ impl RequestContext { }; out.push_str(&format!(" {marker} {name}{tag}\n")); } + Some(out) } diff --git a/src/config/skill.rs b/src/config/skill.rs index e8ec760..c705a11 100644 --- a/src/config/skill.rs +++ b/src/config/skill.rs @@ -152,7 +152,6 @@ impl Skill { self.enabled_mcp_servers.as_deref() } - #[allow(dead_code)] pub fn mcp_tools(&self) -> Option<&IndexMap>> { self.mcp_tools.as_ref() } @@ -198,6 +197,7 @@ fn parse_skill_string_or_array(value: &Value) -> Option> { fn parse_skill_mcp_tools_map(value: &Value) -> Option>> { let map = value.as_object()?; let mut mcp_tools = IndexMap::new(); + for (server, tools) in map { if tools.is_null() { mcp_tools.insert(server.clone(), Vec::new()); @@ -205,6 +205,7 @@ fn parse_skill_mcp_tools_map(value: &Value) -> Option = tools.iter().map(|tool| tool.name.to_string()).collect(); + for (source, pattern) in filter.dead_context_patterns(&advertised) { warn!( "MCP tool pattern '{pattern}' from {source} matches no allowed tools on server '{server}'" ); } + tools.retain(|tool| filter.allows(&tool.name)); } + merge_catalog_items( &mut items, tools diff --git a/src/function/jobs.rs b/src/function/jobs.rs index 9963710..9e35e80 100644 --- a/src/function/jobs.rs +++ b/src/function/jobs.rs @@ -363,9 +363,6 @@ fn whitelist_rejection(tool: &str) -> Option { }) } -/// Whether a declared tool could be run as a background job. This is the -/// declare-side twin of `whitelist_rejection`: a tool is backgroundable -/// exactly when `job__start` would not reject it by name. pub fn is_backgroundable_tool(tool: &str) -> bool { whitelist_rejection(tool).is_none() } diff --git a/src/graph/validator.rs b/src/graph/validator.rs index c484d5d..f7abb34 100644 --- a/src/graph/validator.rs +++ b/src/graph/validator.rs @@ -1,6 +1,7 @@ use super::state::template_root_keys; use super::types::{Graph, Node, NodeType}; use crate::client::{Model, ModelType}; +use crate::config; use crate::config::{Agent, AppConfig, paths}; use crate::rag::{GraphRagConfig, RagData}; use anyhow::{Result, bail}; @@ -214,9 +215,8 @@ impl GraphValidator { return; }; - let expand_alias = |name: &str| { - crate::config::expand_mcp_server_alias(&ctx.app_config.mapping_mcp_servers, name) - }; + let expand_alias = + |name: &str| config::expand_mcp_server_alias(&ctx.app_config.mapping_mcp_servers, name); let mut enabled_servers: HashSet = ctx.mcp_servers.clone(); for server in &ctx.mcp_servers { enabled_servers.extend(expand_alias(server));