Grain SQL

io.github.pattrnlabs由 GitHub 帳號 pattrnlabs 發布v0.10.49更新於 Nov 5, 2026

Run SQL queries and inspect database schemas through safe, visible MCP tools.

已驗證STDIO僅桌面資料庫開發者工具

概覽

AI 產生的概覽

Grain SQL 讓 AI 助理在你的資料庫連線上執行唯讀 SQL 查詢並檢視資料表結構,查詢結果會顯示在 Grain 面板中。

可以做什麼
  • 在已儲存的 Grain 連線上執行 SQL 查詢,預設為唯讀
  • 檢視資料庫結構與中繼資料
  • 透過同一組連線設定查詢關聯式資料庫、資料倉儲、湖倉與搜尋引擎
  • 把助理的每次查詢顯示在 Grain 結果面板中,方便查看實際執行了什麼
適用情境
適合已在 VS Code 使用 Grain,並希望 Claude Code、Cursor 或 Copilot 直接查詢資料庫、確認資料表結構,或以真實查詢結果回答問題的情境。
執行需求
以 npx 執行的本機 npm 套件,並需安裝 Grain VS Code 擴充功能且在設定中啟用 MCP。無介面使用時透過環境變數 GRAIN_CONNECTIONS 提供連線設定;部分資料庫驅動程式會在首次使用時載入,可能需要另外安裝。需要能連線到你的資料庫。
安裝前請注意
GRAIN_CONNECTIONS 含有連線設定,可能包含資料庫憑證,應視為機密。安全模式預設開啟,僅允許唯讀語句;將 GRAIN_MCP_SAFE_MODE 設為 false 會允許可修改或刪除資料的 SQL。匿名遙測預設開啟,可在設定中關閉。Grain 為閉源軟體。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Grain SQL,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Grain

A fast SQL workspace for VS Code, and for the AI agents you work with.

Docs · Changelog · Report a bug · Ask a question

[VS Code Marketplace] [OpenVSX]

Run SQL from any .sql file with Ctrl+Enter and get the results in a sortable grid inside VS Code. Passwords stay in your OS keychain, and Grain has no hosted service.

[Run a query in Grain]

Quick start

  1. Install Grain from the VS Code Marketplace or Open VSX (for Cursor, Windsurf, and VSCodium).
  2. Open a folder in VS Code. Grain adds its demo files there.
  3. Open the Grain panel and click Try the Demo.
  4. Put your cursor in any query in the file that opens and press Ctrl+Enter (Cmd+Enter on macOS).

The demo reads two CSV files through Grain's built-in DuckDB connection, so there's nothing to set up. To query your own database, run Grain: Manage Connections, add a profile, and test it before you save.

[The Grain panel, annotated]

If Grain is useful to you, a star on this repo helps other developers find it.

Use Grain from an AI agent

Grain can serve your database connections to Claude Code, Cursor, and GitHub Copilot over MCP. Agents get read-only access by default, and every query an agent runs shows up in your Grain results panel, so you can see exactly what it did.

MCP is off until you turn on grain.mcpEnabled in settings. Setup steps for each client are in the MCP docs, and example prompts are in examples/agents/.

Features

FeatureWhat it does
Run from the editorCtrl+Enter runs the file; Run Query Under Cursor runs one statement; Run Query in New Tab keeps the previous result
Non-blocking queriesQueries run in a background process, so a slow query doesn't freeze VS Code
Connection managerCreate, test, and switch database profiles without editing JSON
Result gridSort, filter, and resize columns, see each column's SQL type, copy a selection as TSV
Full exportThe grid shows the first 500 rows; export re-runs the query and writes every row to CSV, TSV, or JSON
Agent access over MCPClaude Code, Cursor, and Copilot can query your connections; their results land in your panel
Remote setupsWorks over WSL, dev containers, GitHub Codespaces, and Remote - SSH

Supported databases

