dbtrail
Claude Integration

Tools Reference

Complete reference for the tools available to Claude via the bintrail-mcp server

The following tools are available to Claude and other AI assistants connected to dbtrail. All six are read-only (annotated ReadOnlyHint: true and IdempotentHint: true). They read the index and never touch your source database.

There are two ways to serve them:

  • The web console's /mcp endpoint (recommended, see Claude Setup): authenticated with the console token, with the server selected by URL path (/mcp for the default server, /mcp/{name} for a specific one). Responses carry the console's result caps and field redactions, and the index_dsn parameter does not apply: the console owns the connection.
  • The standalone bintrail-mcp server (headless setups): reads the index database directly via the BINTRAIL_INDEX_DSN environment variable, or a per-call index_dsn parameter that overrides it. Runs over stdio by default, or as a Streamable HTTP server with --http <addr>; see the MCP server reference.

query

Search indexed binlog changes by schema, table, time range, or event type.

Parameters

ParameterTypeDescription
index_dsnstringMySQL DSN of the index database (optional if BINTRAIL_INDEX_DSN is set)
schemastringDatabase schema name
tablestringTable name
event_typestringINSERT, UPDATE, or DELETE
pkstringFilter by primary key value (use | for composites, e.g. 12345|2)
gtidstringFilter by GTID (e.g. 3e11fa47-...:42)
changed_columnstringFilter UPDATEs by changed column name (e.g. email)
sincestringStart time (ISO 8601 or YYYY-MM-DD HH:MM:SS)
untilstringEnd time
limitintegerMax results (default: 100)
column_eqarraycolumn=value filters matched against the before/after row images (repeat for AND; literal NULL matches JSON null)
flagstringFilter events from tables or columns carrying this flag
formatstringOutput format: json (default), table, or csv
profilestringApply a named access profile (table-level deny + column redaction)
no_archivebooleanDisable auto-routing to Parquet archives (MySQL-only results)

Response

The matching change events, rendered in the requested format (JSON by default), with a truncation warning when results hit the limit. Each event contains:

  • event_type: INSERT, UPDATE, or DELETE
  • timestamp: when the change occurred
  • schema / table: where the change happened
  • primary_key: primary key of the affected row
  • before: row state before the change (null for INSERTs)
  • after: row state after the change (null for DELETEs)

When Parquet archives are configured, results are automatically merged from the live index and the archives.


recover

Generate SQL statements to reverse database changes. Always runs in dry-run mode: dbtrail generates the SQL but never executes it.

Parameters

ParameterTypeDescription
index_dsnstringMySQL DSN of the index database (optional if BINTRAIL_INDEX_DSN is set)
schemastringDatabase schema name
tablestringTable name
pkstringFilter by primary key value (pipe-delimited for composites)
event_typestringOnly reverse INSERT, UPDATE, or DELETE events
gtidstringReverse the events of a specific transaction (GTID)
sincestringStart of the search window
untilstringEnd of the search window
changed_columnstringOnly reverse UPDATEs that modified this column
column_eqarraycolumn=value filters matched against the row images
flagstringFilter events from tables or columns carrying this flag
limitintegerMax events to reverse (default: 1000)
profilestringApply a named access profile
no_archivebooleanDisable auto-routing to Parquet archives

Response

A BEGIN/COMMIT-wrapped SQL script that reverses events in reverse chronological order (most recent first), with a trailing comment noting the number of reversal statements generated. The SQL comes back for review. Nothing executes automatically.

Recovery logic

Original eventGenerated SQL
DELETEINSERT INTO ... (restores deleted row)
UPDATEUPDATE ... SET (reverts to previous values)
INSERTDELETE FROM ... (removes inserted row)

status

Report the current state of the index and stream.

Parameters

ParameterTypeDescription
index_dsnstringMySQL DSN of the index database (optional if BINTRAIL_INDEX_DSN is set)

Response

Which binlog files have been indexed, the partition layout with estimated row counts, and an aggregate summary of indexed events.


list_schema_changes

List DDL schema changes (CREATE, ALTER, DROP, RENAME, TRUNCATE) recorded during binlog indexing or streaming. Use it to audit schema modifications or correlate structural changes with data anomalies.

Parameters

ParameterTypeDescription
index_dsnstringMySQL DSN of the index database (optional if BINTRAIL_INDEX_DSN is set)
schemastringFilter by schema name
tablestringFilter by table name
ddl_typestringFilter by DDL type: CREATE, ALTER, DROP, RENAME, or TRUNCATE
sincestringStart time filter
untilstringEnd time filter
limitintegerMax changes to return (default: 100)

