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.
概览
Grain SQL 让 AI 助手在你的数据库连接上执行只读 SQL 查询并查看表结构,查询结果会显示在 Grain 面板中。
- 可以做什么
- 在已保存的 Grain 连接上运行 SQL 查询,默认只读
- 查看数据库表结构与元数据
- 通过同一套连接配置查询关系型数据库、数据仓库、湖仓与搜索引擎
- 把助手的每次查询显示在 Grain 结果面板中,便于查看执行内容
- 适用场景
- 适合已在 VS Code 中使用 Grain、并希望 Claude Code、Cursor 或 Copilot 直接查询数据库、核对表结构或用真实查询结果回答问题的场景。
- 运行要求
- 以 npx 运行的本地 npm 包,并需安装 Grain VS Code 扩展且在设置中启用 MCP。无界面使用时通过环境变量 GRAIN_CONNECTIONS 提供连接配置;部分数据库驱动在首次使用时加载,可能需要另行安装。需要能访问你的数据库。
安装
在 SourceWeft 中
- 打开 控制台中的 Grain SQL,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
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.
Quick start
- Install Grain from the VS Code Marketplace or Open VSX (for Cursor, Windsurf, and VSCodium).
- Open a folder in VS Code. Grain adds its demo files there.
- Open the Grain panel and click Try the Demo.
- Put your cursor in any query in the file that opens and press
Ctrl+Enter(Cmd+Enteron 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.
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
Supported databases
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.mcpSafeModeon (the default), agents can only runSELECT,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
- Bug: file a bug report
- Feature idea: file a feature request
- New database: request a connector
- Question: check the FAQ and docs, then ask a question
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
License
Grain is closed-source. See LICENSE.
来源:README.md,提交 cb80075
工具
0版本历史
32- v0.10.49最新Nov 5, 2026
- v0.10.48Nov 4, 2026
- v0.10.46Nov 3, 2026
- v0.10.45Nov 1, 2026
- v0.10.44Oct 30, 2026
- v0.10.42Oct 29, 2026
- v0.10.37Oct 26, 2026
- v0.10.36Oct 22, 2026
- v0.10.35Oct 20, 2026
- v0.10.34Oct 16, 2026
- v0.10.33Oct 15, 2026
- v0.10.32Oct 14, 2026
- v0.10.31Oct 12, 2026
- v0.10.30Oct 9, 2026
- v0.10.29Oct 8, 2026
- v0.10.27Oct 7, 2026
- v0.10.26Oct 7, 2026
- v0.10.24Oct 6, 2026
- v0.10.23Oct 5, 2026
- v0.10.22Oct 5, 2026
- v0.10.21Oct 4, 2026
- v0.10.20Oct 3, 2026
- v0.10.19Oct 2, 2026
- v0.10.18Sep 30, 2026
- v0.10.17Sep 28, 2026
- v0.10.16Sep 28, 2026
- v0.10.15Sep 27, 2026
- v0.10.14Sep 26, 2026
- v0.10.13Sep 24, 2026
- v0.10.7Sep 23, 2026
- v0.10.4Sep 20, 2026
- v0.10.1Sep 16, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。