Basalt

io.github.joshiii-xyz由 GitHub 账号 joshiii-xyz 发布v0.1.6更新于 Oct 24, 2026

Local SQL workspaces with bounded, recoverable writes for coding agents.

概览

AI 生成的概览

Basalt 是一个本地嵌入式 SQL 数据库和 stdio MCP 服务器,为编码代理提供有边界、可恢复的 SQL 工作区。

可以做什么
Basalt 以本地 stdio MCP 服务器形式运行,底层是用 Rust 编写的嵌入式 SQL 数据库。在工作区模式下,它提供 workspace_import、workspace_inspect、workspace_preview、workspace_plan、workspace_apply、workspace_history、workspace_diff、workspace_undo 和 workspace_export 等工具,以及有边界的 query、list_tables、describe_table 工具和位于 basalt://schema 的架构资源。写入遵循明确的预览/应用流程:可以先检查拟议的变更,按精确的 plan ID 应用,然后进行差异比较或撤销。也提供直接数据库模式,默认只读。
适用场景
当代理或脚本需要一个一次性的本地关系型区域来处理 CSV、JSON、日志、问题导出或测试数据,并且有边界、可恢复的写入比替换现有数据库更重要时,适合使用。它不是 SQLite 兼容替代品,也不是托管数据库;需要兼容性或分析性能时应使用 SQLite 或 DuckDB。
运行要求
作为本地进程通过 stdio 运行。通过 Cargo 安装 basalt-db 包需要 Rust 1.88 或更高版本;带标签的发布版还提供适用于 Linux、macOS 和 Windows 的预构建二进制文件和带校验和的安装程序。MCP 主机必须配置绝对工作区路径,直接模式则配置数据库路径。未声明任何账户、API 密钥、环境变量或请求头。
安装前请注意
写入受到限制:工作区导入、应用和撤销需要批准,只有在主机具有明确的操作员批准策略时才应使用 --allow-writes 标志。工作区或持久数据库路径一次只能由一个进程占用,因此在使用 CLI 访问该工作区之前,请先停止工作区 MCP 服务器。直接模式默认只读;execute 和 checkpoint 需要同样的标志。CLI SQL 操作限制为 16 MiB。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Basalt,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[Basalt logo]

Basalt

A CLI-first local SQL workspace for structured data and coding agents.

[CI] [MIT license]

Basalt is an embedded SQL database and command-line application built from scratch in Rust. It provides a small library API, an interactive shell, durable storage, snapshot-isolated transactions, crash recovery, portable structured-data workspaces, and a stdio MCP server for local AI agents. It is not a SQLite-compatible replacement or a hosted database.

Highlights

  • SQL lexer and recursive-descent parser with expressions, joins, grouping, aggregates, aliases, and transaction statements.
  • Atomic statement execution with primary-key, UNIQUE, and user-created indexes.
  • Snapshot-isolated transactions with optimistic conflict detection.
  • Checksummed page snapshots and a write-ahead log that recovers committed state after a process crash.
  • Simple query planning with table scans, equality indexes, and range indexes.
  • Interactive and scriptable CLI output in table, CSV, and JSON-lines formats.
  • Portable workspaces with versioned metadata and atomic CSV, JSON/JSONL, and SQL dump import/export.
  • Installable MCP server with typed SQL tools, bounded workspace imports and exports, engine-bounded SQL, schema resources, and recoverable agent changes.

Installation

Rust 1.88 or newer is required for a Cargo install.

bash
cargo install basalt-db --locked

The published package is named basalt-db; the installed command remains basalt. To install the current checkout instead, use cargo install --path . --locked.

Tagged releases include checksummed installers and prebuilt binaries for Linux, macOS, and Windows. See GitHub Releases for the current no-toolchain install. The latest tagged release is verified from its published installer and its checksums:

bash
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/yoshiii-xyz/basalt/releases/latest/download/basalt-db-installer.sh | sh

To run directly from a checkout:

bash
cargo run --release -- app.basalt

Quick start

Open a database and run SQL interactively:

