
Locksmith
io.github.cxk280由 GitHub 帳號 cxk280 發布v0.1.1更新於 Oct 24, 2026
Lints PostgreSQL migrations for dangerous locking operations and suggests safe rewrites.
概覽
Locksmith 檢查 PostgreSQL 遷移中的危險鎖定操作,回傳 PASS/REVIEW/BLOCK 結論、問題說明與安全改寫建議。
- 可以做什麼
- 分析 PostgreSQL 遷移,給出結論、逐條語句的問題說明與安全改寫建議,可選擇以大表假設處理。解釋某種 Postgres 鎖定模式會阻擋什麼、由哪些操作取得。讀取表層級鎖定相容性矩陣與完整規則目錄等參考資源。使用 review-migration 提示將遷移風險整理成 PR 留言。
- 適用情境
- 適合在助理審查或撰寫 PostgreSQL 結構遷移時使用,在部署前對鎖定風險做確定、可重複的檢查,而不依賴模型自身對鎖定語意的推理。
- 執行需求
- 透過 npx 從 npm 套件 locksmith-mcp 以 stdio 在本機執行,需要 Node.js。不需帳號、API 金鑰、環境變數或網路存取。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Locksmith,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Locksmith 🔒
An MCP server that catches dangerous SQL migrations before they lock your database.
Most migrations look harmless and then take down production: a plain CREATE INDEX
blocks every write for the length of the build; ALTER COLUMN ... TYPE rewrites the
whole table under ACCESS EXCLUSIVE; SET NOT NULL scans every row. Which operations
are safe — and the rewrite that makes the dangerous ones safe — is knowledge that
lives in senior engineers' heads.
Locksmith encodes that knowledge as a tool an LLM agent (or a human) can call. Give it a PostgreSQL migration; it returns a PASS / REVIEW / BLOCK verdict, a finding for each risky statement (which lock it takes, why that's dangerous), and a concrete safe rewrite.
Why an MCP server?
An agent can often reason about lock semantics — but not reproducibly, and not in a
way you can test, audit, or trust to gate a deploy unsupervised. The same prompt may
approve a table-rewriting ALTER one run and flag it the next, or miss it entirely in a
long migration. Locksmith turns that probabilistic capability into a deterministic,
tested tool: the lock semantics were verified once (against the PostgreSQL docs and the
parser's real behavior, with a test suite pinning each rule) and now run identically every
time, returning the same verdict plus a paste-ready fix — so "review this migration" stops
being a guess.
Capabilities
Tools
analyze_migration(sql, assumeLargeTables?)→ verdict + findings + safe rewrites (both human-readable Markdown and validated structured output).explain_lock(query)→ what a given Postgres lock mode blocks and what takes it.
Resources
locksmith://lock-matrix— the PostgreSQL table-level lock compatibility matrix.locksmith://rules— the full rule catalog (id, severity, rationale) as JSON.
Prompts
review-migration— analyze a migration and summarize the risk as a PR comment.
Rule catalog
Suppressing a rule
Acknowledge a deliberate risk inline, eslint-style:
A bare -- locksmith:disable suppresses all rules for the next statement.
Install & run
No clone or build required — run it straight from npm:
Use with Claude Code
Or add to any MCP client config (Claude Desktop, etc.):
Run from source instead
Try it with the MCP Inspector
Then call analyze_migration with the contents of examples/dangerous.sql.
Development
Design notes
- Deterministic. No clock, randomness, or network — same SQL in, same verdict out. That's what makes it testable and safe to drop into CI.
- Hybrid parsing. Statements are parsed to an AST (
pgsql-ast-parser) when the parser supports them; rules fall back to normalized text for Postgres clauses the parser doesn't model (NOT VALID,CONCURRENTLY). An unparseable statement degrades to a "review manually" note — the linter never fails closed on input it doesn't understand. - Composable rules. Each rule is a pure function with its own metadata in its own file; adding one is a one-file change plus a line in the registry.
- Advisory, not a prover. Locksmith complements review;
assumeLargeTablesdefaults totrueso it errs toward flagging.
Roadmap
- Remote (Streamable HTTP) transport for hosted deployments.
- Additional dialects (MySQL, SQLite).
- Optional live DB introspection to suppress findings on known-small tables.
- A GitHub Action wrapping the same engine to gate PRs.
License
MIT
來源:README.md,提交 8707022
工具
0版本歷史
1- v0.1.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分