systemprompt_cli/commands/infrastructure/logs/tools/
mod.rs1mod list;
2
3use anyhow::Result;
4use clap::Subcommand;
5use schemars::JsonSchema;
6use serde::{Deserialize, Serialize};
7use systemprompt_runtime::DatabaseContext;
8
9use crate::CliConfig;
10
11#[derive(Debug, Subcommand)]
12pub enum ToolsCommands {
13 #[command(
14 about = "List MCP tool executions",
15 after_help = "EXAMPLES:\n systemprompt infra logs tools list\n systemprompt infra logs \
16 tools list --name research_blog\n systemprompt infra logs tools list \
17 --server content-manager --since 1h"
18 )]
19 List(list::ListArgs),
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
23pub struct ToolExecutionRow {
24 pub timestamp: String,
25 pub trace_id: String,
26 pub tool_name: String,
27 pub server: String,
28 pub status: String,
29 #[serde(skip_serializing_if = "Option::is_none")]
30 pub duration_ms: Option<i64>,
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
34pub struct ToolsListOutput {
35 pub executions: Vec<ToolExecutionRow>,
36 pub total: u64,
37}
38
39pub async fn execute(command: ToolsCommands, config: &CliConfig) -> Result<()> {
40 match command {
41 ToolsCommands::List(args) => list::execute(args, config).await,
42 }
43}
44
45pub async fn execute_with_pool(
46 command: ToolsCommands,
47 db_ctx: &DatabaseContext,
48 config: &CliConfig,
49) -> Result<()> {
50 match command {
51 ToolsCommands::List(args) => list::execute_with_pool(args, db_ctx, config).await,
52 }
53}