Skip to main content
Glama
mcp-sqlite-explorer

mcp-sqlite-explorer

mcp-sqlite-explorer

CI License: MIT Node

Zero-dependency, read-only SQLite explorer and query sandbox for AI agents and developers.

Inspect databases, extract relational schemas, run bounded read-only queries, and generate token-dense database summaries for Claude, Cursor, and MCP-compatible coding agents β€” without risking accidental data modification or context window flooding.


✨ Features

  • πŸ›‘οΈ Multi-Layer Read-Only Safety:

    • AST-level query validator blocks all mutating statements (INSERT, UPDATE, DELETE, DROP, ALTER, ATTACH, mutating PRAGMAs).

    • Multi-query injection detection (disallows statement chaining via ;).

    • Native SQLite engine-level read-only mode (PRAGMA query_only = ON; and readOnly: true).

  • ⚑ Zero Native Dependencies:

    • Built entirely on Node 22+ native node:sqlite.

    • No node-gyp, no Python runtime requirement, no C++ compilation errors on Windows, macOS, or Linux.

  • 🧠 Token-Optimized AI Context Summaries:

    • sqlite_summarize_database produces high-density schema maps (tables, row counts, PKs, foreign keys, indexes) formatted specifically to conserve LLM context budgets.

  • πŸ“Š Bounded Query Sandbox:

    • Enforces pagination (limit & offset) with default cap (50 rows, max 500) and truncation indicators.

    • Formats results into GitHub-flavored markdown tables, compact TSV, or JSONL.

  • πŸ” Query Plan Explainer:

    • Inspect SQLite index utilization and execution plans with EXPLAIN QUERY PLAN.

  • πŸ’» Standalone CLI:

    • Dual-mode: works as both an MCP stdio server and a standalone terminal utility.


Related MCP server: db-query-mcp

πŸš€ Quick Start

1. Claude Desktop Configuration

Add mcp-sqlite-explorer to your claude_desktop_config.json:

{
  "mcpServers": {
    "sqlite-explorer": {
      "command": "npx",
      "args": ["-y", "mcp-sqlite-explorer", "serve", "--db", "/path/to/database.sqlite"]
    }
  }
}

2. Standalone CLI Usage

# List all tables and views with row counts
npx mcp-sqlite-explorer tables ./mydb.sqlite

# Describe table columns, primary keys, and foreign keys
npx mcp-sqlite-explorer describe ./mydb.sqlite users

# Run a safe read-only query
npx mcp-sqlite-explorer query ./mydb.sqlite "SELECT id, name FROM users LIMIT 10"

# Generate agent-ready database summary
npx mcp-sqlite-explorer summary ./mydb.sqlite

# Inspect query plan
npx mcp-sqlite-explorer explain ./mydb.sqlite "SELECT * FROM posts WHERE user_id = 1"

πŸ› οΈ MCP Tools Reference

Tool

Description

Key Parameters

sqlite_list_tables

List user tables and views with row and column counts

db_path, include_views

sqlite_describe_table

Full schema detail: columns, types, PKs, FKs, indexes, DDL

db_path, table

sqlite_read_query

Execute read-only query (SELECT, WITH) with pagination

db_path, query, limit, offset, format

sqlite_explain_query

Inspect SQLite execution plan

db_path, query

sqlite_summarize_database

Token-dense database overview for LLM context

db_path


πŸ”’ Security Model

  1. Strict SQL Whitelist: Only SELECT, WITH ... SELECT, EXPLAIN, and safe read-only PRAGMAs (table_info, database_list, index_list, foreign_key_list) are permitted.

  2. Comment Stripping: SQL comments (-- and /* */) are parsed and removed prior to analysis to prevent comment-cloaked attacks.

  3. No Database Writes: Any attempt to write or mutate triggers an immediate UnsafeQueryError before reaching SQLite.


πŸ§ͺ Testing

npm test          # Run Vitest test suite (35+ unit & e2e tests)
npm run typecheck # Validate TypeScript types
npm run build     # Compile TypeScript to dist/

πŸ“„ License

MIT Β© KaryawanSurga

Available Tools

5 tools
sqlite_describe_tableDescribe SQLite Table SchemaA
Read-only

Inspect columns, types, primary keys, foreign keys, indexes, and CREATE TABLE DDL for a specific table or view in SQLite.

Inputs: table (required), db_path.

sqlite_explain_queryExplain SQLite Query Execution PlanA
Read-only

Run EXPLAIN QUERY PLAN on a query to inspect SQLite index usage, table scans, and optimization steps.

Inputs: query (required), db_path.

sqlite_list_tablesList SQLite TablesA
Read-only

List all user tables and views in a SQLite database with row counts and column counts. Use this to discover database schema without loading data.

Inputs: db_path, include_views.

sqlite_read_queryExecute Safe Read-Only QueryA
Read-only

Execute a read-only SQL query (SELECT, WITH, PRAGMA info) safely on SQLite. All write/mutation queries are blocked.

Inputs: query (required), limit, format, offset, +1 more.

sqlite_summarize_databaseSummarize SQLite Database for AI AgentA
Read-only

Generate a token-dense markdown summary of the entire database (tables, row counts, columns, PKs, FK relationships, indexes) optimized for AI agent context windows.

Inputs: db_path.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 5 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes: listing, describing, querying, explaining, and summarizing. However, sqlite_summarize_database overlaps substantially with sqlite_list_tables and sqlite_describe_table because it aggregates similar schema/count information, and sqlite_read_query can also surface PRAGMA-style schema details.

    Naming Consistency5/5

    All tools use a consistent sqlite_verb_noun naming pattern: sqlite_list_tables, sqlite_describe_table, sqlite_read_query, sqlite_explain_query, sqlite_summarize_database. The convention is predictable and easy for an agent to follow.

    Tool Count5/5

    Five tools is well-scoped for a read-only SQLite exploration server. Each tool earns its place: schema discovery, table inspection, querying, query-plan inspection, and context-friendly summarization.

    Completeness5/5

    The server explicitly targets safe read-only exploration, and its surface covers the full workflow: discover tables, inspect schema, run read-only queries, analyze query plans, and summarize a database for agent context. No obvious read-only lifecycle gap remains.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Enables AI agents to safely explore and query a SQLite database in read-only mode, allowing them to inspect schema and run analytical SQL queries without risking data modification.
      3
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      Enables AI assistants to safely run read-only SQL against SQLite databases through whitelist-validated queries, capped result sets, and confined file paths. It also exposes schema inspection so models can discover tables and columns before querying.
      2
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to inspect database schemas and run strictly read-only SQL queries with guardrails against destructive statements, multi-statement chaining, and unbounded scans. Supports SQLite natively and PostgreSQL optionally.
      4
      84 PyPI
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI agents to explore and query SQLite databases through read-only, sandboxed tools for listing tables, describing schemas, fetching DDL, and running a single capped SELECT statement. Also supports plain-English questions that are converted to SQL and routed through the same sandbox.
      4
      MIT