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