Litescope
Let AI agents touch production SQLite โ safely. Diagnose before the write, rewind after it. For Cloudflare D1, Turso, and local files.
Website ยท Roadmap ยท Sponsor

Ask Claude to change your D1 database โ and undo it if it's wrong. Every write is dry-run by default with the exact blast radius, and one call away from revert.

Free and open source (AGPL-3.0) โ every command, every fleet operation, self-hostable, no license key. The only paid thing is the hosted dashboard we run for you.
"It's just a file โ what's there to operate?"
That was true when SQLite was a local dev toy. It isn't anymore. D1, Turso,
LiteFS, and Litestream put SQLite in production at fleet scale โ thousands of
databases, one per tenant. But the tooling never caught up:
sqlite3 assumes one database. Production assumes thousands. There's no
pg_stat, no APM, no standard way to see from the outside why a database is
locked, why WAL is bloating, or which tenant went silent.
- Embedded means unobservable. The very thing that makes SQLite great โ no
server โ is what leaves you blind in production.
- Agents now write to your data. No SQLite tool was built assuming an AI
would run the migration. Litescope was.
Postgres has a mature tool for every problem. SQLite has none โ so Litescope is
one binary for the whole job: fleet observability, file-level superpowers
(bisect / rewind / salvage), lock & WAL diagnostics, and a safe interface for
agents. Things a generic DB client structurally can't do.
MCP โ Give Claude direct access to your D1
Claude Code โ install the plugin, which brings the MCP server plus five
skills (lock doctor, safe writes, migration review, fleet sweep, corruption
recovery) that teach the agent how to use it when something is wrong:
/plugin marketplace add croc100/Litescope
/plugin install litescope@litescope
Or just the MCP server, one line (read-only):
claude mcp add litescope -- litescope mcp
With writes + D1 (Litescope still dry-runs every write and captures a rewind
point before applying):
claude mcp add litescope \
-e CLOUDFLARE_API_TOKEN=your-token \
-e CLOUDFLARE_ACCOUNT_ID=your-account-id \
-- litescope mcp --allow-writes
Cursor โ one-click:
โ Add litescope to Cursor
(installs read-only; add --allow-writes and the Cloudflare env vars in
mcp.json to enable writes).
Claude Desktop / Windsurf / any MCP client โ add to the config file directly:
{
"mcpServers": {
"litescope": {
"command": "litescope",
"args": ["mcp", "--allow-writes"],
"env": {
"CLOUDFLARE_API_TOKEN": "your-token",
"CLOUDFLARE_ACCOUNT_ID": "your-account-id"
}
}
}
}
Also listed in the MCP Registry
as io.github.croc100/litescope.
Then ask Claude things like:
"List my D1 databases"
"Show me the schema of the users table in d1://abc-123"
"Delete every inactive user from d1://prod-db-id" โ dry-run first: shows the
exact blast radius before
you approve the write
"Undo that โ put it back the way it was" โ one-call revert via the
rewind_token from the write
"The deploy at 2pm broke something โ rewind prod to 1:45pm"
"Diff my local dev.db against d1://prod-db-id and show me the migration SQL"
| Tool | What it does |
|---|
litescope_d1_list | List all D1 databases in the account (UUID, name, DSN) |
litescope_query | Run a SELECT on any D1 database or local SQLite file |
litescope_schema | Inspect tables, columns, indexes |
litescope_health | Check for corruption, WAL bloat, fragmentation |
litescope_diff | Schema and row-count diff between any two sources |
litescope_migrate_plan | Generate migration SQL + blast-radius analysis |
litescope_migrate_diff | Generate migration SQL only (no blast-radius) |
litescope_advise | Performance analysis: missing indexes, full table scans |
litescope_check | Verify a backup against a reference database |
litescope_fingerprint | Cluster a fleet by schema fingerprint |
litescope_fleet_health | Triage faults across a whole fleet |
litescope_locks | Diagnose database is locked / SQLITE_BUSY (static + live) |
litescope_snapshot_list | List point-in-time snapshots for a local database |
litescope_query enforces token budgeting โ max_rows cap + columns
projection + truncation reporting โ so a large table never blows the agent's
context window.
| Tool | What it does |
|---|
litescope_query_write | Mutating SQL โ dry-run by default with exact rows affected and blast-radius diff (D1 dry-runs measured on a pulled copy); on apply, captures an undo point first (local: snapshot, D1: Time Travel bookmark) and returns it as a rewind_token |
litescope_write_undo | Revert a write in one call using its rewind_token โ local files and D1 alike; tokens are bound to the database they were minted for |
litescope_migrate_apply | Apply a migration โ same reversible contract as litescope_query_write |
litescope_autopilot | Self-driving optimization (ANALYZE, indexes, VACUUM) โ dry-run by default |
litescope_snapshot | Take a point-in-time backup of a local database |
litescope_restore | Restore a local database from a snapshot |
litescope_rewind | Restore a D1 database to a point in time (Time Travel) |
litescope_d1_pull | Download a D1 database to a local SQLite file |
litescope_d1_create | Create a new D1 database |
litescope_d1_delete | Delete a D1 database (irreversible) |
Write tools are off unless you start the server with --allow-writes, every
write is dry-run by default, and no write commits without an auto-captured undo
point. See the security model for the full boundary โ what each
layer protects against, and what it doesn't.
Prompts & Resources
Beyond tools, the MCP server exposes prompts โ canned workflows like
diagnose_locked_database, review_migration, safe_optimize, and
health_checkup that chain the tools above into a safe plan โ and
resources: a database's schema, data dictionary, live health, and live lock
diagnosis โ readable by the agent without spending a tool call, and
subscribable for push updates whenever the underlying file changes. Bind one
with litescope mcp ./app.db, or address any source via
litescope://schema/{source}, litescope://dictionary/{source},
litescope://health/{source}, and litescope://locks/{source}.
The server implements MCP 2026-07-28, the stateless revision: server/discover,
per-request protocol metadata, resultType, caching hints (ttlMs /
cacheScope), and subscriptions/listen streams โ alongside tool annotations
(read-only / destructive hints), structured output (structuredContent +
outputSchema) and argument completion. It is dual-era: a client that still
opens with the initialize handshake is served MCP 2025-06-18 unchanged, so
older MCP clients keep working.
Interactive views (MCP Apps)
Four tools answer with an interactive panel rendered inside the conversation,
via the MCP Apps
extension (io.modelcontextprotocol/ui):
| Tool | View |
|---|
litescope_locks | Lock doctor โ verdict, each finding's exact PRAGMA/DSN fix, live lock probe |
litescope_health | Health panel โ integrity, WAL, fragmentation, snapshot cover |
litescope_query_write / litescope_migrate_apply | Blast radius โ rows affected per statement, schema impact, rewind token |
litescope_fleet_health | Fleet grid โ every database worst-first, with drill-down |
The views are single self-contained documents compiled into the binary. They
load nothing from the network, so the host's strictest CSP applies and a
database's contents cannot leave the iframe. They never write, either: a button
that would apply or undo a write hands the request back to the conversation,
because a click inside an embedded panel is not the user approving a production
write. A host without the extension gets the same results as text.
Remote / hosted (Streamable HTTP)
By default litescope mcp speaks stdio. For a hosted, remote, or multi-client
setup, serve over the Streamable HTTP transport instead:
litescope mcp --http :7577 --http-token "$LITESCOPE_MCP_TOKEN"
POST a JSON-RPC message to the endpoint (/mcp by default). Modern clients are
served statelessly โ no session โ with each request carrying its own protocol
metadata and the standard MCP-Protocol-Version / Mcp-Method / Mcp-Name
headers, and change notifications arriving on a subscriptions/listen response
stream. Handshake-era clients still get a session via the Mcp-Session-Id
header and a GET SSE stream.
Before exposing it publicly, lock it down: --http-token (or the
LITESCOPE_MCP_TOKEN env var) requires Authorization: Bearer <token> on every
request, and --http-origin allowlists browser Origins (localhost is always
allowed) for DNS-rebinding protection. Without a token the endpoint is open and
the server prints a warning.
D1 โ CLI operations
Rewind โ D1 Time Travel
litescope rewind d1://DB_ID --to "2h ago"
litescope rewind d1://DB_ID --to "yesterday"
litescope rewind d1://DB_ID --to "2024-01-15T10:30:00Z"
litescope rewind list d1://DB_ID
Pull / Push โ sync between D1 and local SQLite
litescope d1 pull d1://DB_ID ./snapshot.db
litescope d1 push ./seed.db d1://DB_ID
litescope d1 push ./seed.db d1://DB_ID --drop-existing
Migrate โ schema changes on D1
litescope migrate local.db d1://DB_ID
litescope migrate apply d1://DB_ID migration.sql
Bisect โ find which commit broke a D1 database
Binary-search D1 Time Travel to pinpoint the exact snapshot where a query
started returning wrong results:
litescope bisect d1://DB_ID \
--good "3d ago" \
--bad now \
--check "SELECT COUNT(*) FROM orders WHERE status = 'paid'" \
--expect "gt:0"
Checks gt:0 (greater-than), lt:N, eq:N, or a literal value. Narrows
to the snapshot window where the condition first failed, then lets you
inspect or rewind.
Local SQLite
doctor โ one-shot checkup
litescope doctor app.db
litescope doctor app.db --deep
litescope doctor app.db --format html -o report.html
Combines integrity check, WAL/fragmentation health, index advisor, and schema lint in one command. Exits 1 when attention is needed โ use it as a CI quality gate.
snapshot / restore โ point-in-time backups
litescope snapshot app.db
litescope snapshot app.db --label before-migration
litescope snapshot app.db --keep 7
litescope snapshot list app.db
litescope restore app.db
litescope restore app.db --from <snapshot.db>
Snapshots live in a sibling .litescope-snapshots/ directory. Restore is
integrity-checked and takes a pre-restore safety snapshot first โ the same
"did you back up?" safety net that D1 gets from Time Travel, for local and Turso.
autopilot โ self-driving optimization
litescope autopilot app.db
litescope autopilot app.db --apply
litescope autopilot app.db --apply --aggressive
litescope autopilot --fleet litescope.fleet.yaml --apply
Runs ANALYZE + PRAGMA optimize, adds missing foreign-key indexes, and
(with --aggressive) VACUUMs and drops redundant indexes โ each explained in
plain language. Dry-run by default; every real change is preceded by an
automatic snapshot.
locks โ diagnose "database is locked"
litescope locks app.db
litescope locks app.db --live
litescope locks app.db --watch
litescope locks app.db --timeline
litescope locks app.db --timeline --since 24h
Inspects journal mode, busy_timeout, locking mode, and WAL bloat, and
prescribes the exact PRAGMA/DSN fix. --live identifies the process holding
the lock right now. --watch records every observation to a local history
store; --timeline then aggregates it into a per-database contention view โ
when the database was jammed, for how long, which processes held it, wait-time
percentiles, and whether the WAL checkpoint kept up.
diff โ schema and data diff
litescope diff old.db new.db
litescope diff old.db new.db --format json
litescope diff local.db d1://DB_ID
litescope diff local.db turso://TOKEN@ORG/prod
migrate โ generate and apply migrations
litescope migrate before.db after.db --output migration.sql
litescope migrate apply prod.db migration.sql --dry-run
litescope migrate apply prod.db migration.sql --verify after.db
migrate apply safety sequence: pre-flight integrity check โ VACUUM INTO backup โ single transaction โ FK verification โ auto-rollback on failure.
lint โ schema anti-patterns
litescope lint app.db
litescope lint app.db --strict
Rules: no-primary-key, untyped-column, not-strict, autoincrement-overhead, non-integer-pk.
schema โ inspect schema + ERD
litescope schema app.db
litescope schema app.db --erd
dump โ portable SQL export
litescope dump app.db -o backup.sql
litescope dump app.db --schema-only
litescope dump app.db --table users
import / export โ spreadsheets and SQLite
litescope import sales.csv
litescope import budget.xlsx
litescope export shop.db --table orders -o orders.xlsx
litescope export shop.db --query "SELECT city, COUNT(*) FROM users GROUP BY city"
Formats: CSV, TSV, JSON, Excel (.xlsx). No external dependencies.
monitor โ schema drift detection
litescope monitor snapshot prod.db --output baseline.json
litescope monitor check prod.db --baseline baseline.json
litescope monitor watch prod.db --baseline baseline.json --interval 1h --webhook https://hooks.slack.com/...
serve โ local web dashboard
litescope serve
litescope serve --config litescope.fleet.yaml
Fleet topology map, health triage, schema fingerprinting, interactive ERD, a
paginated data browser with a visual query builder, drag-drop import, and a
visual diff panel โ pick any two databases to review schema and row-count
changes before applying. Entirely local, no account required.
Fleet
Manage hundreds of databases at once. Built for multi-tenant apps on Turso and D1.
litescope fleet discover turso --org my-org --token $TURSO_API_TOKEN
litescope fleet discover d1 --account $CF_ACCOUNT_ID --token $CF_API_TOKEN
litescope fleet health
litescope fleet locks
litescope fleet fingerprint
litescope fleet migrate migration.sql --dry-run
litescope fleet migrate migration.sql --canary 5
litescope fleet migrate migration.sql
CI โ GitHub Action
Run Litescope on every pull request โ lint the schema, diff against the base
branch, and comment the blast radius so a risky migration can't merge unreviewed.
- uses: croc100/Litescope@v1
with:
args: "lint app.db --strict"
comment: "true"
args is any Litescope command; the job exits non-zero when Litescope flags
something, failing the check. See
examples/github-actions/migration-ci.yml
for a full lint + diff workflow.
| Input | Default | Description |
|---|
args | โ | Litescope command to run (required) |
version | latest | Release tag to install, or latest |
comment | false | Post output as a sticky PR comment |
working-directory | . | Directory to run in |
Install
Homebrew
brew install croc100/tap/litescope
npm / npx โ for JS and wrangler users, no separate install:
npx litescope doctor app.db
npm install -g litescope
Go install
go install github.com/croc100/litescope/cmd/litescope@latest
Binary download
macOS, Linux, Windows โ Releases.
Remote sources
| DSN | Provider |
|---|
./app.db or /path/to/file.db | Local SQLite file |
d1://DB_UUID | Cloudflare D1 (env: CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID) |
d1://TOKEN@ACCOUNT_ID/DB_UUID | Cloudflare D1 (explicit credentials) |
turso://TOKEN@ORG/DBNAME | Turso |
Pricing โ what's free
The tool is free. We only charge to run the dashboard for you.
| Free (OSS, AGPL-3.0) | Cloud (paid) |
|---|
| Every CLI command, MCP server, fleet ops | โ
| โ
|
litescope serve โ local web dashboard | โ
| โ
|
| Self-hosted dashboard on your own infra | โ
| โ
|
| Hosted dashboard we run & maintain | โ | โ
|
| Managed metadata ingestion, retention, alerting | โ | โ
|
| Org auth, teams, SSO | โ | โ
|
| Support SLA | โ | โ
|
The line is simple: the software and every feature is free and self-hostable
forever. You pay only if you want us to host and operate the dashboard so you
don't have to. No feature is locked behind a license key.
See litescope-site.pages.dev/pricing for the
hosted plans.
License
Litescope is AGPL-3.0. Free to use, modify, and self-host. If you offer it
as a network service the AGPL requires you to share your modifications. A
commercial license (AGPL exception + support SLA) is available for
organizations โ see COMMERCIAL.md or email
dl_litescope@crode.net.