mcp-server-sqlite

MCP数据服务

提供方 0xOmarA

数据服务 stdio · 本地进程 会话登录 社区 / 第三方 Claude DesktopClaudeZed
查看接入方式

A production-grade MCP server for SQLite that enforces fine-grained access control via SQLite's native authorizer at query-prepare time and exposes 13 tools for SQL execution, full-text search, backup, and schema introspection for secure AI-agent database access.

一句话选型结论

按资料字段整理

mcp-server-sqlite 属于数据服务类 MCP 服务器,stdio · 本地进程,会话登录,可直接接入 Claude Desktop、Claude、Zed,有可直接执行的安装命令。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类数据服务 传输方式stdio · 本地进程 鉴权会话登录 部署方式本地部署
GitHub 星标 3 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

数据服务
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

Local Deployment SQLite MCP server Rust database access control fine-grained permissions full-text search database backup AI agent integration SQL query

支持客户端

适用场景

Local DeploymentSQLiteMCP server

安装与配置

stdio · 本地进程 会话登录
客户端在本机拉起子进程,数据不出本机
mcp-server-sqlite --database ./my-database.db --preset read-only

这条命令只是入口,具体启动参数请按官方文档补齐,不要直接照搬到别的服务器。

  1. 1
    准备运行环境

    stdio 服务在本地起进程,需要先装好 rust,再按安装命令拉取依赖。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
数据库查询

用自然语言查库、取数,不用手写 SQL。

数据同步与清洗

把多来源数据拉到一处做整理。

报表取数

按口径快速拉出统计结果。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已适配 Claude Desktop、Claude、Zed,换客户端不用重新研究配置。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 使用前要准备好会话登录对应的凭据,并按最小权限配置。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在数据服务场景里让模型直接调用外部能力的人。
  • 已经在用 Claude Desktop、Claude 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 不方便管理密钥或第三方授权的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
mcp-server-sqlite当前 未标注 stdio · 本地进程 本地部署 有 2026-04-05
Memory 9d25f64e 9 未标注 未标注 无 2026-05-17
Getzep MCP 9 stdio · 本地进程 本地部署 有 2026-05-17
anything-llm 未标注 stdio · 本地进程 本地部署 有 2026-04-11
Prisma MCP Server 未标注 stdio · 本地进程 本地部署 有 2026-05-17
Astr Bot 未标注 stdio · 本地进程 本地部署 有 2026-05-17

服务器档案

数据服务
字段来自项目仓库与公开索引,中文说明由本站标注
提供方0xOmarA上游标注的维护方 0xOmarA
分类数据服务本站按上游分类展示
连接方式stdio · 本地进程客户端在本机拉起子进程,数据不出本机
鉴权方式会话登录远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · rust本地安装时用到的包标识与运行时
部署类型本地部署上游给出的部署形态
最近核验2026-04-05上游最后核验时间

详细介绍

17.1 KB
来自项目仓库与上游目录的原文,未做删改

mcp-server-sqlite

A production-grade MCP server for SQLite with fine-grained access control

Why this exists

Every existing MCP server for SQLite falls short in at least one critical way. The official reference server from Anthropic is a ~300-line Python script with known unpatched SQL injection vulnerabilities, no parameterized queries, no transactions, no read-only mode, and a hardcoded demo prompt. It was archived in May 2025 with Anthropic declining to fix the security issues, yet it was forked over 5,000 times. The community alternatives each solve one or two problems but none solves them comprehensively.

This server was built to be the SQLite MCP server you can actually trust in production. It is written in Rust, ships as a single binary with no runtime dependencies, and uses SQLite's own sqlite3_set_authorizer API to enforce access control at the query-preparation level, before any SQL ever executes. The access control system supports column-level granularity, specificity-based rule resolution, and five built-in presets ranging from deny-everything to allow-everything.

Features

  • Authorizer-based access control. Uses SQLite's native authorizer callback to intercept every operation at prepare time. Supports 30+ selector types covering reads, writes, DDL, pragmas, functions, transactions, attach/detach, and virtual tables, all with per-table, per-column, and per-function granularity.
  • Five permission presets. deny-everything, read-only (default), read-write, full-ddl, and allow-everything. Layer --allow and --deny overrides on top with a specificity-based resolution algorithm where deny wins ties.
  • 13 tools. A single execute tool for arbitrary SQL, plus purpose-built tools for schema introspection, full-text search, query planning, backups, and database maintenance.
  • Full-text search. First-class FTS5 support with dedicated tools for creating indexes and searching with BM25 ranking and highlighted snippets.
  • Query timeouts. Optional per-server timeout that uses SQLite's progress handler to abort runaway queries before they can tie up resources.
  • Connection pooling. Built on r2d2 for connection reuse with per-connection authorizer and timeout installation.
  • Init scripts. Seed schemas and data on first run with --init-sql files that are skipped when the database already exists.
  • Single binary. Compiles SQLite statically via rusqlite's bundled feature. No Python, no Node, no runtime dependencies.

