Safe Read-Only SQLite Explorer MCP Server
Provides read-only inspection and exploration of SQLite databases, enabling listing of tables and views, describing columns, foreign keys, indexes, and DDL, executing SELECT/EXPLAIN/WITH queries with pagination and timing, and browsing a schema summary resource, all under strict multi-layer read-only safeguards.
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.
Safe Read-Only SQLite Explorer MCP Server
A safe SQLite database inspection and exploration server built on the Model Context Protocol (MCP) using FastMCP.
Enables AI coding assistants and autonomous agents (such as Antigravity, Cursor, and Claude Desktop) to inspect schemas, execute analytical queries, and review data models with strict, multi-layer read-only guarantees.
1. Multi-Layer Security Model
To prevent accidental data corruption, unauthorized mutations, or Denial-of-Service through unindexed Cartesian joins, the server enforces a strict 4-Layer Defense:
Defense Layer | Mechanism | Protection Scope |
Layer 1: Driver / OS | Percent-Encoded URI Read-Only Mode ( | Blocks write operations at the SQLite VFS / OS file descriptor level. Uses RFC 3986 percent-encoding to prevent delimiter attacks via |
Layer 2: Engine Authorizer | C Authorizer Hook ( | Denies |
Layer 3: Pragma Enforcement |
| Enforces query-only mode at the database engine level upon connection creation. |
Layer 4: Query Sanitizer | Leading Statement Validation | Enforces that queries strictly begin with |
Additional Safeguards:
Progress Handler Step Limit: Automatically interrupts runaway queries (e.g., infinite recursive CTEs or unindexed Cartesian joins) exceeding virtual machine instruction limits (
SQLITE_MAX_INSTRUCTIONS, default 10,000,000).BLOB & Data Serialization Protection: Formats raw binary data (
bytes) as<BLOB N bytes>to prevent JSON-RPC serialization crashes (TypeError).Result Ceiling: Automatically truncates text fields over 500 characters (
... [truncated]) and enforces row ceilings (default 100, max 1000).Parameterized Schema Introspection: Uses SQLite's table-valued PRAGMA functions (
pragma_table_info(?),pragma_foreign_key_list(?),pragma_index_list(?)) with bound parameters to eliminate escaping issues on identifiers with apostrophes.
Related MCP server: sqlite-analyst
2. Capabilities
Tools
list_tables: Lists all user tables, views, and index counts within the SQLite database.describe_table: Returns detailed column definitions (column name, data type, nullability, defaults, primary key flags), foreign key constraints, indexes, and rawCREATE TABLEDDL.execute_query: Executes read-only SQL queries (SELECT,EXPLAIN,WITH) under strict pagination and formatting limits. Returns formatted JSON along with execution timing.
Resources
sqlite://schema: Dynamic Markdown resource summarizing the entire database structure, tables, columns, constraints, foreign keys, indexes, and raw DDL for rapid LLM absorption.
Prompts
analyze_schema: Structured DBA review prompt guiding the model to evaluate normalization, index coverage, foreign key completeness, and query optimization opportunities.
3. Installation & Setup
Prerequisites
Python 3.10+
uvor standard Pythonvenv
Setup with uv (Recommended)
# Clone the repository and navigate to the directory
cd Read-Only-SQLite-MCP-Server
# Create a virtual environment and install dependencies
uv venv .venv
uv pip install -e ".[dev]"Generate Sample Database
python tests/fixtures/create_sample_db.py -o sample.db4. Running the Server
Command Line
Run over standard I/O (stdio):
python -m sqlite_mcp.server --db-path ./sample.dbAlternatively, supply the database path via environment variable:
export SQLITE_DB_PATH="./sample.db"
python -m sqlite_mcp.serverLogging Protocol
stdoutis reserved strictly for JSON-RPC 2.0 protocol packets.All server diagnostics, startup messages, and error traces route exclusively to
sys.stderr.
5. Antigravity & MCP Client Integration
Add the server to your MCP client configuration (e.g., mcp_config.json):
{
"mcpServers": {
"sqlite-explorer": {
"command": "python",
"args": [
"-m",
"sqlite_mcp.server",
"--db-path",
"/absolute/path/to/your/database.db"
],
"env": {
"LOG_LEVEL": "INFO",
"SQLITE_MAX_INSTRUCTIONS": "10000000"
}
}
}
}6. Automated Test Suite
Run the full automated test suite covering security authorizers, data sanitization, FastMCP tool contracts, and stdio JSON-RPC lifecycle:
pytest -vThe test suite verifies:
Tested mutation vectors (
DROP,INSERT,UPDATE,ALTER,ATTACH,PRAGMA write) are caught and rejected.Layer 1 OS/VFS
mode=roprotection is verified in isolation with percent-encoded URIs.Multi-statement query injection is denied across all quoting styles (single quotes, double quotes, brackets, and backticks).
BLOBs and long strings serialize without errors.
Runaway loops and unindexed Cartesian joins trigger virtual machine instruction limit interrupts.
End-to-end stdio subprocess handshake passes without protocol corruption.
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
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Security layer for AI agents: Retrieve for controlled SQL reads, Guard for allow/deny writes.
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables safe, read-only SQL access to SQLite databases for AI agents, allowing schema exploration and SELECT queries with defense-in-depth protections.3MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to explore and query SQLite databases through read-only tools, with defense-in-depth sandboxing preventing any data modifications.MIT
- AlicenseAqualityCmaintenanceEnables 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.3MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to safely query and explore SQLite databases through read-only, guard-protected tools that block writes, sensitive table access, and runaway queries.1MIT