mcp-sqlite-tools
This server provides an MCP interface for safe, local SQLite database operations, including reading, writing, schema management, CSV import/export, transactions, and backups.
Open, create, close, list, and inspect SQLite databases and their metadata.
List, describe, create, and drop tables and views.
Run paginated read-only SQL queries with named or positional parameters.
Execute explicit write queries (INSERT/UPDATE/DELETE), schema queries, and batch inserts.
Import headered CSV files into tables and export tables or query results to CSV.
Export and import database schemas as SQL or JSON.
Begin, commit, and roll back transactions with nested savepoint support.
Back up databases online, including committed WAL data, and vacuum databases.
Restrict database and CSV paths through environment configuration to enforce safe access.
Provides tools for managing SQLite databases, including querying, schema operations, transaction management, and backups.
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., "@mcp-sqlite-tools Show me the first 5 rows of the users table"
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-sqlite-tools
A Model Context Protocol (MCP) server for safe, local SQLite database operations. It gives MCP clients explicit read, write, schema, transaction, CSV, backup, and maintenance tools.
Features
Open, create, inspect, back up, vacuum, and close SQLite databases
List, describe, create, and drop tables
Run paginated read queries with named or positional parameters
Run explicit write and schema queries
Import and export headered CSV files
Use transactions with nested savepoints
Export and import schemas as SQL or JSON
Restrict database and CSV paths through configuration
Classify destructive tools for client approval policies
Use Node's built-in SQLite driver with no native addon dependency
Related MCP server: SQLite Read-Only MCP Server
Requirements
Node.js 24.12 or later
An MCP client with stdio server support
Configure your MCP client
The MCP client starts this server through npx; a global installation
is not required.
Install with MCPick
MCPick can add the server to a supported client without manual JSON editing. This command targets Claude Code's local scope by default:
npx -y mcpick add \
--name sqlite-tools \
--command npx \
--args "-y,mcp-sqlite-tools"Select a client and scope explicitly when needed:
npx -y mcpick add \
--name sqlite-tools \
--command npx \
--args "-y,mcp-sqlite-tools" \
--client vscode \
--scope projectThe add command supports Claude Code, Gemini CLI, VS Code, Cursor,
Windsurf, OpenCode, and Pi. Run npx mcpick clients to see current
client capabilities, scopes, and configuration locations.
The examples track the latest package release. For reproducible
configuration, replace mcp-sqlite-tools in --args with an exact
version such as mcp-sqlite-tools@x.y.z.
Manual configuration
For unsupported clients or advanced configuration, add the server manually:
{
"mcpServers": {
"mcp-sqlite-tools": {
"command": "npx",
"args": ["-y", "mcp-sqlite-tools"],
"env": {
"SQLITE_DEFAULT_PATH": ".",
"SQLITE_ALLOW_ABSOLUTE_PATHS": "true",
"SQLITE_BUSY_TIMEOUT": "30000",
"SQLITE_JOURNAL_MODE": "wal",
"SQLITE_BACKUP_PATH": "./backups"
}
}
}
}VS Code uses a servers object instead of mcpServers. See the
configuration guide
for more client-specific examples.
Environment variables
Variable | Purpose | Default |
| Base directory for database files |
|
| Allow paths outside the default directory |
|
| Default backup directory | Default database path |
| SQLite lock busy timeout in milliseconds |
|
|
|
|
| Enable diagnostic logging |
|
When SQLITE_ALLOW_ABSOLUTE_PATHS=false, relative and absolute paths
must resolve inside SQLITE_DEFAULT_PATH. Symbolic links cannot be
used to escape that directory.
Use SQLITE_JOURNAL_MODE=delete for databases in file-synchronized
directories. The unsafe SQLite modes memory and off are not
accepted.
SQLITE_MAX_QUERY_TIME remains available as a deprecated alias for
SQLITE_BUSY_TIMEOUT. It does not limit wall-clock query runtime.
Tools
Tools are separated by intent so MCP clients can apply clear approval rules.
Safe and read-only
Tool | Purpose |
| Open an existing database |
| Close one database connection |
| Find database files in a directory |
| Read file and SQLite metadata |
| List tables and views |
| Read columns and constraints |
| Create a consistent online backup |
| Export a table or read-only query |
| Export schema as SQL or JSON |
| Run one SQLite read-only statement |
Writes, schema, and maintenance
Tool | Purpose |
| Create a new database file |
| Create a table from validated columns |
| Drop a table and its data |
| Run |
| Run one schema statement |
| Insert records in batches |
| Import a headered CSV file |
| Apply SQL or JSON schema objects |
| Rebuild a database to reclaim space |
| Begin a transaction or nested savepoint |
| Commit or release a savepoint |
| Roll back a transaction or savepoint |
See the complete API reference for parameters, responses, examples, pagination, and CSV options.
Safety model
The server does not treat every SQL string as equivalent:
execute_read_queryuses SQLite's authorizer API to reject writes, schema changes, unsafe PRAGMAs, attachment, and multiple statements.Write, schema, transaction, and destructive administration actions use separate tools so clients can request approval.
Database and CSV paths are resolved and validated before access.
Identifiers generated by tools are quoted.
Values are bound as parameters rather than interpolated into SQL.
Backups use SQLite's online backup API and include committed WAL data.
A client can allow read-only tools and require approval for destructive tools. Always review SQL and file paths before approving changes. Back up important databases before schema changes, imports, or large writes.
Why native SQLite?
Using node:sqlite removes the native addon, its install script, and
its platform-specific binaries. A clean production install fell from
31.3 MB with better-sqlite3 to 3.6 MB with native SQLite, an 88.5%
reduction. The npm tarball itself is similar in size: 63.1 KB native
versus 60.0 KB published. The large saving is in the installed
dependency tree.
The migration also removes better-sqlite3 and its type package. It
makes installation independent of prebuilt addon availability or a
working native compiler.
Driver benchmark
Lower times are better. These medians use 20,000 rows, two warmups, and seven measured runs per driver. Each sample uses a new database and the driver order alternates. Setup is outside the measured region except for the insert workload.
Workload |
|
| Native result |
Insert transaction | 11.13 ms | 23.78 ms | 2.14× faster |
Indexed point reads | 25.23 ms | 21.40 ms | 17.9% slower |
Full row scan | 6.39 ms | 3.29 ms | 94.3% slower |
Update transaction | 8.04 ms | 15.40 ms | 1.92× faster |
Online backup | 0.55 ms | 0.38 ms | 45.0% slower |
Measured on Linux x64 with Node.js 24.15.0 and an AMD Ryzen AI 9
HX 370. Node used SQLite 3.51.3; better-sqlite3@13.0.1 used SQLite
3.53.3. These microbenchmarks show driver trade-offs, not complete MCP
performance. MCP transport and validation costs are not included.
Development
git clone https://github.com/spences10/mcp-sqlite-tools.git
cd mcp-sqlite-tools
pnpm install
pnpm run check
pnpm test
pnpm run buildSee development and architecture for module responsibilities and other development commands.
Documentation
Contributing
Issues and pull requests are welcome.
License
MIT License. See LICENSE.
Available Tools
22 toolsbackup_database✓ SAFE: Back up SQLite DB, including committed WAL data.C
✓ SAFE: Back up SQLite DB, including committed WAL data.
Inputs: backup_path, source_database_name.
begin_transaction⚠️ TRANSACTION: Begin transaction; holds locks until end.C
⚠️ TRANSACTION: Begin transaction; holds locks until end.
Inputs: database_name.
bulk_insert⚠️ DESTRUCTIVE: Batch insert records with identical columns.C
⚠️ DESTRUCTIVE: Batch insert records with identical columns.
Inputs: data (required), table (required), batch_size, database_name.
close_database✓ SAFE: Close DB connection; file unchanged.C
✓ SAFE: Close DB connection; file unchanged.
Inputs: database_name.
commit_transaction✓ TRANSACTION: Commit transaction and release locks.D
✓ TRANSACTION: Commit transaction and release locks.
Inputs: database_name.
create_database⚠️ CREATES FILE: Create new empty SQLite DB; fails if file exists.B
⚠️ CREATES FILE: Create new empty SQLite DB; fails if file exists.
Inputs: path (required).
create_table⚠️ SCHEMA CHANGE: Create table; fails if it exists.C
⚠️ SCHEMA CHANGE: Create table; fails if it exists.
Inputs: name (required), columns (required), database_name.
database_info✓ SAFE: Get DB metadata and statistics, not row data.C
✓ SAFE: Get DB metadata and statistics, not row data.
Inputs: database_name.
describe_table✓ SAFE: Describe table columns and constraints.C
✓ SAFE: Describe table columns and constraints.
Inputs: table (required), verbosity, database_name.
drop_table⚠️ DESTRUCTIVE: Drop table and all data.C
⚠️ DESTRUCTIVE: Drop table and all data.
Inputs: table (required), database_name.
execute_read_query✓ SAFE: Execute read-only SQL with params and pagination.C
✓ SAFE: Execute read-only SQL with params and pagination.
Inputs: query (required), limit, offset, params, +2 more.
execute_schema_query⚠️ SCHEMA CHANGE: Execute DDL SQL with params.D
⚠️ SCHEMA CHANGE: Execute DDL SQL with params.
Inputs: query (required), params, database_name.
execute_write_query⚠️ DESTRUCTIVE: Execute INSERT/UPDATE/DELETE with params.C
⚠️ DESTRUCTIVE: Execute INSERT/UPDATE/DELETE with params.
Inputs: query (required), params, database_name.
export_csv⚠️ FILE WRITE: Export table or read-only query to CSV.D
⚠️ FILE WRITE: Export table or read-only query to CSV.
Inputs: file_path (required), query, table, append, +5 more.
export_schema✓ SAFE: Export schema as SQL or JSON.C
✓ SAFE: Export schema as SQL or JSON.
Inputs: format, tables, database_name.
import_csv⚠️ DESTRUCTIVE/SCHEMA: Import headered CSV into a table.D
⚠️ DESTRUCTIVE/SCHEMA: Import headered CSV into a table.
Inputs: table (required), file_path (required), quote, escape, +8 more.
import_schema⚠️ SCHEMA CHANGE: Import SQL/JSON schema objects.C
⚠️ SCHEMA CHANGE: Import SQL/JSON schema objects.
Inputs: schema (required), format, database_name.
list_databases✓ SAFE: List SQLite DB files in a directory.C
✓ SAFE: List SQLite DB files in a directory.
Inputs: directory.
list_tables✓ SAFE: List tables/views with pagination and verbosity.D
✓ SAFE: List tables/views with pagination and verbosity.
Inputs: limit, offset, verbosity, database_name.
open_database✓ SAFE: Open existing SQLite DB and set current context.C
✓ SAFE: Open existing SQLite DB and set current context.
Inputs: path (required).
rollback_transaction⚠️ TRANSACTION: Roll back transaction and release locks.D
⚠️ TRANSACTION: Roll back transaction and release locks.
Inputs: database_name.
vacuum_database✓ MAINTENANCE: VACUUM database to reclaim space.C
✓ MAINTENANCE: VACUUM database to reclaim space.
Inputs: database_name.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 22 tools
Each tool has a clearly distinct purpose, covering different aspects of database management (creation, connection, querying, schema, backup, export/import), with no overlapping functions.
All tool names follow the consistent verb_noun pattern (e.g., backup_database, execute_read_query, export_schema), using lowercase with underscores throughout.
With 22 tools, the set is comprehensive for a SQLite server, slightly exceeding the typical 3-15 range but justified by the wide range of operations (e.g., backup, vacuum, import/export).
The tool set covers database lifecycle, table management, data CRUD, schema operations, transactions, and backup/export functions, leaving no significant gaps for standard SQLite usage.
Maintenance
Related MCP Connectors
Security layer for AI agents: Retrieve for controlled SQL reads, Guard for allow/deny writes.
Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…
SQL validation, formatting, parsing, metadata extraction, linting, and security analysis.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides comprehensive SQLite database interaction for AI agents, including data manipulation, schema inspection, and automated query logging. It features a unique context preservation pattern that uses a dedicated meta-table to help autonomous agents maintain self-documenting database architectures.1MIT
- AlicenseAqualityDmaintenanceEnables safe, read-only SQL access to SQLite databases for AI agents, allowing schema exploration and SELECT queries with defense-in-depth protections.3MIT
- AlicenseAqualityDmaintenanceEnables safe exploration and analysis of SQLite databases through guarded read-only queries, schema inspection, aggregations, and CSV imports.5MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to safely work with SQLite databases by enforcing read/write separation, dry-run writes with confirmation, automatic backups, and an audit trail.MIT