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