@lubo3395/mcp-sqlite-server
Allows VS Code / GitHub Copilot to directly operate SQLite databases via MCP protocol, providing tools for querying, schema management, data import/export, and more.
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., "@@lubo3395/mcp-sqlite-serverlist 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.
@lubo3395/mcp-sqlite-server
SQLite 数据库 MCP 服务器 — 让 AI 助手(Claude、Cursor、VS Code Copilot 等)通过 MCP 协议直接操作 SQLite 数据库。
Node 版本要求:>= 22 基于 Node.js 内置
node:sqlite,无需任何原生编译依赖,开箱即用。 如果你的 Node 版本低于 22,请升级 Node 或联系我们讨论其他方案。
功能
工具 | 功能 | 读写 |
| 执行任意 SQL 语句(支持参数化查询) | R+W |
| 列出所有表名及行数 | R |
| 查看表的结构、列、索引和 DDL | R |
| 创建新表 | W |
| 删除表 | W |
| 添加列 | W |
| 创建索引 | W |
| 删除索引 | W |
| 从 CSV 文件导入数据 | W |
| 从 JSON 文件导入数据 | W |
| 查询结果导出为 CSV | R |
| 查询结果导出为 JSON | R |
Related MCP server: MCP SQLite Server
安全
支持 --readonly 只读模式。启用后:
better-sqlite3 驱动层拒绝写入
sqlite_query只允许 SELECT / PRAGMA / EXPLAIN / WITHDDL 和导入工具全部拦截
安装
npx 直接使用(推荐)
{
"mcpServers": {
"sqlite": {
"command": "npx",
"args": ["-y", "@lubo3395/mcp-sqlite-server", "--db", "./data.db", "--max-rows", "200"]
}
}
}全局安装
npm install -g @lubo3395/mcp-sqlite-server
mcp-sqlite-server --db ./data.db --max-rows 200配置
Claude Desktop / Claude Code
在 claude_desktop_config.json 或 claude.json 中添加:
{
"mcpServers": {
"sqlite": {
"command": "npx",
"args": ["-y", "@lubo3395/mcp-sqlite-server", "--db", "D:/path/to/data.db", "--max-rows", "200"],
"env": {}
}
}
}只读模式:
{
"mcpServers": {
"sqlite": {
"command": "npx",
"args": ["-y", "@lubo3395/mcp-sqlite-server", "--db", "D:/path/to/data.db", "--readonly", "--max-rows", "200"]
}
}
}多数据库:
{
"mcpServers": {
"sqlite": {
"command": "npx",
"args": ["-y", "@lubo3395/mcp-sqlite-server", "--db", "./main.db", "--db", "./reference.db", "--max-rows", "200"]
}
}
}VS Code / GitHub Copilot
在 .vscode/mcp.json 中添加:
{
"servers": {
"sqlite": {
"command": "npx",
"args": ["-y", "@lubo3395/mcp-sqlite-server", "--db", "./data.db", "--max-rows", "200"]
}
}
}Cursor
在 .cursor/mcp.json 中添加:
{
"mcpServers": {
"sqlite": {
"command": "npx",
"args": ["-y", "@lubo3395/mcp-sqlite-server", "--db", "./data.db", "--max-rows", "200"]
}
}
}Cline / Roo Code
在 cline.json 中添加:
{
"mcpServers": {
"sqlite": {
"command": "npx",
"args": ["-y", "@lubo3395/mcp-sqlite-server", "--db", "./data.db", "--max-rows", "200"]
}
}
}Tool 详情
sqlite_query
执行 SQL 语句,支持参数化查询防止注入。查询结果自动截断(默认最多 200 行),避免浪费 token。
参数 | 类型 | 必填 | 说明 |
| string | 是 | SQL 语句 |
| array | 否 | 参数化查询参数( |
| number | 否 | 返回行数上限(默认 200,受 |
| number | 否 | 跳过的行数,配合 limit 分页 |
| string | 否 | 数据库别名 |
示例:
查询: SELECT * FROM users WHERE age > ?
参数: [25]
分页: limit=50, offset=100返回值包含 total_count(总行数)和 has_more(是否还有更多),AI 可据此决定是否继续分页。
sqlite_list_tables
列出所有表名及行数。
参数 | 类型 | 必填 | 说明 |
| string | 否 | 数据库别名 |
sqlite_get_schema
查看指定表的结构信息。
参数 | 类型 | 必填 | 说明 |
| string | 是 | 表名 |
| string | 否 | 数据库别名 |
sqlite_create_table
创建新表。
参数 | 类型 | 必填 | 说明 |
| string | 是 | 表名 |
| string | 是 | 列定义 JSON(见下方说明) |
| boolean | 否 | 是否添加 IF NOT EXISTS |
| string | 否 | 数据库别名 |
columns 参数格式:
[
{"name": "id", "type": "INTEGER", "pk": true, "autoIncrement": true},
{"name": "name", "type": "TEXT", "notnull": true},
{"name": "email", "type": "TEXT", "unique": true},
{"name": "age", "type": "INTEGER", "defaultValue": "0"}
]sqlite_drop_table / sqlite_add_column / sqlite_create_index / sqlite_drop_index
分别为删除表、添加列、创建索引、删除索引。支持 if_exists / if_not_exists 和 db_alias 参数。
sqlite_import_csv / sqlite_import_json
从文件导入数据到表。支持 create_if_not_exists 自动建表。
参数 | 类型 | 必填 | 说明 |
| string | 是 | 文件路径 |
| string | 是 | 目标表名 |
| boolean | 否 | 自动建表 |
| string | 否 | 分隔符(CSV,默认 |
| boolean | 否 | 是否含表头(CSV,默认 true) |
sqlite_export_csv / sqlite_export_json
将查询结果导出到文件。
参数 | 类型 | 必填 | 说明 |
| string | 是 | SELECT 查询 |
| string | 是 | 输出文件路径 |
| array | 否 | 参数化查询参数 |
| boolean | 否 | 是否覆盖已有文件 |
命令行参数
mcp-sqlite-server --db <path> [选项...]
--db <path> SQLite 数据库文件路径(必填,可指定多个)
--readonly 只读模式(禁止写操作)
--max-rows <n> 查询返回的最大行数上限(默认 200,设为 0 不限制)
--help, -h 显示帮助本地开发
git clone https://github.com/lubo3395/mcp-sqlite-server.git
cd mcp-sqlite-server
npm install
npm run dev # 开发模式(热重载)
npm run build # 构建
npm start # 启动使用 MCP Inspector 测试:
npx @modelcontextprotocol/inspector node dist/index.js --db ./test.db技术栈
运行时: Node.js 22+(内置
node:sqlite)MCP SDK:
@modelcontextprotocol/sdk校验:
zod构建: TypeScript + tsc
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Query, join, profile, clean and convert CSV/JSON/Parquet with server-side DuckDB over MCP.
Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Shared memory and actions for Claude, Kiro, OpenAI, Cursor, and other MCP-compatible AI clients.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceExposes sqlite3 database functionality as MCP tools, enabling SQL query execution, schema management, and CRUD operations.1MIT
- FlicenseNot gradedqualityDmaintenanceQuery, explore, and manage SQLite databases through the Model Context Protocol. Connect any MCP-compatible AI client to your databases.-
- FlicenseAqualityDmaintenanceProvides SQLite database analytics operations through MCP, enabling AI assistants to connect, query, explore schema, and export data from SQLite databases.47-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to manage and query SQLite databases through MCP tools, supporting CRUD operations, schema management, and saved views.4 npmMIT