Response

Each change includes the timestamp, affected schema and table, DDL type, the full DDL statement, and binlog coordinates (file, position, GTID).


recover_cascade

Generate reversal SQL for rows hit by a foreign-key ON DELETE / ON UPDATE CASCADE or SET NULL. InnoDB runs FK cascades below the binlog, so plain recover reverses only the parent change and silently misses the cascade-deleted children and the rewritten or nulled child foreign keys. This tool synthesizes those from the index and reverses them too. Dry-run only, like recover.

Parameters

ParameterTypeDescription
index_dsnstringMySQL DSN of the index database (optional if BINTRAIL_INDEX_DSN is set)
schemastringSchema of the parent table whose change cascaded (required)
tablestringParent table whose cascade touched children (required)
pkstringRestrict to a single changed parent primary key (pipe-delimited for composites)
pksarrayRestrict to several changed parent primary keys; mutually exclusive with pk
sincestringOnly parent changes at or after this time
untilstringOnly parent changes at or before this time
lookbackstringHow far before each parent change to search for child state (default 30d)
max_depthintegerMaximum cascade recursion depth, parent → child → grandchild (default 5)
limitintegerMax parent events to process, applied separately to the DELETE and the UPDATE scan (default 1000)
allow_incompletebooleanReturn the script even when the synthesis is provably partial (default false: any coverage caveat fails the call, with the caveats in the error)
baseline_dirstringLocal baseline snapshot directory, enabling the Phase-2 fallback (also recovers children untouched within the lookback window)
baseline_s3stringS3 prefix of baseline snapshots, used only when baseline_dir is unset

Response

The reversal SQL plus a structured coverage report: statement count, how many parent rows were reversed (split into deletes and key-changing updates), how many child rows were re-INSERTed, how many SET NULL and key restores were emitted, and two separate channels: incomplete (every reason the recovery is provably partial) and warnings (advisory notes on an otherwise-complete recovery). complete is exactly "incomplete is empty".


reconstruct

Reconstruct a single row's full state at a point in time. It folds a baseline snapshot with the events indexed after it, so columns never touched inside the retained window still resolve, which recover cannot do because it only reverses the events it has. Requires a baseline snapshot: a backup created from the console's Backups page, or the CLI dump → baseline pipeline.

Parameters

ParameterTypeDescription
index_dsnstringMySQL DSN of the index database (optional if BINTRAIL_INDEX_DSN is set)
schemastringDatabase schema name (required)
tablestringTable name (required)
pkstringPrimary key of the row to reconstruct (pipe-delimited for composites) (required)
atstringPoint in time to reconstruct at (YYYY-MM-DD HH:MM:SS or RFC 3339, default now)
historybooleanReturn every state transition from the baseline up to the target time instead of a single state
baseline_dirstringLocal directory of baseline Parquet snapshots (overrides BINTRAIL_BASELINE_DIR)
baseline_s3stringS3 prefix of baseline snapshots, used only when baseline_dir is unset
allow_gapsbooleanProceed even when part of the window is missing from the captured history. Default false: a coverage gap, or a permanent capture loss recorded by the stream, aborts rather than returning a silently wrong row state. What was overridden comes back in warnings

Response

The row's state at at, with the baseline it was folded from (baseline_time), how many events were applied (event_count), and flags distinguishing the three outcomes: the state, deleted as of that time (deleted), and no baseline row for that PK (found: false). With history: true, each transition carries its time, source (baseline, INSERT, UPDATE, DELETE), event ID, GTID, and resulting state.

Baseline location on the console endpoint

baseline_dir and baseline_s3 are accepted only by the standalone bintrail-mcp server. On the console's /mcp endpoint they are rejected for the same reason index_dsn is: an authenticated MCP client must not be able to point the console at arbitrary storage. The console uses the baseline configured for the selected server.


Access control

Pass profile on query or recover to apply a named access profile: table-level deny rules plus column redaction, authored with the CLI (bintrail flag / bintrail profile / bintrail access; profile authoring has no console UI yet). While a profile is active, Parquet archive routing is disabled (archive queries do not enforce profile rules).

Forensic attribution is a dbtrail EE capability

Tools that answer who made a change (who_changed, user_activity, connection_history) are part of dbtrail EE. They attribute events to MySQL users, hosts, and client programs. The open-source tools expose each event's raw connection_id for manual correlation.

On this page