style: applied uniform style across files
This commit is contained in:
@@ -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<Item = (&LayerSource, &[String])> {
|
||||
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<String, String>,
|
||||
@@ -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<String, String>,
|
||||
key: &str,
|
||||
|
||||
@@ -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<String> {
|
||||
let mut names: Vec<String> = 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)
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -152,7 +152,6 @@ impl Skill {
|
||||
self.enabled_mcp_servers.as_deref()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn mcp_tools(&self) -> Option<&IndexMap<String, Vec<String>>> {
|
||||
self.mcp_tools.as_ref()
|
||||
}
|
||||
@@ -198,6 +197,7 @@ fn parse_skill_string_or_array(value: &Value) -> Option<Vec<String>> {
|
||||
fn parse_skill_mcp_tools_map(value: &Value) -> Option<IndexMap<String, Vec<String>>> {
|
||||
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<IndexMap<String, Vec<Strin
|
||||
mcp_tools.insert(server.clone(), tools);
|
||||
}
|
||||
}
|
||||
|
||||
Some(mcp_tools)
|
||||
}
|
||||
|
||||
|
||||
@@ -107,13 +107,16 @@ impl McpRuntime {
|
||||
if let Some(filter) = self.tool_filters.get(server) {
|
||||
let advertised: Vec<String> =
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user