decision_cockpit 0.1.0

Layer — product decision memory with MCP tools and an embedded review dashboard
Documentation
use decision_cockpit::{bootstrap, config::Config, http, mcp, state::AppState};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // IMPORTANT: stdout is the MCP transport, so all logs must go to stderr.
    init_tracing();

    let config = Config::from_env()?;

    bootstrap::ensure_postgres(&config).await?;

    let state = AppState::connect(&config.database_url).await?;
    state.migrate().await?;

    if config.serve_dashboard {
        let _http = http::spawn(state.clone(), &config);
    }

    tracing::info!(
        dashboard = %config.dashboard_url(),
        "Decision Cockpit MCP server starting on stdio"
    );
    mcp::serve_stdio(state, config).await?;
    Ok(())
}

fn init_tracing() {
    let filter = EnvFilter::try_from_default_env()
        .unwrap_or_else(|_| EnvFilter::new("info,decision_cockpit=debug"));
    tracing_subscriber::registry()
        .with(filter)
        .with(tracing_subscriber::fmt::layer().with_writer(std::io::stderr))
        .init();
}