Installation

From crates.io```bash

cargo install mcp-server-sqlite


### From source```bash
git clone https://github.com/0xOmarA/mcp-server-sqlite.git
cd mcp-server-sqlite
cargo install --path .

Quick start

Start a read-only server with an in-memory database:```bash
mcp-server-sqlite


Start a read-write server on a persistent database with a schema init file:```bash
mcp-server-sqlite --database ./app.db --preset read-write --init-sql schema.sql

Claude Desktop configuration

Add the following to your Claude Desktop MCP config file:```json
{
"mcpServers": {
"sqlite": {
"command": "mcp-server-sqlite",
"args": [
"--database", "./my-database.db",
"--preset", "read-only"
]
}
}
}


## Tools

The server exposes 13 tools over MCP. Each tool validates inputs, enforces the configured access control policy, and returns structured typed output.

### `execute`

Runs any SQL query against the database. This is the primary tool. It handles SELECT, INSERT, UPDATE, DELETE, DDL, and everything else SQLite supports. Returns typed result rows (preserving NULL, Integer, Real, Text, and Blob types) and a count of rows changed.```
execute({ "query": "SELECT name, age FROM students WHERE age > 20" })

Access control is enforced at the SQLite authorizer level, so denied operations never execute. If the configured policy denies any part of the query (a table read, a column access, a function call), the entire statement is rejected with a clear error message.

list_tables

Lists all tables in the database with their names and CREATE TABLE definitions.

describe_table

Returns column metadata for a specific table: column name, declared type, NOT NULL constraint, default value, and whether it is part of the primary key.```
describe_table({ "table_name": "students" })


### `list_indexes`

Lists indexes in the database. Optionally filter by table. Returns the index name, table name, uniqueness flag, ordered column list, and the WHERE clause for partial indexes.```
list_indexes({ "table_name": "students" })

list_foreign_keys

Returns foreign key constraints for a given table, including the local column, referenced table and column, and the ON UPDATE/ON DELETE actions.```
list_foreign_keys({ "table_name": "enrollments" })


### `list_views`

Lists all views with their names and defining SQL.

### `list_triggers`

Lists triggers in the database. Optionally filter by table. Returns the trigger name, attached table, event (INSERT/UPDATE/DELETE), timing (BEFORE/AFTER/INSTEAD OF), and full SQL definition.```
list_triggers({ "table_name": "students" })

explain_query

Returns the EXPLAIN QUERY PLAN output for a query without executing it. Shows how SQLite will access tables, which indexes it will use, and how it will join data. Useful for understanding query performance.```
explain_query({ "query": "SELECT * FROM students WHERE name = 'Omar'" })


### `backup`

Creates a full backup of the database to a file path using SQLite's online backup API. Runs incrementally in pages so it does not block other operations for long. Returns the number of pages copied and the destination path.```
backup({ "destination": "/tmp/app-backup.db" })

create_fts_index

Creates an FTS5 virtual table over specified columns of an existing table. The virtual table name defaults to {table}_fts but can be customized.```
create_fts_index({
"table_name": "articles",
"columns": ["title", "body"]
})


### `search_fts`

Runs a full-text search query against an FTS5 virtual table. Returns results ranked by BM25 relevance with highlighted snippets showing where the query matched. Configurable result limit, snippet length, and highlight markers.```
search_fts({
  "fts_table": "articles_fts",
  "query": "sqlite AND indexing",
  "limit": 5
})

vacuum

Runs the SQLite VACUUM command to rebuild the database file, reclaim unused space, and defragment storage.

database_info

Returns database metadata: SQLite version, page size, page count, total size in bytes, journal mode, WAL checkpoint status (when in WAL mode), freelist page count, and the number of tables and indexes.

Access control

The access control system is the core differentiator of this server. It is built on SQLite's sqlite3_set_authorizer callback, which means SQLite itself parses every query and reports every operation it will perform. The server then evaluates each operation against the configured policy. Denied operations cause the entire statement to be rejected at prepare time, before any data is read or modified.

This approach has several important properties:

  • Zero parsing gaps. SQLite does the parsing, not a third-party SQL parser. Every valid SQLite statement is handled correctly, including edge cases like triggers, views, CTEs, and virtual tables.
  • Column-level granularity. The Read and Update selectors accept both a table name and a column name, so you can deny access to specific columns (e.g. --deny Read(Users.ssn)).
  • Indirect operation tracking. If a trigger on table A fires an INSERT into table B, the authorizer catches the INSERT on table B. Operations hidden inside triggers and views are not invisible to the policy.
  • Fail-closed by default. The default preset is read-only. When allow and deny rules conflict at the same specificity level, deny wins.

