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