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