dbtrail
Claude Integration

Using Claude with dbtrail

Query your MySQL change history using natural language

Once you've connected Claude to dbtrail, you can query your MySQL change history using natural language.

Example conversations

Finding deleted rows

You: Show me all rows deleted from the orders table in production in the last 24 hours.

Claude: I found 3 deleted rows in production.orders since yesterday:

order_idcustomeramountdeleted_at
1042acme-corp$299.002026-03-07 14:23:01
1043widgets-inc$150.502026-03-07 15:01:33
1044acme-corp$75.002026-03-07 16:45:12

Investigating changes

You: What changed in the users table for user_id 5678 this week?

Claude: I found 2 changes to user 5678 this week:

  1. UPDATE on Mar 5 at 10:15: email changed from old@example.com to new@example.com
  2. UPDATE on Mar 7 at 09:30: status changed from active to suspended

Finding the first event of the day

You: What is the oldest registered event that happened today on the production server?

Claude: The earliest event today was an INSERT into production.heartbeat at 2026-03-20 00:00:01 UTC, a routine heartbeat write from the replication monitor.

Finding the earliest delete in a time range

You: Show me the first row deleted from sessions after the deploy at 2pm yesterday.

Claude: The first DELETE in app.sessions after 2026-03-19 14:00 was at 14:03:22 UTC:

session_iduser_idcreated_atdeleted_at
a8f3c9e120412026-03-19 09:15:002026-03-19 14:03:22

This was 3 minutes after the deploy, so it could be the new session cleanup job kicking in.

Generating recovery SQL

You: Generate SQL to recover the deleted order 1042.

Claude: Here's the recovery SQL (dry-run). Review carefully before executing:

SET autocommit = 0;
BEGIN;
INSERT INTO `production`.`orders` (`order_id`, `customer`, `amount`, `status`)
VALUES (1042, 'acme-corp', 299.00, 'active');
COMMIT;

Always review recovery SQL

Recovery is always dry-run: Claude generates the SQL but never executes it. A DBA must review and run the SQL manually.

Who-changed attribution is a dbtrail EE capability

Questions like "who was the first person to modify the pricing table since Monday?" need forensic attribution: mapping each change to a MySQL user, host, and client program. The open-source index records each change's raw connection_id; full attribution is part of dbtrail EE.

Tips for effective queries

  1. Be specific about the server. If you have multiple servers, mention which one: "on the production-main server"
  2. Use time ranges: "in the last hour", "since March 1st", "between 2pm and 3pm yesterday"
  3. Filter by event type: "show me only DELETEs", "what was updated"
  4. Reference tables explicitly: "in the orders table in the mydb schema"
  5. Ask for the first or oldest event: "what was the first INSERT today?", "show me the oldest delete since the deploy". Claude retrieves the oldest matching events first without scanning through all results

What Claude can and cannot do

Can doCannot do
Query indexed changesExecute SQL on your database
Filter by schema, table, time, event typeModify data directly
Generate recovery SQL (dry-run)Run recovery SQL automatically
List DDL schema changesStart/stop streams
Check server and stream statusAccess data outside the configured index

The MCP server applies no rate limits of its own.

On this page