Skip to content

trifle-io/trifle-cli

Repository files navigation

Trifle CLI

Query and push time-series metrics from your terminal. Works with Trifle App via API or directly against local databases (SQLite, Postgres, MySQL, Redis, MongoDB). Ships an MCP server mode for AI agent integration.

Part of the Trifle ecosystem.

Trifle CLI

Install

Homebrew (macOS/Linux):

brew install trifle-io/trifle/trifle

Shell script (macOS/Linux):

curl -sSL https://get.trifle.io | sh

Go:

go install github.com/trifle-io/trifle-cli@latest

Build locally (Go 1.24+):

go build -o trifle .

Quick Usage

Bootstrap Trifle App access

# Login (stores user token in config)
trifle auth login --url https://app.trifle.io --email user@example.com --password '<password>'

# Create a source and mint a source token
trifle source create project --name "Agent Project"
trifle source list
trifle source token create --source-type project --source-id <PROJECT_ID> --save --activate

# Optional: upload a local SQLite file when creating a database source
trifle source create database --display-name "SQLite Upload" --driver sqlite --sqlite-file ./metrics.sqlite

Query metrics from Trifle App

trifle metrics get \
  --key event::signup \
  --from 2026-02-10T00:00:00Z \
  --to 2026-02-16T00:00:00Z \
  --granularity 1h

Track metrics locally

# Set up a local SQLite database
trifle metrics setup --driver sqlite --db ./stats.db

# Push a metric
trifle metrics push --driver sqlite --db ./stats.db \
  --key event::signup --values '{"count":1}'

# Query it back
trifle metrics get --driver sqlite --db ./stats.db \
  --key event::signup \
  --from 2026-02-10T00:00:00Z --to 2026-02-16T00:00:00Z \
  --granularity 1h

Use with any database

# PostgreSQL
trifle metrics setup --driver postgres --dsn "postgres://user:pass@localhost:5432/myapp"

# MySQL
trifle metrics setup --driver mysql --host 127.0.0.1 --port 3306 --user root --database myapp

# MongoDB
trifle metrics setup --driver mongo --dsn mongodb://127.0.0.1:27017 --database myapp

# Redis
trifle metrics get --driver redis --prefix trifle:metrics --key event::signup \
  --from 2026-02-10T00:00:00Z --to 2026-02-16T00:00:00Z --granularity 1h

MCP Server Mode

Run Trifle CLI as an MCP server so AI agents (Claude, GPT, etc.) can query and track metrics:

trifle mcp serve

This enables AI agents to read your analytics, track their own token/cost usage, and generate insights through the standard MCP protocol.

Buffering

Configure write buffering for high-throughput local tracking:

trifle metrics push \
  --driver postgres --dsn "postgres://localhost:5432/myapp" \
  --key event::signup --values '{"count":1}' \
  --buffer-mode auto \
  --buffer-duration 2s \
  --buffer-size 500 \
  --buffer-aggregate

Documentation

Full reference at docs.trifle.io/trifle-cli

Trifle Ecosystem

Component What it does
Trifle App Dashboards, alerts, scheduled reports, AI-powered chat. Cloud or self-hosted.
Trifle::Stats (Ruby) Time-series metrics library for Ruby.
Trifle.Stats (Elixir) Time-series metrics library for Elixir.
Trifle Stats (Go) Time-series metrics library for Go.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/trifle-io/trifle-cli.

License

Available under the Elastic License 2.0. See LICENSE for details.

About

CLI for querying and pushing time-series metrics. Works with Trifle App API or local databases. MCP server mode for AI agents.

Topics

Resources

License

Stars

Watchers

Forks

Contributors