console
$ basalt app.basaltbasalt> CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT NOT NULL);basalt> INSERT INTO users VALUES (1, 'Ada');basalt> SELECT * FROM users;id | name---+-----1  | Ada1 row(s)

For a one-shot command:

bash
basalt --json --command "SELECT * FROM users ORDER BY id;" app.basalt

Use Database::in_memory() for an ephemeral database. Durable writes are appended to the WAL immediately; call checkpoint() to fold the current state into the snapshot and clear old WAL frames. A durable path is owned by one process at a time; cloned Database handles share that owner safely across threads, while a second process receives an "already open" error.

Workspaces

Use a workspace when an agent or script needs a disposable, local relational area for CSV, JSON, logs, issue exports, or fixtures:

bash
basalt init .basalt-workspacebasalt workspace import --table issues .basalt-workspace issues.csvbasalt workspace inspect --json .basalt-workspacebasalt workspace query --json .basalt-workspace "SELECT * FROM issues ORDER BY id"basalt workspace export .basalt-workspace issues issues.jsonl

Imports are atomic, recoverable, and return a durable change_id; exports are deterministic. Add --json to workspace import/export commands when an agent or script needs a machine-readable operation report; raw exports to - remain clean data streams. Later writes can be previewed, applied by exact plan ID, inspected in history, diffed with schema and row-change counts, and undone when they are the latest change. A workspace is owned by one Basalt process while open, so stop a workspace MCP server before using that workspace from the CLI or by opening its data.basalt file directly. See docs/workspaces.md for the format and boundaries.

The reason to use Basalt for agent-owned data is the write boundary: inspect a proposed change before it is durable, apply only the exact reviewed plan, then diff or undo the latest change if needed.

bash
basalt workspace preview --json .basalt-workspace \  "UPDATE issues SET status = 'closed' WHERE id = 42"# Review the returned plan_id, then:basalt workspace apply --json .basalt-workspace PLAN_ID# Review the returned change_id, then:basalt workspace diff --json .basalt-workspace CHANGE_IDbasalt workspace undo --json .basalt-workspace CHANGE_ID

Use SQLite or DuckDB when you need their compatibility or analytical performance. Basalt is for local structured-data work where a bounded, recoverable write matters more than replacing an existing database.

If that describes your workflow, use the early-user validation guide with a disposable, non-sensitive input and record the concrete task and blocker. Basalt does not claim adoption until developers complete this workflow against the tools they already use.

MCP server

Basalt can run as a local Model Context Protocol server over stdio. Install the binary from this checkout:

bash
cargo install --path . --locked

Then configure an MCP host with an absolute workspace path. Workspace mode is the recommended agent integration: it scopes data access and requires an explicit preview/apply lifecycle for writes.

json
{  "mcpServers": {    "basalt": {      "command": "basalt",      "args": [        "mcp",        "--workspace",        "/absolute/path/to/project-data",        "--init-workspace"      ]    }  }}

--init-workspace creates the configured workspace only when its path does not exist; it never replaces an existing directory or manifest. Omit it when the workspace must be provisioned separately. Add "--allow-writes" only when the host has an explicit operator approval policy for applying workspace plans and undoing changes. Direct database mode is still available with "args": ["mcp", "/absolute/path/to/app.basalt"], but it is read-only by default; execute and checkpoint require the same flag. Use "args": ["mcp", ":memory:"] for an ephemeral direct-mode session. The installed binary is preferred for host configuration; running from a checkout is also possible with cargo run --quiet -- mcp --workspace /absolute/path/to/project-data.

When a modern MCP host advertises form elicitation, Basalt returns an input_required approval request before each workspace import, apply, or undo and executes only after the host retries with an explicit approval. Legacy initialized hosts receive elicitation/create; hosts that do not advertise elicitation use the explicit --allow-writes startup policy.

The release metadata carries the visible Cargo ownership marker used by the MCP Registry listing:

