
Strut Stack Sql
io.github.rzlco666由 GitHub 帳號 rzlco666 發布v2.0.2更新於 Nov 6, 2026
Token-efficient MCP server for MySQL, PostgreSQL, SQLite, DuckDB, SQL Server, and ClickHouse
概覽
節省 token 的 MCP 伺服器,讓 AI 助理透過一個小型二進位程式查詢 PostgreSQL、MySQL、SQLite、DuckDB、ClickHouse 與 SQL Server。
- 可以做什麼
- 搜尋並檢視結構物件、資料表、索引、外鍵與關聯圖
- 執行單筆或批次 SQL 查詢,回傳欄位式結果並支援游標分頁
- 以 EXPLAIN 樹、分級發現與索引建議分析查詢效能
- 在明確開啟 DDL 後建立、修改、刪除資料表與欄位,或清空資料表
- 依主體授權、限制列數與位元組數,並對指定欄位做遮蔽
- 適用情境
- 適合讓助理探索關聯式資料庫、用 SQL 回答問題或診斷慢查詢,同時預設維持唯讀。也適合希望以單一靜態二進位檔取代 Node 或 Python 執行環境的團隊。
- 執行需求
- 以本機程序執行(各平台 MCPB 套件、Homebrew、Scoop、winget、Docker 或 cargo)。需透過 DATABASE_URL 環境變數或設定檔提供資料庫連線 URL;SQLite 與 DuckDB 可使用本機檔案或記憶體資料庫。需要能連線至目標資料庫的網路。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Strut Stack Sql,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
[Strut Stack SQL — Light strut. Extreme load.]
[Latest release] [CI] [License: MIT] [MCP Registry] [PostgreSQL · MySQL · SQLite · DuckDB · ClickHouse · SQL Server]
Light strut. Extreme load.
A token-efficient MCP server that lets AI agents query
PostgreSQL, MySQL, SQLite, DuckDB, ClickHouse, and SQL Server — safely, in one small Rust binary.
⭐ If this saves you tokens, star the repo — it is the single biggest thing that helps other people find it.
Install in one command — binary + AI setup included
This is the fastest path. It downloads the release binary (SHA256-verified), then configures every AI tool it finds on your machine — Claude Code, Cursor, VS Code, Claude Desktop, Codex, OpenCode, Windsurf, and Zed — so you do not hand-edit a single JSON file. Existing entries for other servers are kept, and every file it touches is backed up first.
With your database URL baked in (recommended):
Other useful forms:
Then restart your AI tool and ask it:
"List the tables in my database, then show me the 5 most recent orders."
You should see the tables listed, then the 5 most recent orders.
If you run the installer without a URL, configs reference ${env:DATABASE_URL} (or
forward it, for Codex) — export DATABASE_URL in the environment that launches your
editor before starting it. Full installer reference: docs/INSTALL.md.
One-click install
No terminal? These links open your editor with the server pre-filled. Replace the placeholder database URL with your own where prompted.
GitHub does not render cursor:// / vscode: links clickable. If a button above does
not open your editor, paste this into your browser's address bar instead:
Set up by hand (copy-paste)
Prefer the installer above. If you configure by hand, every block below is
read-only by default: 13 tools (3 core + 10 introspection), no writes, no DDL.
Replace DATABASE_URL with your real URL, or keep --url-env DATABASE_URL and
export it. Every block is also machine-checked in docs/CLIENTS.md.
Claude Code
Or in .mcp.json (project) — Claude Code expands ${VAR} here:
Check it with claude mcp get strut-stack-sql (or /mcp inside a session).
Cursor
Global ~/.cursor/mcp.json, or project .cursor/mcp.json. Cursor interpolates
${env:NAME}, so this works with an exported DATABASE_URL and no secret in the file:
VS Code
Workspace .vscode/mcp.json (or the user configuration via MCP: Open User
Configuration). Note: VS Code uses a top-level servers object, not mcpServers —
do not paste a Cursor block here unchanged:
Claude Desktop
claude_desktop_config.json (~/Library/Application Support/Claude/ on macOS,
~/.config/Claude/ on Linux):
Codex
~/.codex/config.toml (or project .codex/config.toml). Codex uses TOML, not JSON:
No URL in the file? Use env_vars = ["DATABASE_URL"] instead of env to forward
it from Codex's environment.
OpenCode
The CLI is the version-proof path (it writes the right shape for your OpenCode):
Or in opencode.json (global ~/.config/opencode/opencode.json, or project root).
command is one array and env vars go in environment, not env:
Verify with opencode mcp list. On OpenCode v2, if the server does not appear,
nest it under mcp.servers instead of directly under mcp.
Windsurf
~/.config/devin/mcp_config.json (current builds; older builds read
~/.codeium/windsurf/mcp_config.json — use whichever Open MCP config file in
Cascade opens):
Press refresh in Cascade after editing.
Zed
~/.config/zed/settings.json (merged under context_servers, everything else kept):
Any other MCP client
This is the whole contract — stdio, one binary, one env var:
Try it
Once your AI tool shows the server as connected, these prompts exercise the whole surface. Start read-only; writes and DDL stay off until you explicitly enable them (see Tools).
What the agent sees: execute_sql returns columnar JSON — column names once, compact meta:
Smoke-test the binary itself (no database needed) — a JSON initialize response
means the server speaks MCP:
Connect your database
One URL, one flag. Credentials belong in the environment (or .env discovery in
your project), never in a pasted config — prefer --url-env DATABASE_URL.
Multiple databases, per-principal grants, row/byte/timeout ceilings, and redaction
live in one TOML file — see strut-stack-sql.example.toml:
Full CLI / env / TOML reference: docs/CONFIGURATION.md. Per-engine notes: Postgres · MySQL · SQLite · DuckDB · SQL Server.
Why
Most SQL MCP servers make agents pay three taxes:
- Token tax — every tool schema and every row-as-object result burns context.
- Safety tax — raw SQL passthrough means one hallucinated
DROP TABLEis a production incident. - Footprint tax — a Node/Python runtime just to run
SELECT.
Strut Stack SQL does not charge them:
- 3 tools by default — the
liteprofile. The other 17 are opt-in: 10 introspection tools with--full-tools, and 7 DDL tools only when--full-tools --allow-ddlis set. A fresh install that shows three tools is working as designed. - Columnar results —
{cols, rows, meta}sends column names once, not once per row. - Every statement passes one AST guard — parsed with
sqlparser, classified recursively (including CTE bodies), checked against a tier, LIMIT-clamped, and rejected before a pool connection is checked out. - One static binary, six engines, behind a stable driver contract.
- Measured, not claimed — idle RSS under 8 MB,
tools/listat 2,643 bytes in lite mode (625 tokenso200k_base; 10,853 bytes / 2,549 tokens in full mode), cold start toinitializeat 2.52 ms p95 over stdio. Token numbers are v2.0.1 (2026-11-05); runtime numbers are v2.0.0 (2026-11-02). Full numbers and their limits: Benchmarks.
Tools — exactly 20
search_objects— ranked progressive schema discovery (exact > prefix > substring > comment match).execute_sql— single statement, bound parameters, or a governed concurrent batch; columnar / rows / auto output; cursor pagination for large results.analyze_query_performance— normalized EXPLAIN tree, tiered findings, index advice (advice text only; never executed).get_relationship_graph/suggest_joins/get_schema_context— FK graph, shortest join paths, token-budgeted schema digest.- DDL aliases require
"confirm": truefor destructive actions.
Profiles are presets over the same flags — no second authorization system:
list_tools and invocation use the same authorization function, so a tool hidden from the list is
also rejected when called directly. Full schemas and error contract: docs/TOOLS.md.
Safety — read-only by default, fail-closed everywhere else
- AST guard before pool checkout — one statement per string; unknown statement types are denied, not guessed.
- Recursive classification — writes hidden in CTEs (
WITH … DELETE … RETURNING … SELECT …),SELECT … INTO,INTO OUTFILE/DUMPFILE, row-locking clauses, and dangerous functions (pg_read_file,LOAD_FILE,pg_sleep, …) are never counted as reads. - Per-principal grants —
read < writes < ddl < adminper principal × source, with optional row/byte/timeout ceilings. The process flags (--allow-writes,--allow-ddl) are a ceiling no grant can exceed. - Admin gate —
GRANT/REVOKEuse the separateAdmintier and additionally require--allow-grants. - Column redaction, not denial —
--deny-columns password_hash,totp_secretreplaces matching values with"[redacted]": exact, case-insensitive column-name match, column names stay visible. An alias (SELECT password AS p) evades it, so treat it as a seat-belt, not an access-control boundary — use a read-only database user and views that never select the secret. DuckDB's guard additionally blocksread_csv,read_text,ATTACH,INSTALL, andLOADso an agent cannot read files outside the allowlist. - Dry runs and explicit consent — DDL accepts
dry_run: true(parse, classify, and report without executing), destructive aliases requireconfirm: true, and theadminprofile adds single-use approvals (approval_id/ MCP elicitation) on top. - Per-database allowlist (opt-in) —
--allow-databases app,analyticsdenies cross-database table qualifiers, hides other databases fromlist_schemas, and rejectsschema: "*"; unqualified names still resolve on the connected database, so pair it with a database-scoped credential (limits). - HTTP auth —
STRUT_STACK_SQL_HTTP_TOKENSentries arename:secret:mode[:source…]; secrets may be stored assha256:<64 hex>and are compared in constant time. OAuth 2.1 resource-server mode validates RS256 JWTs against the issuer's JWKS and fails closed if discovery fails. A non-loopback HTTP bind with no auth fails startup unless--allow-unauthenticated-httpis passed explicitly.
Remote HTTP mode:
Full model: docs/SECURITY.md. Safe probes: /livez never touches a
database; /readyz uses cached pool status and never returns raw database errors.
Security boundary and limitations
Defense in depth, not a sandbox. The controls in the Safety section above are real, but none of them replaces least-privilege database accounts, network restrictions, and review of SQL privileges.
- The guard parses SQL; it does not understand intent. Statements are parsed with
sqlparserinto an AST and classified recursively (including CTE bodies); anything the parser cannot represent is rejected, not guessed. That is a policy check on the statement's shape — not a proof that the query is safe to run against your data. - Database privileges remain decisive. Run the server with a dedicated, least-privilege database account — never an administrative one — and isolate demonstration environments. A read-only database user and views that never select the secret are the real boundary;
--deny-columnsis a seat-belt, not a wall (an alias evades the name match). - Treat credentials as secrets. Never commit
.envfiles, real token hashes, raw tokens, or logs containing sensitive SQL. - Transport needs deployment security. Bind locally for development. The HTTP transport must not be exposed publicly without a properly secured TLS / reverse-proxy and network policy — a non-loopback bind without auth fails startup unless
--allow-unauthenticated-httpis passed explicitly. - There is no persistent audit log yet. Tool calls and SQL text can appear in logs — control log access, rotation, retention, and redaction according to your environment. A JSONL audit log with agent identity is on the roadmap, not in this release.
- This is not a security certification. Review and test it before any production deployment. Data returned through tools must be treated as untrusted content, not as instructions to the agent.
What exists today, what is still on the roadmap, and how to report a vulnerability (privately): SECURITY.md. The full threat model lives in docs/SECURITY.md.
More ways to install
The installer above is recommended. Everything below installs the same binary; full matrix and release asset names: docs/INSTALL.md.
MCPB bundles for every platform are attached to each
GitHub Release and described by
server.json for the MCP Registry.
Open source
The whole stack is MIT licensed: one static Rust binary for six engines
(PostgreSQL, MySQL, SQLite, DuckDB, ClickHouse, SQL Server), with the guard, formatter, tools,
server, and drivers as separate crates. Choose a surface with --profile lite|standard|full|admin
instead of maintaining four builds — profiles are presets over the same flags and grants, not a
second authorization system (docs/PROFILES.md).
- Security model and threat model: docs/SECURITY.md.
- Install channels: one-line installer, Homebrew, Scoop, winget, Docker,
cargo install --path ., and per-platform MCPB bundles (docs/INSTALL.md). - Contributions: docs/CONTRIBUTING.md.
Architecture
Thirteen crates plus a thin binary. The core, guard, format, tools, and server crates never import a
database library; only a driver crate does. The driver boundary is one trait
(EngineDriver in crates/strut-sql-driver-api): drivers own connections, execution, and
catalogs, while dialect selection, capability checks, authorization, and tool SQL generation stay
shared. Full crate map: docs/ARCHITECTURE.md.
Benchmarks (measured)
Raw artifact: scripts/benchmark/results/2.0.0.json —
2026-11-02, WSL2 Ubuntu 24.04, Intel i5-13420H (6 vCPU), 5.79 GB RAM, SQLite temp database,
n=120 iterations after 20 warmups, 20 cold-start runs. Reproduce with
./scripts/benchmark/run-bench.sh. The table below is the v2.0.0 runtime benchmark — for the
v2.0.1 token numbers, see Token benchmark below.
Two measurement classes are kept apart instead of blended:
- In-process — engine work on a local SQLite file.
tools/listis 3,039 bytes (v2.0.0) for the core surface, and a 100 × 8 result is 7,526 bytes of columnar text before truncation (column names once, not once per row). These numbers describe payload shape, not network cost. - Roundtrip over stdio/HTTP — process spawn →
initialize, plus one request/response perexecute_sql. The 0.80 ms stdio p50 includes local SQLite execution and JSON-RPC framing; the harness cannot split tool overhead from database time on an in-process file.
The two HTTP misses are real and are not rounded away: cold start includes listener readiness and
the session handshake, and each HTTP execute_sql is a fresh request, so transport framing
dominates. PostgreSQL and MySQL were not measured (no live server on the reference machine) and
are recorded as not_run, together with the competitor comparison. Methodology and limits:
docs/BENCHMARKS.md.
Token benchmark (v2.0.1)
Measured 2026-11-05 (run 1) and independently re-run 2026-11-06 (run 2, byte-identical payloads)
against the v2.0.1 release binary (strut-stack-sql 2.0.1, commit 805d18f, MCP protocol
2025-06-18, tiktoken 0.14.0). Tokens count only what the model sees — per-tool name +
description + inputSchema (method: octomind.run, 2026-10-02). These are schema tokens, not
session tokens and not a Claude bill. Full method, per-tool tables, and reproduction steps:
docs/TOKEN-BENCHMARK.md.
Raw tools/list payloads: lite 2,643 B, standard 5,679 B, full 10,853 B. The old headline figure
of 3,039 bytes was the v2.0.0 payload; it does not apply to v2.0.1. Token budgets (lite ≤ 750,
full ≤ 3,000 o200k_base) are adopted design budgets; the CI job enforcing them is follow-up
work, not yet a gate.
Protocol and clients
- Pinned MCP specification: 2025-06-18. Version negotiation,
tools/list,tools/call, error shapes, Streamable HTTP sessions, auth metadata, and DNS-rebindingOriginchecks are exercised by a runnable gate. Older requested versions are answered with 2025-06-18; JSON-RPC batches are rejected. - Eight-client setup, six-client checked matrix: the installer and the copy-paste blocks above cover Claude Code, Cursor, VS Code, Claude Desktop, Codex, OpenCode, Windsurf, and Zed. The six-client matrix in docs/CLIENTS.md (Cursor, Claude Code, VS Code, Codex, Windsurf, OpenCode) has every config block parsed and the minimal stdio command smoke-run in CI.
- Historical 2.0.0 conformance results: docs/CONFORMANCE.md.
Troubleshooting
Documentation
Contributing
Issues and PRs welcome — start with docs/CONTRIBUTING.md. Include a minimal SQL repro for guard issues (never production credentials).
License
Built for agents that should ask the database, not guess it.
⭐ Star it if it earns its place in your stack — and tell one person who still pastes SQL into chat.
來源:README.md,提交 49181b6
工具
0版本歷史
4- v2.0.2最新Nov 6, 2026
- v2.0.1Nov 5, 2026
- v2.0.0Nov 5, 2026
- v1.0.4Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分