Skip to main content

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

1//! `infra logs tools` subcommands for listing MCP tool executions.
2//!
3//! Exposes [`ToolsCommands`] and the [`ToolExecutionRow`] / [`ToolsListOutput`]
4//! shapes rendered for each execution record.
5//!
6//! Copyright (c) systemprompt.io — Business Source License 1.1.
7//! See <https://systemprompt.io> for licensing details.
8
9mod list;
10
11use anyhow::Result;
12use clap::Subcommand;
13use schemars::JsonSchema;
14use serde::{Deserialize, Serialize};
15use systemprompt_identifiers::TraceId;
16
17use crate::context::CommandContext;
18
19#[derive(Debug, Subcommand)]
20pub enum ToolsCommands {
21    #[command(
22        about = "List MCP tool executions",
23        after_help = "EXAMPLES:\n  systemprompt infra logs tools list\n  systemprompt infra logs \
24                      tools list --name research_blog\n  systemprompt infra logs tools list \
25                      --server content-manager --since 1h"
26    )]
27    List(list::ListArgs),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
31pub struct ToolExecutionRow {
32    pub timestamp: String,
33    pub trace_id: TraceId,
34    pub tool_name: String,
35    pub server: String,
36    pub status: String,
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub duration_ms: Option<i64>,
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
42pub struct ToolsListOutput {
43    pub executions: Vec<ToolExecutionRow>,
44    pub total: u64,
45}
46
47pub async fn execute(command: ToolsCommands, ctx: &CommandContext) -> Result<()> {
48    match command {
49        ToolsCommands::List(args) => list::execute(args, ctx).await,
50    }
51}