Workspace mode exposes workspace_import, workspace_inspect, workspace_preview, workspace_plan, workspace_apply, workspace_history, workspace_diff, workspace_undo, and workspace_export, alongside bounded query, list_tables, and describe_table tools. It also exposes the current schema at basalt://schema. See docs/mcp.md for the complete tool contract, configuration details, approval boundary, and troubleshooting.

CLI

Execute a SQL file:

bash
basalt --file schema-and-seed.sql app.basalt

Run commands in order on one connection, including a transaction spanning multiple commands:

bash
basalt --command "BEGIN;" --command "INSERT INTO users VALUES (2, 'Grace');" --command "COMMIT;" app.basalt

Use --file - to read SQL from stdin. Repeat --command and --file as needed; they execute in the order they appear. Table output is human-readable, CSV emits query rows, and --json emits one JSON object per statement. Run .help inside the shell for .tables, .schema, .mode, .headers, .checkpoint, .show, and .clear. Each CLI SQL action and the pending interactive buffer is limited to 16 MiB; larger scripts should be split into smaller actions or use the bounded workspace import formats.

Library usage

rust
use basalt::{Database, db::StatementResult};
let database = Database::open("example.basalt")?;database.execute_sql(    "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT NOT NULL); INSERT INTO users VALUES (1, 'Ada');",)?;let result = database.execute_sql("SELECT * FROM users WHERE id = 1")?;assert!(matches!(result[0], StatementResult::Select { .. }));database.checkpoint()?;# Ok::<(), basalt::db::DbError>(())

Use database.connect() when SQL transaction statements need to span multiple calls.

Project layout

PathPurpose
src/sql/Lexer, parser, AST, and SQL dialect
src/engine.rsStatement execution and query semantics
src/planner.rsAccess-path selection
src/db.rs, src/database.rsTables, constraints, transactions, and API
src/storage.rs, src/wal.rsSnapshots, checksums, and recovery
src/cli.rsInteractive and scripted command-line frontend
src/workspace.rsLocal workspace lifecycle and data interchange
src/mcp.rsStdio MCP server, agent tools, and schema resource
server.jsonMCP Registry release metadata
docs/sql.mdSupported SQL dialect and transaction semantics
docs/benchmark-results.mdRecorded workflow benchmark snapshot
docs/compatibility.mdFile-format boundary and differential-test policy
docs/production-readiness.mdTechnical release contract, limits, and evidence
docs/early-user-validation.mdFive-minute switching test and feedback template
docs/fuzzing.mdParser and persistence fuzzing instructions
docs/mcp.mdMCP installation, configuration, and tool contract
docs/workspaces.mdWorkspace layout and import/export contract
tests/Integration and crash-recovery coverage
benches/In-process engine throughput benchmark
scripts/benchmark_workspace.pyReproducible workflow comparison harness
scripts/differential_sql.pySupported-subset SQLite differential checks
scripts/mcp-smoke.pyInstalled-binary writable MCP smoke test
scripts/verify-release-artifacts.pyRelease archive checksum and contents check
scripts/verify-registry-metadata.pyMCP Registry package/version consistency check
scripts/release-check.shPackaged-crate and release preflight
scripts/smoke-test.shInstalled-binary CLI and read-only MCP smoke test
fuzz/Optional libFuzzer parser and snapshot targets

Development

bash
cargo fmt --all -- --checkcargo check --all-targets --lockedcargo clippy --all-targets --all-features --locked -- -D warningscargo test --all-targets --lockedRUSTDOCFLAGS="-D warnings" cargo doc --no-deps --lockedcargo bench --bench throughputcargo package --lockedcargo build --release --lockedcargo auditpython3 scripts/benchmark_workspace.py --basalt target/release/basalt

For the complete Unix release preflight, use:

bash
bash scripts/release-check.sh

It installs the exact packaged crate into a temporary prefix and runs the installed-binary smoke journey. It also runs cargo audit and dist plan when those tools are available.

See CONTRIBUTING.md for contribution guidelines and CHANGELOG.md for project history. The release checklist is in docs/release.md, including the generated release workflow and clean-binary smoke test.

License

MIT. See LICENSE.

来源:README.md,提交 f03e8d3

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.6最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分