# croc100/Litescope [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/croc100/Litescope  
**GitHub Stars:** 1  
**npm Downloads (last month):** 373  
**Views:** 4  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/croc100-litescope

## Description
MCP-first operations toolchain for SQLite, Cloudflare D1, and Turso. Inspect, diff, migrate, monitor, back up, and repair databases over stdio. Read-only by default; writes are opt-in, dry-run first, and auto-snapshot before applying. npx -y litescope mcp

## Tools
Capabilities this server exposes over MCP:

- **litescope_health** — Inspect a SQLite or D1 database for operational faults: corruption (PRAGMA integrity check), WAL bloat from a starved checkpoint, freelist fragmentation, and reachability. Returns a JSON report with a severity (ok / warning / critical) and a list of issues. Read-only.

For D1: set CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID and use source=d1://DB_ID.
- **litescope_schema** — Load the schema of a SQLite or D1 database — tables, columns (name, type, not-null, primary key), and indexes. Returns JSON. Read-only.

Works with local files, D1, and Turso. For D1: set CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID and use source=d1://DB_ID.
- **litescope_diff** — Compare two SQLite or D1 databases and return their schema and row-count differences as JSON. Works across any combination of local files, D1, and Turso — e.g. diff a local migration target against a live D1 database. Read-only.
- **litescope_migrate_plan** — Plan a migration between two SQLite or D1 databases WITHOUT applying it. Returns the migration SQL plus a blast-radius analysis: each operation classified safe / risky / destructive, with an estimated write-lock duration for table rebuilds. Use this before applying any migration to a D1 database. Read-only.
- **litescope_migrate_diff** — Diff two SQLite or D1 databases and return the migration SQL that would bring the 'old' source up to the 'new' schema — without applying it or computing blast-radius. Useful when you only need the SQL to review or pass to litescope_migrate_apply. For a full blast-radius analysis use litescope_migrate_plan. Read-only.
- **litescope_query** — Run a read-only SQL query on any SQLite or D1 database and return the results as JSON. Only SELECT statements and read-only PRAGMAs are allowed. This is the primary tool for an AI agent to explore data in a D1 database.

Token budgeting: results are capped at max_rows (default 200) so a large table won't blow your context window — the response reports total_rows and truncated. Use the columns argument to project only the fields you need. Narrow with LIMIT / WHERE for precise reads.

For D1: set CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID and use source=d1://DB_ID.
- **litescope_advise** — Analyze a local SQLite database for performance problems and recommend fixes: foreign keys with no index, redundant indexes, and full table scans for any supplied queries. Returns findings with runnable CREATE/DROP INDEX suggestions. Read-only — recommends, never alters the schema. (Local files only.)
- **litescope_check** — Verify a SQLite backup. Runs a PRAGMA integrity check; if 'against' is given, also compares schema and row counts to a reference database. Returns a JSON report. Read-only. (Local files only.)
- **litescope_d1_list** — List all Cloudflare D1 databases in the account. Returns each database's UUID, name, creation date, table count, and the DSN to use with other litescope tools. Requires CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID environment variables. Read-only.
- **litescope_fingerprint** — Cluster a fleet of SQLite databases by schema and report how many distinct schemas are running, with each cluster's drift from the canonical (largest) one. Reads a fleet config file (litescope.fleet.yaml). Read-only.
- **litescope_fleet_health** — Triage operational faults across a whole fleet of SQLite databases in parallel — corruption, WAL bloat, fragmentation, reachability — sorted worst-first. Reads a fleet config file (litescope.fleet.yaml). Read-only.
- **litescope_locks** — Diagnose "database is locked" / SQLITE_BUSY and writer-starvation problems — the most common SQLite production failure. Inspects journal mode, busy_timeout, locking mode, and WAL bloat for local files, and returns provider-specific guidance for D1 and Turso. Each finding includes the exact PRAGMA or DSN change to apply. Returns a JSON report with a verdict (ok / attention / critical).

Set live=true (local files only) to instead probe the *current* lock state: whether a writer is holding the lock right now and which processes have the file open. Use this when an app is actively reporting "database is locked". Read-only.
- **litescope_snapshot_list** — List point-in-time snapshots (local backups) for a local SQLite database, newest first. Snapshots are created with litescope_snapshot (requires --allow-writes). Use this to find a snapshot to restore, or to confirm a database has a backup before a risky write. Read-only; local files only.
- **litescope_autopilot** — Self-driving DBA for a local SQLite database. Derives safe maintenance and optimization actions — ANALYZE, PRAGMA optimize, missing foreign-key indexes, and (when fragmented) VACUUM / redundant-index cleanup — each explained in plain language. When queries are supplied, also flags full table scans, predicates on an expression (lower(col), date(col) — needs an expression index), and equality filters that only match a small slice of the table (needs a partial index instead of indexing the whole column). For large databases it also flags an undersized page cache (PRAGMA cache_size/mmap_size — guidance only, not stored in the file).

