Skip to main content

boost/tools/
info.rs

1//! `application-info` — summary of the running app: env, drivers, version.
2
3use async_trait::async_trait;
4use serde_json::{json, Value};
5
6use crate::protocol::CallToolResult;
7use crate::tool::{Context, Tool};
8
9pub struct ApplicationInfo;
10
11#[async_trait]
12impl Tool for ApplicationInfo {
13    fn name(&self) -> &'static str {
14        "application-info"
15    }
16    fn description(&self) -> &'static str {
17        "High-level summary of the running Anvilforge app: name, environment, database driver, framework version, whether APP_KEY is set."
18    }
19
20    async fn call(&self, ctx: &Context, _args: Value) -> CallToolResult {
21        let app = ctx.container.app();
22        CallToolResult::json(&json!({
23            "framework": "anvilforge",
24            "framework_version": env!("CARGO_PKG_VERSION"),
25            "app": {
26                "name": app.name,
27                "env": app.env,
28                "url": app.url,
29                "debug": app.debug,
30                "key_set": !app.key.is_empty(),
31            },
32            "database": {
33                "driver": format!("{:?}", ctx.container.driver()),
34            },
35            "routes_count": ctx.routes.len(),
36            "components_count": spark::registry::classes().len(),
37            "models_count": cast_core::registered_models().len(),
38            "log_entries_buffered": ctx.log_buffer.count(),
39        }))
40    }
41}