io.github.spences10/mcp-sqlite-tools

数据与存储

by spences10

面向本地 SQLite 数据库操作的 MCP server,支持常见查询、管理与数据处理任务。

什么是 io.github.spences10/mcp-sqlite-tools

面向本地 SQLite 数据库操作的 MCP server,支持常见查询、管理与数据处理任务。

README

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

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:

bash
npx -y mcpick add \
  --name sqlite-tools \
  --command npx \
  --args "-y,mcp-sqlite-tools"

Select a client and scope explicitly when needed:

bash
npx -y mcpick add \
  --name sqlite-tools \
  --command npx \
  --args "-y,mcp-sqlite-tools" \
  --client vscode \
  --scope project

The 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:

json
{
	"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_BACKUP_PATH": "./backups"
			}
		}
	}
}

VS Code uses a servers object instead of mcpServers. See the configuration guide for more client-specific examples.

Environment variables

VariablePurposeDefault
SQLITE_DEFAULT_PATHBase directory for database files.
SQLITE_ALLOW_ABSOLUTE_PATHSAllow absolute database pathstrue
SQLITE_BACKUP_PATHDefault backup directoryDefault database path
SQLITE_BUSY_TIMEOUTSQLite lock busy timeout in milliseconds30000
DEBUGEnable diagnostic loggingfalse

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

ToolPurpose
open_databaseOpen an existing database
close_databaseClose one database connection
list_databasesFind database files in a directory
database_infoRead file and SQLite metadata
list_tablesList tables and views
describe_tableRead columns and constraints
backup_databaseCreate a consistent online backup
export_csvExport a table or read-only query
export_schemaExport schema as SQL or JSON
execute_read_queryRun one SQLite read-only statement

Writes, schema, and maintenance

ToolPurpose
create_databaseCreate a new database file
create_tableCreate a table from validated columns
drop_tableDrop a table and its data
execute_write_queryRun INSERT, UPDATE, or DELETE
execute_schema_queryRun one schema statement
bulk_insertInsert records in batches
import_csvImport a headered CSV file
import_schemaApply SQL or JSON schema objects
vacuum_databaseRebuild a database to reclaim space
begin_transactionBegin a transaction or nested savepoint
commit_transactionCommit or release a savepoint
rollback_transactionRoll 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_query uses 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.

Workloadnode:sqlitebetter-sqlite3Native result
Insert transaction11.13 ms23.78 ms2.14× faster
Indexed point reads25.23 ms21.40 ms17.9% slower
Full row scan6.39 ms3.29 ms94.3% slower
Update transaction8.04 ms15.40 ms1.92× faster
Online backup0.55 ms0.38 ms45.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

bash
git clone https://github.com/spences10/mcp-sqlite-tools.git
cd mcp-sqlite-tools
pnpm install
pnpm run check
pnpm test
pnpm run build

See development and architecture for module responsibilities and other development commands.

Documentation

Contributing

Issues and pull requests are welcome.

License

MIT License. See LICENSE.

常见问题

io.github.spences10/mcp-sqlite-tools 是什么?

面向本地 SQLite 数据库操作的 MCP server,支持常见查询、管理与数据处理任务。

相关 Skills

技术栈评估

by alirezarezvani

Universal
热门

对比框架、数据库和云服务,结合 5 年 TCO、安全风险、生态活力与迁移复杂度做量化评估,适合技术选型、栈升级和替换路线决策。

帮你系统比较技术栈优劣,不只看功能,还把TCO、安全性和生态健康度一起量化,选型和迁移决策更稳。

数据与存储
未扫描24.7k

资深数据科学家

by alirezarezvani

Universal
热门

覆盖实验设计、特征工程、预测建模、因果推断与模型评估,适合用 Python/R/SQL 做 A/B 测试、时序分析和生产级 ML 落地,支撑数据驱动决策。

从 A/B 测试、因果分析到预测建模一条龙搞定,既有硬核统计方法也懂业务沟通,特别适合把数据结论真正落地。

数据与存储
未扫描24.7k

资深架构师

by alirezarezvani

Universal
热门

适合系统设计评审、ADR记录和扩展性规划,分析依赖与耦合,权衡单体或微服务、数据库与技术栈选型,并输出Mermaid、PlantUML、ASCII架构图。

搞系统设计、技术选型和扩展规划时,用它能更快理清架构决策与依赖关系,还能直接产出 Mermaid/PlantUML 图,方案讨论效率很高。

数据与存储
未扫描24.7k

相关 MCP Server

by Anthropic

热门

PostgreSQL 是让 Claude 直接查询和管理你的数据库的 MCP 服务器。

这个服务器解决了开发者需要手动编写 SQL 查询的痛点,特别适合数据分析师或后端开发者快速探索数据库结构。不过,由于是参考实现,生产环境使用前务必评估安全风险,别指望它能处理复杂事务。

数据与存储
89.7k

SQLite 数据库

编辑精选

by Anthropic

热门

SQLite 是让 AI 直接查询本地数据库进行数据分析的 MCP 服务器。

这个服务器解决了 AI 无法直接访问 SQLite 数据库的问题,适合需要快速分析本地数据集的开发者。不过,作为参考实现,它可能缺乏生产级的安全特性,建议在受控环境中使用。

数据与存储
89.2k

by Firecrawl

热门

Firecrawl 是让 AI 直接抓取网页并提取结构化数据的 MCP 服务器。

它解决了手动写爬虫的麻烦,让 Claude 能直接访问动态网页内容。最适合需要实时数据的研究者或开发者,比如监控竞品价格或抓取新闻。但要注意,它依赖第三方 API,可能涉及隐私和成本问题。

数据与存储
7.1k

评论