Dry-run by default (apply=false): returns the plan without changing anything. apply=true executes the safe actions and requires --allow-writes; a snapshot is taken first so the run is one litescope_restore away from undo. Risky actions (VACUUM, dropping indexes, query-derived indexes) only run with aggressive=true. Local files only.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "litescope": {
    "command": "npx",
    "args": ["-y","litescope","mcp"],
    "env": {
      "CLOUDFLARE_API_TOKEN": "",
      "CLOUDFLARE_ACCOUNT_ID": "",
      "LITESCOPE_MCP_TOKEN": ""
    }
  }
}
```

**Requires environment variables:** `CLOUDFLARE_API_TOKEN`, `CLOUDFLARE_ACCOUNT_ID`, `LITESCOPE_MCP_TOKEN` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What croc100/Litescope MCP server does

The croc100/Litescope MCP server connects MCP clients to local SQLite files and Cloudflare D1 databases, with support for Turso described by the project. It is intended for operational work rather than simple query execution: agents can inspect schemas, check database health, compare sources, plan migrations, investigate locks, and analyze performance issues.

The default posture is read-only. Write operations are unavailable unless the server starts with `--allow-writes`. Even then, mutating SQL and migrations are dry-run first, report affected rows and blast-radius information, and capture a recovery point before applying changes. Local databases use snapshots, while D1 uses a Time Travel bookmark. The resulting `rewind_token` can be passed to the undo operation.

## How it works

By default, `litescope mcp` communicates over stdio, so it can be configured as a local MCP server in Claude Desktop, Claude Code, Cursor, Windsurf, or another MCP client. A database can be supplied when starting the server, such as `litescope mcp ./app.db`. The server also provides database-oriented MCP resources for schemas, data dictionaries, health, and lock diagnosis, along with prompts for workflows including migration review and locked-database diagnosis.

For remote or multi-client deployments, the server can use Streamable HTTP with `--http`. An HTTP token can require bearer authentication, and an origin allowlist helps protect the endpoint from DNS-rebinding risks. Without an HTTP token, the endpoint is open and emits a warning.

Query results include controls for maximum rows, selected columns, and truncation reporting. These limits help keep large result sets within an agent's context window. The implementation also exposes structured output, tool annotations, argument completion, resource subscriptions, and server logging under MCP 2025-06-18.

## Setup and configuration

Install and start the server with `npx -y litescope mcp` for the standard stdio mode. Read-only use does not require the Cloudflare credentials shown in the project examples when working with local files. D1 access uses `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID`; these are supplied in the MCP client's environment when needed.

Enable mutating operations by adding `--allow-writes`. This flag does not remove the dry-run and recovery-point behavior. To expose the service over HTTP, use the `--http` option and optionally set `--http-token` or `LITESCOPE_MCP_TOKEN`.

## Tools and capabilities

Read-only capabilities include listing D1 databases, running SELECT statements, inspecting schemas, checking corruption and WAL or fragmentation conditions, comparing schemas and row counts, generating migration SQL, advising on indexes and scans, verifying backups, fingerprinting fleets, checking fleet health, diagnosing locks, and listing local snapshots.

Opt-in write capabilities include mutating SQL, applying migrations, optimization actions such as `ANALYZE`, index creation, and `VACUUM`, local snapshots and restores, D1 rewind operations, D1 pulls, and D1 database creation or deletion. The D1 deletion operation is irreversible according to the project documentation.

## Limitations and notes

The safety workflow reduces accidental changes but does not make every operation reversible: D1 deletion is explicitly irreversible, and write access still requires deliberate server configuration. HTTP deployments need their own access controls; the documentation warns that an endpoint without a token is open. Cloudflare credentials are needed for the related D1 operations, while local SQLite work can be configured without them.

The project is distributed under AGPL-3.0. Its hosted dashboard is separate from the free, open-source command-line and MCP functionality described here.

_Full upstream README: https://allmcps.com/mcp/croc100-litescope/readme_

