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