Skip to content

An agent-managed museum exhibit, built in Rust with Gajae-Code / LazyCodex — developed and maintained with no human intervention.

Rust

merge: clawcode-issue-9407-cli-agents-mcp-config into main

Jobdoribf848a43ce01
diff --cc rust/crates/commands/src/lib.rs
index ad18e125,0ea493af..23f9ef25
--- a/rust/crates/commands/src/lib.rs
+++ b/rust/crates/commands/src/lib.rs
@@@ -1823,27 -1662,112 +1914,132 @@@ fn render_skills_report(skills: &[Skill
lines.join("\n").trim_end().to_string()
}
+fn render_skill_install_report(skill: &InstalledSkill) -> String {
+ let mut lines = vec![
+ "Skills".to_string(),
+ format!(" Result installed {}", skill.invocation_name),
+ format!(" Invoke as ${}", skill.invocation_name),
+ ];
+ if let Some(display_name) = &skill.display_name {
+ lines.push(format!(" Display name {display_name}"));
+ }
+ lines.push(format!(" Source {}", skill.source.display()));
+ lines.push(format!(
+ " Registry {}",
+ skill.registry_root.display()
+ ));
+ lines.push(format!(
+ " Installed path {}",
+ skill.installed_path.display()
+ ));
+ lines.join("\n")
+}
+
+ fn render_mcp_summary_report(
+ cwd: &Path,
+ servers: &BTreeMap<String, ScopedMcpServerConfig>,
+ ) -> String {
+ let mut lines = vec![
+ "MCP".to_string(),
+ format!(" Working directory {}", cwd.display()),
+ format!(" Configured servers {}", servers.len()),
+ ];
+ if servers.is_empty() {
+ lines.push(" No MCP servers configured.".to_string());
+ return lines.join("\n");
+ }
+
+ lines.push(String::new());
+ for (name, server) in servers {
+ lines.push(format!(
+ " {name:<16} {transport:<13} {scope:<7} {summary}",
+ transport = mcp_transport_label(&server.config),
+ scope = config_source_label(server.scope),
+ summary = mcp_server_summary(&server.config)
+ ));
+ }
+
+ lines.join("\n")
+ }
+
+ fn render_mcp_server_report(
+ cwd: &Path,
+ server_name: &str,
+ server: Option<&ScopedMcpServerConfig>,
+ ) -> String {
+ let Some(server) = server else {
+ return format!(
+ "MCP\n Working directory {}\n Result server `{server_name}` is not configured",
+ cwd.display()
+ );
+ };
+
+ let mut lines = vec![
+ "MCP".to_string(),
+ format!(" Working directory {}", cwd.display()),
+ format!(" Name {server_name}"),
+ format!(" Scope {}", config_source_label(server.scope)),
+ format!(
+ " Transport {}",
+ mcp_transport_label(&server.config)
+ ),
+ ];
+
+ match &server.config {
+ McpServerConfig::Stdio(config) => {
+ lines.push(format!(" Command {}", config.command));
+ lines.push(format!(
+ " Args {}",
+ format_optional_list(&config.args)
+ ));
+ lines.push(format!(
+ " Env keys {}",
+ format_optional_keys(config.env.keys().cloned().collect())
+ ));
+ lines.push(format!(
+ " Tool timeout {}",
+ config
+ .tool_call_timeout_ms
+ .map_or_else(|| "<default>".to_string(), |value| format!("{value} ms"))
+ ));
+ }
+ McpServerConfig::Sse(config) | McpServerConfig::Http(config) => {
+ lines.push(format!(" URL {}", config.url));
+ lines.push(format!(
+ " Header keys {}",
+ format_optional_keys(config.headers.keys().cloned().collect())
+ ));
+ lines.push(format!(
+ " Header helper {}",
+ config.headers_helper.as_deref().unwrap_or("<none>")
+ ));
+ lines.push(format!(
+ " OAuth {}",
+ format_mcp_oauth(config.oauth.as_ref())
+ ));
+ }
+ McpServerConfig::Ws(config) => {
+ lines.push(format!(" URL {}", config.url));
+ lines.push(format!(
+ " Header keys {}",
+ format_optional_keys(config.headers.keys().cloned().collect())
+ ));
+ lines.push(format!(
+ " Header helper {}",
+ config.headers_helper.as_deref().unwrap_or("<none>")
+ ));
+ }
+ McpServerConfig::Sdk(config) => {
+ lines.push(format!(" SDK name {}", config.name));
+ }
+ McpServerConfig::ManagedProxy(config) => {
+ lines.push(format!(" URL {}", config.url));
+ lines.push(format!(" Proxy id {}", config.id));
+ }
+ }
+
+ lines.join("\n")
+ }
-
fn normalize_optional_args(args: Option<&str>) -> Option<&str> {
args.map(str::trim).filter(|value| !value.is_empty())
}
@@@ -2294,11 -2317,23 +2596,23 @@@ mod tests
));
assert!(agents_error.contains(" Usage /agents [list|help]"));
assert!(skills_error.contains(
- "Unexpected arguments for /skills: show help. Use /skills, /skills list, or /skills help."
+ "Unexpected arguments for /skills: show help. Use /skills, /skills list, /skills install <path>, or /skills help."
));
- assert!(skills_error.contains(" Usage /skills [list|help]"));
+ assert!(skills_error.contains(" Usage /skills [list|install <path>|help]"));
}
+ #[test]
+ fn rejects_invalid_mcp_arguments() {
+ let show_error = parse_error_message("/mcp show alpha beta");
+ assert!(show_error.contains("Unexpected arguments for /mcp show."));
+ assert!(show_error.contains(" Usage /mcp show <server>"));
+
+ let action_error = parse_error_message("/mcp inspect alpha");
+ assert!(action_error
+ .contains("Unknown /mcp action 'inspect'. Use list, show <server>, or help."));
+ assert!(action_error.contains(" Usage /mcp [list|show <server>|help]"));
+ }
+
#[test]
fn renders_help_from_shared_specs() {
let help = render_slash_command_help();
@@@ -2337,9 -2373,9 +2652,9 @@@
));
assert!(help.contains("aliases: /plugins, /marketplace"));
assert!(help.contains("/agents [list|help]"));
- assert!(help.contains("/skills [list|help]"));
+ assert!(help.contains("/skills [list|install <path>|help]"));
- assert_eq!(slash_command_specs().len(), 26);
- assert_eq!(resume_supported_slash_commands().len(), 14);
+ assert_eq!(slash_command_specs().len(), 27);
+ assert_eq!(resume_supported_slash_commands().len(), 15);
}
#[test]