SQLite Read-Only MCP Server
Provides read-only SQL access to a SQLite database, allowing AI agents to list tables, describe schemas, and run SELECT queries safely.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@SQLite Read-Only MCP Server list all tables in the database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Server for SQLite (read-only) — safe SQL for your AI agent
A small, production-minded MCP server (Model Context Protocol) that gives an AI agent —
Claude Desktop, Claude Code, or any MCP client — safe, read-only SQL access to a SQLite
database. Point it at a .db file and the agent can explore schemas and run SELECT queries —
but never write, drop, or escape the database.
Built on the official MCP Python SDK (
FastMCP). The read-only safety core has zero MCP dependency and is unit-tested on its own — the server is a thin, auditable wrapper.
Why read-only matters
Handing an LLM a raw database connection is how you get a DROP TABLE in production. This server
enforces read-only at two independent layers:
OS-level — the connection is opened with SQLite
?mode=ro+PRAGMA query_only, so any write fails at the engine.Statement-level —
queryrejects anything that isn't a singleSELECT/WITH(no multi-statements, noINSERT/UPDATE/DELETE/DROP/PRAGMAwrites), and caps row counts.
Defense in depth: even if one layer is bypassed, the other still holds. (There's a test that proves it.)
Related MCP server: sql-guard-mcp
What the agent gets (all 3 MCP primitives)
Primitive | Name | Does |
🔧 tool |
| List the tables in the database |
🔧 tool |
| Column schema (name, type, nullability, PK) |
🔧 tool |
| Run a single read-only |
📄 resource |
| The whole DB schema as text |
💬 prompt |
| A ready-made "explore this DB" prompt |
Quick start (≈ 1 minute)
git clone https://github.com/skycandykey1/mcp-sqlite-server
cd mcp-sqlite-server
pip install -r requirements.txt
# make a sample DB to play with
python examples/make_sample_db.py
# inspect it live in the MCP dev inspector
SQLITE_DB_PATH=examples/sample.db mcp dev mcp_sqlite/server.py
# ...or run the server directly
SQLITE_DB_PATH=examples/sample.db python -m mcp_sqlite.serverUse it from Claude Desktop
Add this to your Claude Desktop config (Settings → Developer → Edit Config), using absolute paths —
see examples/claude_desktop_config.example.json:
{
"mcpServers": {
"sqlite-readonly": {
"command": "python",
"args": ["-m", "mcp_sqlite.server"],
"cwd": "/absolute/path/to/mcp-sqlite-server",
"env": { "SQLITE_DB_PATH": "/absolute/path/to/your.db" }
}
}
}Restart Claude Desktop, then ask: "What tables are in my database? Show me the top 5 orders by amount."
How it fits together
MCP client (Claude Desktop / Claude Code)
│ MCP over stdio
▼
mcp_sqlite/server.py ← thin FastMCP wrapper (tools / resource / prompt)
│
▼
mcp_sqlite/db.py ← read-only core (no MCP dep, fully unit-tested)
│ ?mode=ro + query_only + SELECT-only guard
▼
your .db (read-only)Run the tests
pip install -r requirements-dev.txt
python -m pytest -q # offline — no MCP client, no API key neededLicense
MIT — see LICENSE.
💼 Built by
skycandykey1— available for AI agent & automation contract work. I build agents, MCP servers, and LLM automation. →skycandykey456@gmail.com·https://github.com/skycandykey1
Available Tools
3 toolsdescribe_tableA
Get the column schema (name, type, nullability, primary key) for one table.
Args: table: Table name, as returned by list_tables.
Inputs: table (required). Returns: result
list_tablesA
List all tables in the database.
Inputs: no named parameters. Returns: result
queryA
Run a READ-ONLY SQL query (a single SELECT or WITH statement) and return the rows.
Writes (INSERT/UPDATE/DELETE/DROP/...) are rejected. Results are capped at max_rows.
Args: sql: A single SELECT or WITH statement. max_rows: Maximum number of rows to return (1-1000, default 100).
Inputs: sql (required), max_rows.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clear, non-overlapping purpose: listing tables, describing a table's schema, and running read-only queries. No ambiguity.
Tool names follow a consistent verb_noun pattern ('describe_table', 'list_tables', 'query') with clear, predictable naming.
Three tools is ideal for a read-only SQL interface—covers essential operations without unnecessary complexity.
The set covers all necessary operations for a read-only database: enumeration, schema inspection, and arbitrary queries. No gaps.
Maintenance
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Security layer for AI agents: Retrieve for controlled SQL reads, Guard for allow/deny writes.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Deterministic safety, correctness & cost gate that vets Postgres SQL before your AI agent runs it.
Related MCP Servers
- 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
- AlicenseBqualityCmaintenanceEnables 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.2MIT
- AlicenseAqualityBmaintenanceEnables 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.4137 PyPIMIT