feat(mcp): add tool presets and audit commands
- Introduce reference MCP presets with installation/audit helpers and remove legacy connector lists. - Add CLI `owlen tools` commands to install presets or audit configuration, with optional pruning. - Extend the TUI :tools command to support listing presets, installing them, and auditing current configuration. - Document the preset workflow and provide regression tests for preset application.
This commit is contained in:
61
crates/owlen-core/tests/presets.rs
Normal file
61
crates/owlen-core/tests/presets.rs
Normal file
@@ -0,0 +1,61 @@
|
||||
use owlen_core::config::Config;
|
||||
use owlen_core::mcp::presets::{PresetTier, apply_preset, audit_preset};
|
||||
|
||||
#[test]
|
||||
fn standard_preset_produces_spec_compliant_servers() {
|
||||
let configs = Config::preset_servers(PresetTier::Standard);
|
||||
assert!(
|
||||
!configs.is_empty(),
|
||||
"expected standard preset to contain connectors"
|
||||
);
|
||||
for server in configs {
|
||||
assert!(
|
||||
server
|
||||
.name
|
||||
.chars()
|
||||
.all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '-'),
|
||||
"server '{}' failed identifier validation",
|
||||
server.name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn apply_preset_adds_missing_servers() {
|
||||
let mut config = Config::default();
|
||||
let report = apply_preset(&mut config, PresetTier::Standard, false).expect("apply preset");
|
||||
assert!(!report.added.is_empty(), "expected connectors to be added");
|
||||
assert!(report.updated.is_empty());
|
||||
assert!(report.removed.is_empty());
|
||||
|
||||
let audit = audit_preset(&config, PresetTier::Standard);
|
||||
assert!(
|
||||
audit.missing.is_empty(),
|
||||
"expected no missing connectors after install"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prune_preset_removes_extra_entries() {
|
||||
let mut config = Config::default();
|
||||
// Seed with an extra entry
|
||||
config
|
||||
.mcp_servers
|
||||
.push(owlen_core::config::McpServerConfig {
|
||||
name: "custom_tool".into(),
|
||||
command: "custom-cmd".into(),
|
||||
args: vec![],
|
||||
transport: "stdio".into(),
|
||||
env: Default::default(),
|
||||
oauth: None,
|
||||
});
|
||||
|
||||
let report = apply_preset(&mut config, PresetTier::Standard, true).expect("apply preset");
|
||||
assert!(report.removed.contains(&"custom_tool".to_string()));
|
||||
assert!(
|
||||
config
|
||||
.mcp_servers
|
||||
.iter()
|
||||
.all(|srv| srv.name != "custom_tool")
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user