mcp-sqlite-explorer
Provides read-only exploration and querying of a SQLite database: listing tables and views with row counts, describing schemas, indexes, and foreign keys, sampling rows, generating ER diagrams, and running safe read-only SQL queries.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcp-sqlite-explorer
Hand Claude the keys to your SQLite database. Keep the steering wheel locked.
mcp-sqlite-explorer is a Model Context Protocol server that lets
Claude (or any MCP client) list tables, read schemas, sample rows, draw an ER diagram and run SQL
against a SQLite file. It reads everything and writes nothing: read-only is enforced in four separate
layers, and the test suite tries to break every one of them.
Talk to your database
Point it at the bundled demo (an invented space-agency mission log) and just ask. The tool output
below is real, from examples/mission_control.db:
You: Which spacecraft flies the most missions, and did anything go seriously wrong out there?
Claude: calls
list_tables, thenquery:SELECT s.name, COUNT(*) AS missions FROM missions m JOIN spacecraft s USING (spacecraft_id) GROUP BY s.name ORDER BY missions DESC LIMIT 3
name
missions
Pale Lantern
7
Basalt Moth
6
Orrery Wren
5
then
query:SELECT m.code, e.logged_at, e.subsystem, e.message FROM telemetry_events e JOIN missions m USING (mission_id) WHERE e.severity = 'critical' ORDER BY e.logged_at
code
logged_at
subsystem
message
Gamma-106
2036-03-26 08:24:00
life support
Loss of signal for 12 minutes
Cosmo-122
2036-06-16 15:48:00
comms
Main engine shutdown earlier than planned
Helix-107
2037-02-27 19:25:00
thermal
Main engine shutdown earlier than planned
The lander Pale Lantern is the workhorse with 7 missions. Out of 106 telemetry events only 3 are critical: a 12-minute loss of signal on Gamma-106 and two early engine shutdowns.
You: Great. Now delete the scrubbed missions, they're clutter.
Claude: calls
querywithDELETE FROM missions WHERE status = 'scrubbed'Error executing tool query: Only SELECT, WITH, EXPLAIN and read-only PRAGMA statements are allowed (got DELETE).No can do: this server is read-only, so the 5 scrubbed missions stay put. If you want them gone, that's a job for your own migration tooling.
That last refusal is the point. You can let an agent roam a database snapshot without wondering what it might decide to "tidy up".
Related MCP server: mcp-sqlite-insights
Tools
Tool | What it does |
| Every table and view, with its type and row count. |
| Columns, types, nullability, defaults, primary key, row count, indexes and foreign keys. |
| Runs one read-only statement ( |
| First |
| A Mermaid |
Resource | What it holds |
| Every table and view with its |
Every tool is advertised with MCP's readOnlyHint: true and destructiveHint: false annotations, so
clients that honour them know these tools cannot change anything.
The demo database
examples/make_demo_db.py builds a synthetic mission-control database from a fixed random seed
(every craft, call sign and event is made up). The committed examples/mission_control.db is about
60 KB. This diagram is the verbatim output of schema_diagram() on it:
erDiagram
crew_members {
INTEGER crew_id PK
TEXT call_sign
TEXT role
TEXT home_base
DATE joined_on
}
mission_crew {
INTEGER mission_id PK,FK
INTEGER crew_id PK,FK
TEXT seat
}
missions {
INTEGER mission_id PK
TEXT code
INTEGER spacecraft_id FK
TEXT destination
TEXT status
DATE launch_date
INTEGER duration_days
REAL budget_mcr
}
spacecraft {
INTEGER spacecraft_id PK
TEXT name
TEXT class
INTEGER crew_capacity
DATE commissioned_on
}
telemetry_events {
INTEGER event_id PK
INTEGER mission_id FK
TIMESTAMP logged_at
TEXT severity
TEXT subsystem
TEXT message
}
crew_members ||--o{ mission_crew : "crew_id"
missions ||--o{ mission_crew : "mission_id"
spacecraft ||--o{ missions : "spacecraft_id"
missions ||--o{ telemetry_events : "mission_id"There is also a mission_summary view. Views show up in list_tables but are not drawn as entities.
Install
Requires Python 3.10+. The only runtime dependency is the official mcp Python SDK (1.x).
git clone https://github.com/TGabeCar/mcp-sqlite-explorer.git
cd mcp-sqlite-explorer
python -m venv .venv
# macOS/Linux: source .venv/bin/activate Windows: .venv\Scripts\activate
pip install -e .That gives you an mcp-sqlite-explorer command inside the venv. It speaks MCP over stdio.
mcp-sqlite-explorer examples/mission_control.db # path as an argument
SQLITE_DB_PATH=examples/mission_control.db mcp-sqlite-explorer # or via the environment
python -m mcp_sqlite_explorer examples/mission_control.db # module form works tooThe argument wins over SQLITE_DB_PATH. If neither is given, or the file does not exist, it exits
with a clear message. It never creates an empty database by accident.
Configure your client
Claude Code
claude mcp add sqlite-explorer -- mcp-sqlite-explorer /absolute/path/to/your.dbOr pass the path through the environment:
claude mcp add sqlite-explorer -e SQLITE_DB_PATH=/absolute/path/to/your.db -- mcp-sqlite-explorerIf the venv is not active when Claude Code starts, use the full path to the command
(/path/to/.venv/bin/mcp-sqlite-explorer).
Claude Desktop
Add this to claude_desktop_config.json (Settings > Developer > Edit Config):
{
"mcpServers": {
"sqlite-explorer": {
"command": "/absolute/path/to/.venv/bin/mcp-sqlite-explorer",
"args": ["/absolute/path/to/your.db"]
}
}
}On Windows the command is C:\\path\\to\\.venv\\Scripts\\mcp-sqlite-explorer.exe. Use absolute
paths: desktop apps do not start inside your virtualenv. Restart Claude Desktop after editing.
Security model
Defense in depth: each layer below blocks writes on its own, and
tests/test_security.py switches the layers off one at a time to prove it.
Read-only file handle. The database is opened through a SQLite URI with
mode=ro, so the engine refuses to write to the file at all. A missing file is an error, never a fresh empty database.PRAGMA query_only = ONon every connection.An authorizer callback (
sqlite3.Connection.set_authorizer) that allows only reads. It deniesINSERT/UPDATE/DELETE, everyCREATE/DROP/ALTER,ATTACH/DETACH, transactions,load_extension, and anyPRAGMAoutside a small read-only allowlist (table_info,index_list,foreign_key_list,user_versionand friends).PRAGMA writable_schemaandPRAGMA query_only = OFFnever get through.A static statement check before the SQL reaches SQLite. Comments, string literals and quoted identifiers are blanked out first (so
'please DELETE me'or a column named"update"is fine). Then the query must be a single statement starting withSELECT,WITH,EXPLAINorPRAGMA, with no write or admin keyword anywhere (soWITH x AS (...) DELETE ...is caught), and aPRAGMAmust be allowlisted and must not assign with=.
Limits that keep answers small and agents unstuck:
Limit | Value |
Rows from | default 100, hard max 1000; the reply says when more rows exist |
Rows from | default 5, hard max 50 |
Characters per cell | 200, then truncated with |
Query run time | 5 seconds, then SQLite is interrupted by a progress handler |
SQL length | 20,000 characters |
Table names given to describe_table and sample_rows are looked up in sqlite_master first and
then quoted, so they cannot smuggle SQL.
What it does not do: read-only is not the same as private. Anything in the file can be read by whoever drives the client, so point it at a database (or a copy) you are happy for the model to see. There is no per-table or per-column filtering yet; that is on the roadmap.
Development
pip install -e ".[dev]"
python -m pytest -q # tools, security, and a real in-memory MCP client session
python examples/make_demo_db.py # rebuild the demo databaseCI runs the suite on Ubuntu and Windows across Python 3.10, 3.12 and 3.13, plus a gitleaks secret scan over the full history.
src/mcp_sqlite_explorer/
db.py # all the logic, as plain testable functions
server.py # FastMCP wiring and the CLI entry point
examples/
make_demo_db.py
mission_control.db
tests/Roadmap
Publish to PyPI so
uvx mcp-sqlite-explorerjust worksTable and column allow/deny lists (keep
users.password_hashout of the model's sight entirely)Several databases in one server, picked by name
An
explain_querytool that turnsEXPLAIN QUERY PLANinto plain-English index adviceOptional CSV/JSON output for
queryA streamable HTTP transport flag
License
MIT © 2026 Gabe
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables Claude and other MCP clients to map a SQLite database's schema and run read-only SQL queries against it, with writes blocked at the SQLite level through multiple enforcement layers. Results come back as context-friendly Markdown tables with row caps and a query timeout.2MIT
- AlicenseNot gradedqualityBmaintenanceLets Claude Desktop, Claude Code, and other MCP clients map the structure of a SQLite database and run read-only SQL queries against it, returning compact Markdown results. Multi-layered protections make any write impossible, so a database can be explored without reviewing each query first.MIT
- AlicenseNot gradedqualityCmaintenanceEnables Claude and other MCP clients to inspect a local SQLite database's tables, columns, and schema, and run safe read-only SQL queries with capped JSON results.MIT
- AlicenseAqualityBmaintenanceEnables an AI agent to explore and understand a SQLite database file read-only, inspecting schema relationships, foreign-key gaps, data-quality issues, query plans and generated schema docs. Every tool is guarded so the database file cannot be modified.8MIT