litescope
Litescope is an MCP-first operations tool for Cloudflare D1 and SQLite databases, giving AI agents direct access for inspection, migration, optimization, and fleet management.
Read-Only Capabilities
Health Inspection: Check for corruption, WAL bloat, fragmentation, and reachability — returns a severity verdict (ok/warning/critical)
Schema Inspection: Retrieve tables, columns (name, type, not-null, primary key), and indexes from any SQLite or D1 database
Read-Only Queries: Run SELECT statements or read-only PRAGMAs with token budgeting (row caps, column projection, truncation reporting)
Database Diff: Compare two databases (any combination of local, D1, Turso) for schema and row-count differences
Migration Planning: Generate migration SQL with blast-radius analysis (safe/risky/destructive classification and lock-duration estimates)
Index Advisor: Analyze for missing/redundant indexes and full table scans — returns runnable CREATE/DROP INDEX suggestions
Backup Verification: Run integrity checks on a backup and optionally compare schema/row counts against a reference
Lock Diagnosis: Diagnose SQLITE_BUSY issues — inspects journal mode, busy_timeout, WAL bloat, and live lock state
Fleet Schema Fingerprinting: Cluster a fleet of databases by schema to detect drift across instances
Fleet Health Triage: Run parallel health checks across an entire fleet, sorted worst-first
List D1 Databases: List all Cloudflare D1 databases with UUIDs, names, table counts, and DSNs
List Snapshots: List available point-in-time backups for a local SQLite database
Write Capabilities (require --allow-writes)
Mutating SQL: Execute write statements with automatic dry-run and pre-application snapshots
Apply Migrations: Apply migration SQL with dry-run and backup support
Self-Driving Optimization (Autopilot): Automatically apply ANALYZE, PRAGMA optimize, missing FK indexes, VACUUM, and redundant-index cleanup — with a pre-run snapshot for rollback
Snapshot & Restore: Take and restore point-in-time snapshots of local databases
D1 Time Travel: Rewind a Cloudflare D1 database to a specific point in time
D1 Sync: Pull D1 to local SQLite, create, or delete D1 databases
Additional CLI Tools
Local SQLite doctor, schema linting, ERD/schema visualization, SQL dump, CSV/Excel import-export, schema drift monitoring, and a local web dashboard
CI integration via GitHub Action for linting, diffing, and PR commenting
Staged fleet migrations with canary support
Provides tools for managing Cloudflare D1 databases, including listing, querying, migrating, rewinding via Time Travel, pulling/pushing, and health checks.
Enables local SQLite database operations such as querying, schema inspection, diffing, migrations, snapshots, restore, autopilot optimization, lock diagnosis, and monitoring.
Supports diff operations between local SQLite databases and Turso remote databases, extending Litescope's data management to Turso.
Litescope
Let AI agents touch production SQLite — safely. Diagnose before the write, rewind after it. For Cloudflare D1, Turso, and local files.
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.
Why a tool for SQLite?
"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:
sqlite3assumes one database. Production assumes thousands. There's nopg_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.
Related MCP server: mcp-server-sqlite
MCP — Give Claude direct access to your D1
Claude Code — one line (read-only):
claude mcp add litescope -- litescope mcpWith 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-writesCursor — 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"Read-only tools (always available)
Tool | What it does |
| List all D1 databases in the account (UUID, name, DSN) |
| Run a SELECT on any D1 database or local SQLite file |
| Inspect tables, columns, indexes |
| Check for corruption, WAL bloat, fragmentation |
| Schema and row-count diff between any two sources |
| Generate migration SQL + blast-radius analysis |
| Generate migration SQL only (no blast-radius) |
| Performance analysis: missing indexes, full table scans |
| Verify a backup against a reference database |
| Cluster a fleet by schema fingerprint |
| Triage faults across a whole fleet |
| Diagnose |
| 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.
Write tools (--allow-writes)
Tool | What it does |
| 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 |
| Revert a write in one call using its |
| Apply a migration — same reversible contract as |
| Self-driving optimization (ANALYZE, indexes, VACUUM) — dry-run by default |
| Take a point-in-time backup of a local database |
| Restore a local database from a snapshot |
| Restore a D1 database to a point in time (Time Travel) |
| Download a D1 database to a local SQLite file |
| Create a new D1 database |
| 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 2025-06-18: tool annotations (read-only /
destructive hints), structured output (structuredContent + outputSchema),
argument completion, resource-change subscriptions, and server logging.
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), or open a GET SSE
stream for server notifications; each client gets its own session via the
Mcp-Session-Id header.
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
# Restore to a previous point in time
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"
# List available restore points (30-day window + migration timestamps)
litescope rewind list d1://DB_IDPull / Push — sync between D1 and local SQLite
# Download D1 → local (for inspection, backup, or diffing)
litescope d1 pull d1://DB_ID ./snapshot.db
# Upload local → D1 (seed a fresh database or restore from snapshot)
litescope d1 push ./seed.db d1://DB_ID
litescope d1 push ./seed.db d1://DB_ID --drop-existingMigrate — schema changes on D1
# Diff local dev schema against live D1 — generate migration SQL
litescope migrate local.db d1://DB_ID
# Apply a migration directly to D1
litescope migrate apply d1://DB_ID migration.sqlBisect — 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 # exhaustive integrity_check
litescope doctor app.db --format html -o report.htmlCombines 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 # consistent VACUUM INTO copy
litescope snapshot app.db --label before-migration
litescope snapshot app.db --keep 7 # retain only the 7 newest
litescope snapshot list app.db
litescope restore app.db # restore the newest snapshot
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 # dry-run: show the plan
litescope autopilot app.db --apply # apply the safe actions
litescope autopilot app.db --apply --aggressive
litescope autopilot --fleet litescope.fleet.yaml --applyRuns 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 # static config diagnosis
litescope locks app.db --live # is a writer holding the lock now?
litescope locks app.db --watch # stream lock-state changes
litescope locks app.db --timeline # recorded contention history
litescope locks app.db --timeline --since 24hInspects 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 # local vs live D1
litescope diff local.db turso://TOKEN@ORG/prodmigrate — 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.dbmigrate 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 # exit 1 on info findings tooRules: 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 # Mermaid ER diagramdump — portable SQL export
litescope dump app.db -o backup.sql
litescope dump app.db --schema-only
litescope dump app.db --table usersimport / export — spreadsheets and SQLite
litescope import sales.csv # → sales.db, table "sales"
litescope import budget.xlsx # first sheet → budget.db
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 # exits 1 on drift
litescope monitor watch prod.db --baseline baseline.json --interval 1h --webhook https://hooks.slack.com/...serve — local web dashboard
litescope serve # opens http://127.0.0.1:7575
litescope serve --config litescope.fleet.yamlFleet 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.
# Discover all databases
litescope fleet discover turso --org my-org --token $TURSO_API_TOKEN
litescope fleet discover d1 --account $CF_ACCOUNT_ID --token $CF_API_TOKEN
# Triage the whole fleet
litescope fleet health
litescope fleet locks # roll up "database is locked" contention, worst-first
litescope fleet fingerprint # cluster by schema — find drift before it bites
# Stage a migration across the fleet
litescope fleet migrate migration.sql --dry-run
litescope fleet migrate migration.sql --canary 5
litescope fleet migrate migration.sqlCI — 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" # post the result as a sticky PR commentargs 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 |
| — | Litescope command to run (required) |
|
| Release tag to install, or |
|
| Post output as a sticky PR comment |
|
| Directory to run in |
Install
Homebrew
brew install croc100/tap/litescopenpm / npx — for JS and wrangler users, no separate install:
npx litescope doctor app.db
npm install -g litescopeGo install
go install github.com/croc100/litescope/cmd/litescope@latestBinary download
macOS, Linux, Windows — Releases.
Remote sources
DSN | Provider |
| Local SQLite file |
| Cloudflare D1 (env: |
| Cloudflare D1 (explicit credentials) |
|
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 | ✅ | ✅ |
| ✅ | ✅ |
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.
Maintenance
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/croc100/Litescope'
If you have feedback or need assistance with the MCP directory API, please join our Discord server