Skip to main content

systemprompt_cli/commands/infrastructure/logs/tools/
mod.rs

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