Relational databases[圖片]
PostgreSQL
[圖片]
MySQL
[圖片]
SQL Server
[圖片]
SQLite
Data warehouses[圖片]
Snowflake
[圖片]
BigQuery
Query engines & lakehouses[圖片]
Trino / Presto
[圖片]
DuckDB
Search[圖片]
Elasticsearch

Through Trino or Presto you can query your cluster's Iceberg, Delta Lake, and Hive tables. DuckDB queries local CSV and Parquet files directly.

PostgreSQL and Trino / Presto are bundled with the extension. The others load their driver on first use, and if a driver is missing, Grain tells you what to install.

Need another database? Request a connector. Requests with the most 👍 get built first.

Examples

Runnable queries for Postgres, MySQL, Elasticsearch, and DuckDB, plus agent prompts. Open any .sql file with Grain installed and press Ctrl+Enter.

Privacy

  • Your SQL, results, and passwords stay on your machine. Passwords are stored in VS Code Secret Storage, backed by your OS keychain, and never in a settings file.
  • Agents are read-only by default. With grain.mcpSafeMode on (the default), agents can only run SELECT, SHOW, DESCRIBE, EXPLAIN, WITH, and metadata queries. Agents can't read stored passwords or change saved connections.
  • Telemetry is anonymous. Grain sends usage data that never includes SQL, results, credentials, hostnames, or schema names. Turn it off with grain.telemetry.enabled.

FAQ

Is Grain open source?
No. Grain is closed-source. This repo holds the issue tracker, docs, and examples.

Which databases does it support?
The nine listed above. To ask for another one, request a connector.

Do my queries or passwords leave my machine?
No. There's no Grain server. Queries go straight from VS Code to your database, and passwords stay in your OS keychain. See Privacy for what the anonymous telemetry does and doesn't include.

How do I connect Claude Code or Cursor?
Turn on grain.mcpEnabled, then follow the steps for your client in the MCP docs.

Why does my database show a driver error?
Some connectors load their driver on first use. The error message names what to install. If it's still failing after that, file a bug report with the Output panel logs (View → Output → Grain).

Getting help

We don't have a fixed roadmap yet. What we build next depends a lot on what people ask for here, especially connector requests. See CONTRIBUTING.md for how to file a good issue.

Star History

[Star History Chart]

License

Grain is closed-source. See LICENSE.

來源:README.md,提交 cb80075

工具

0
SourceWeft 曾在隔離沙箱中以無憑證方式啟動該軟體包一次,以列出其工具,但未能完成:伺服器未能啟動。

版本歷史

32
  1. v0.10.49最新Nov 5, 2026
  2. v0.10.48Nov 4, 2026
  3. v0.10.46Nov 3, 2026
  4. v0.10.45Nov 1, 2026
  5. v0.10.44Oct 30, 2026
  6. v0.10.42Oct 29, 2026
  7. v0.10.37Oct 26, 2026
  8. v0.10.36Oct 22, 2026
  9. v0.10.35Oct 20, 2026
  10. v0.10.34Oct 16, 2026
  11. v0.10.33Oct 15, 2026
  12. v0.10.32Oct 14, 2026
  13. v0.10.31Oct 12, 2026
  14. v0.10.30Oct 9, 2026
  15. v0.10.29Oct 8, 2026
  16. v0.10.27Oct 7, 2026
  17. v0.10.26Oct 7, 2026
  18. v0.10.24Oct 6, 2026
  19. v0.10.23Oct 5, 2026
  20. v0.10.22Oct 5, 2026
  21. v0.10.21Oct 4, 2026
  22. v0.10.20Oct 3, 2026
  23. v0.10.19Oct 2, 2026
  24. v0.10.18Sep 30, 2026
  25. v0.10.17Sep 28, 2026
  26. v0.10.16Sep 28, 2026
  27. v0.10.15Sep 27, 2026
  28. v0.10.14Sep 26, 2026
  29. v0.10.13Sep 24, 2026
  30. v0.10.7Sep 23, 2026
  31. v0.10.4Sep 20, 2026
  32. v0.10.1Sep 16, 2026

評分

已滿足適用檢查項的 40%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

    請在儲存庫或註冊中心條目中宣告授權條款。