Presets

Presets define the baseline permissions before any --allow/--deny overrides are applied.

Preset Allows Denies
deny-everything Nothing Everything
read-only (default) Read, Select, Transaction, Function, Recursive, Pragma Insert, Update, Delete, all DDL, Attach, Detach
read-write Extends read-only with Insert, Update, Delete, Savepoint, Analyze, Reindex, temp objects Permanent DDL, Attach, Detach
full-ddl Extends read-write with CreateTable, DropTable, AlterTable, CreateIndex, DropIndex, CreateTrigger, DropTrigger, CreateView, DropView Attach, Detach, virtual tables
allow-everything Everything Nothing

Selectors

Selectors identify the operation and, optionally, the exact resources a rule applies to. The syntax is Action or Action(field1.field2) where * is a wildcard.

Data operations:

Selector Fields Example
Read table_name.column_name Read(Users.email)
Insert table_name Insert(AuditLog)
Update table_name.column_name Update(Users.password)
Delete table_name Delete(Sessions)
Select (none) Select

Transactions:

Selector Fields Example
Transaction operation Transaction(BEGIN)
Savepoint operation.savepoint_name Savepoint(*.my_sp)

DDL (permanent):

Selector Fields Example
CreateTable table_name CreateTable(TempData)
DropTable table_name DropTable(OldRecords)
AlterTable database_name.table_name AlterTable(*.Users)
CreateIndex table_name.index_name CreateIndex(Users.idx_email)
DropIndex table_name.index_name DropIndex
CreateView view_name CreateView(ActiveUsers)
DropView view_name DropView
CreateTrigger table_name.trigger_name CreateTrigger(Users.*)
DropTrigger table_name.trigger_name DropTrigger

DDL (temporary):

Selector Fields Example
CreateTempTable table_name CreateTempTable
DropTempTable table_name DropTempTable
CreateTempIndex table_name.index_name CreateTempIndex
DropTempIndex table_name.index_name DropTempIndex
CreateTempView view_name CreateTempView
DropTempView view_name DropTempView
CreateTempTrigger table_name.trigger_name CreateTempTrigger
DropTempTrigger table_name.trigger_name DropTempTrigger

Other operations:

Selector Fields Example
Pragma pragma_name Pragma(journal_mode)
Function function_name Function(count)
Attach filename Attach
Detach database_name Detach
Reindex index_name Reindex
Analyze table_name Analyze(Users)
CreateVtable table_name.module_name CreateVtable(*.fts5)
DropVtable table_name.module_name DropVtable
Recursive (none) Recursive

Specificity and resolution

Each selector has a specificity equal to the number of fields pinned to concrete values (not *). When SQLite asks whether an operation is allowed:

  1. All matching rules are collected. Globs match anything; concrete values must match exactly.
  2. Rules are evaluated from the highest specificity to the lowest. The first level with at least one matching rule determines the outcome.
  3. If both allow and deny rules match at the same specificity, deny wins.
  4. If no rule matches at any level, the per-action default from the preset applies.

Example: read-only with a sensitive column denied```bash
mcp-server-sqlite --database ./app.db --deny Read(Users.ssn)


The `read-only` preset allows all reads. The `--deny Read(Users.ssn)` rule has specificity 2 (both table and column pinned), which beats the preset's blanket allow at specificity 0. Reading `Users.name` is fine. Reading `Users.ssn` is denied.

**Example: deny a table but allow one column**```bash
mcp-server-sqlite --database ./app.db \
  --deny Read(Secrets) \
  --allow Read(Secrets.id)

The deny on Read(Secrets) has specificity 1. The allow on Read(Secrets.id) has specificity 2. Reads on Secrets.id are allowed because specificity 2 beats specificity 1. All other columns in Secrets remain denied.

Example: deny everything, allow only specific functions```bash
mcp-server-sqlite --preset deny-everything \
--allow Read \
--allow Select \
--allow Transaction \
--allow Function(count) \
--allow Function(sum)


Starting from a deny-everything baseline, only reads and the `count()` and `sum()` SQL functions are permitted. All other functions (e.g. `load_extension`) remain denied.

## CLI reference```
Usage: mcp-server-sqlite [OPTIONS]

