systemprompt_cli/commands/plugins/mcp/
mod.rs1pub mod call;
7pub mod call_client;
8pub mod list;
9mod list_packages;
10pub mod logs;
11pub mod logs_db;
12mod logs_disk;
13mod status;
14mod tools;
15mod tools_schema;
16pub mod types;
17pub mod validate;
18mod validate_output;
19
20use anyhow::{Context, Result, bail};
21use clap::Subcommand;
22
23use crate::context::CommandContext;
24use crate::shared::render_result;
25
26#[derive(Debug, Subcommand)]
27pub enum McpCommands {
28 #[command(about = "List configured MCP servers")]
29 List(list::ListArgs),
30
31 #[command(about = "Show MCP server runtime status")]
32 Status(status::StatusArgs),
33
34 #[command(about = "Validate MCP server configurations")]
35 Validate(validate::ValidateArgs),
36
37 #[command(about = "Tail logs for an MCP server")]
38 Logs(logs::LogsArgs),
39
40 #[command(about = "List discovered MCP packages from the registry")]
41 ListPackages(list_packages::ListPackagesArgs),
42
43 #[command(about = "List tools exposed by enabled MCP servers")]
44 Tools(tools::ToolsArgs),
45
46 #[command(about = "Invoke a tool on an MCP server")]
47 Call(call::CallArgs),
48}
49
50pub async fn execute(command: McpCommands, ctx: &CommandContext) -> Result<()> {
51 let config = &ctx.cli;
52 match command {
53 McpCommands::List(args) => {
54 let result = list::execute(args, config).context("Failed to list MCP servers")?;
55 render_result(&result, config);
56 Ok(())
57 },
58 McpCommands::Status(args) => {
59 let result = status::execute(args, ctx)
60 .await
61 .context("Failed to get MCP server status")?;
62 render_result(&result, config);
63 Ok(())
64 },
65 McpCommands::Validate(args) => {
66 let (result, valid) = validate::execute(args, ctx)
67 .await
68 .context("Failed to validate MCP server")?;
69 render_result(&result, config);
70 if !valid {
71 bail!("MCP server validation failed");
72 }
73 Ok(())
74 },
75 McpCommands::Logs(args) => {
76 let result = logs::execute(args, ctx.prompter(), config)
77 .await
78 .context("Failed to get MCP server logs")?;
79 render_result(&result, config);
80 Ok(())
81 },
82 McpCommands::ListPackages(args) => {
83 let result = list_packages::execute(args, ctx)
84 .await
85 .context("Failed to list MCP packages")?;
86 render_result(&result, config);
87 Ok(())
88 },
89 McpCommands::Tools(args) => {
90 let result = Box::pin(tools::execute(args, ctx))
91 .await
92 .context("Failed to list MCP tools")?;
93 render_result(&result, config);
94 Ok(())
95 },
96 McpCommands::Call(args) => {
97 let result = Box::pin(call::execute(args, ctx))
98 .await
99 .context("Failed to execute MCP tool")?;
100 render_result(&result, config);
101 Ok(())
102 },
103 }
104}