Options:
      --database <DATABASE>
          The SQLite database URI. Defaults to a shared in-memory database.
          Use a file URI for persistence (e.g. `file:./app.db`). Query
          parameters like `?mode=ro` and `?cache=shared` are supported.
          [default: file::memory:?cache=shared]

      --init-sql <INIT_SQL>
          Paths to SQL files executed once when creating a new database.
          Skipped entirely if the database file already exists. Use this
          to set up schemas and seed data on first run. May be specified
          multiple times.

  -p, --preset <PRESET>
          The baseline permission preset.
          [default: read-only]
          [possible values: deny-everything, read-only, read-write,
           full-ddl, allow-everything]

  -a, --allow <ALLOW>
          Allow a specific SQL operation. Accepts a selector in the form
          Action or Action(field1.field2) where * is a wildcard. More
          specific rules override less specific ones. May be specified
          multiple times.

  -d, --deny <DENY>
          Deny a specific SQL operation. Same selector syntax as --allow.
          When an allow and deny rule match at the same specificity level,
          deny wins. May be specified multiple times.

      --timeout-ms <TIMEOUT_MS>
          Maximum time in milliseconds that any single SQL operation is
          allowed to run before being interrupted. Omit for no timeout.

  -h, --help
          Print help (including more examples with --help)

  -V, --version
          Print version

Examples

Read-only analytics database

Expose a database for read-only analytics, denying access to PII columns:```bash
mcp-server-sqlite \
--database ./analytics.db \
--deny Read(.email) \
--deny Read(
.phone) \
--deny Read(*.ssn)


### Application backend with restricted writes

Allow reads and writes, but protect the audit log and prevent schema changes:```bash
mcp-server-sqlite \
  --database ./app.db \
  --preset read-write \
  --deny Delete(AuditLog) \
  --deny Update(AuditLog)

Locked-down server for untrusted agents

Start from deny-everything and allow only what is needed:```bash
mcp-server-sqlite \
--database ./data.db \
--preset deny-everything \
--allow Read(Products) \
--allow Read(Categories) \
--allow Select \
--allow Transaction \
--allow Function(count) \
--allow Function(sum) \
--allow Function(avg) \
--timeout-ms 5000


### Development server with full access

For local development where convenience matters more than safety:```bash
mcp-server-sqlite \
  --database ./dev.db \
  --preset allow-everything \
  --init-sql schema.sql \
  --init-sql seed.sql

Full-text search workflow

Set up a database with FTS5 for document search:```bash
mcp-server-sqlite \
--database ./docs.db \
--preset full-ddl \
--allow CreateVtable(*.fts5)


Then through the MCP tools:```
create_fts_index({ "table_name": "articles", "columns": ["title", "body"] })

search_fts({ "fts_table": "articles_fts", "query": "rust AND sqlite" })

Logging

The server logs to stderr using the tracing framework. Control the log level with the RUST_LOG environment variable:```bash

Default (info)

mcp-server-sqlite --database ./app.db

Verbose (includes tool inputs/outputs)

RUST_LOG=debug mcp-server-sqlite --database ./app.db

Quiet (errors only)

RUST_LOG=error mcp-server-sqlite --database ./app.db
```

Comparison with existing servers

Feature Official (Python) jparkerweb (JS) sqlite-explorer (Python) dbhub (TS) This server
Authorizer-based access control No No No No Yes
Column-level permissions No No No No Yes
Permission presets No No No Read-only toggle 5 presets + overrides
Query timeouts No No No Yes Yes
Full-text search (FTS5) No No No No Yes
Query plan explanation No No No No Yes
Database backup No No No No Yes
Schema introspection depth Tables + columns Tables + columns Tables + columns Tables + columns Tables, columns, indexes, foreign keys, views, triggers
SQL injection protection Vulnerable N/A Parameter binding N/A Authorizer rejects at prepare time
Connection pooling No No No No Yes (r2d2)
Init scripts No No No No Yes
Single binary, no runtime No (Python) No (Node.js) No (Python) No (Node.js) Yes (Rust)

License

Licensed under either of Apache License, Version 2.0 or MIT License at your option.

常见问题

8 问
答案由本站依据条目字段整理,不引用上游原文
mcp-server-sqlite 怎么安装?

在客户端按下面的安装命令接入:mcp-server-sqlite --database ./my-database.db --preset read-only。装完在客户端配置里引用同一个包或端点。

mcp-server-sqlite 怎么在 Claude Desktop、Claude、Zed 里配置?

它的传输方式是stdio · 本地进程,在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,配置才会生效。

mcp-server-sqlite 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

mcp-server-sqlite 需要 API Key 吗?

资料标注需要会话登录认证,使用前准备好对应凭据,并按最小权限配置。

mcp-server-sqlite 支持哪些客户端?

资料标注支持 Claude Desktop、Claude、Zed;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

mcp-server-sqlite 能提供哪些能力?

资料显示能力标签包括 Local Deployment、SQLite、MCP server、Rust、database access control、fine-grained permissions。具体工具清单以官方文档为准。

mcp-server-sqlite 需要什么运行环境?

运行时为 rust;属于本地进程,需要在本机装好运行环境。

mcp-server-sqlite 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为stdio · 本地进程。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 2026-04-05。