Grain SQL

io.github.pattrnlabsPublished by GitHub account pattrnlabsv0.10.49Updated Nov 5, 2026

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

VerifiedSTDIODesktop onlyDatabasesDeveloper Tools

Overview

AI-generated overview

Grain SQL lets an AI assistant run read-only SQL queries and inspect schemas across your database connections, with results shown in the Grain panel.

What you can do
  • Run SQL queries against your saved Grain connections, read-only by default
  • Inspect database schemas and metadata
  • Query relational databases, warehouses, lakehouses and search engines through the same profiles
  • Show every agent query in the Grain results panel so you can see what ran
When to use it
Useful when you already use Grain in VS Code and want Claude Code, Cursor or Copilot to explore your databases, check schemas or answer questions with real query results instead of guessing.
Requirements
Local npm package run with npx, plus the Grain VS Code extension with MCP enabled in settings. Connection profiles are supplied through the GRAIN_CONNECTIONS environment variable for headless use; some database drivers load on first use and may need installing. Network access to your databases.
Before you install
GRAIN_CONNECTIONS holds connection profiles, which may include database credentials, so treat it as a secret. Safe mode is on by default and limits agents to read-only statements; setting GRAIN_MCP_SAFE_MODE to false allows mutating SQL that can change or delete data. Anonymous telemetry is on unless disabled in settings. Grain is closed-source.

Installation

In SourceWeft

  1. Open Grain SQL in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

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[Image]
PostgreSQL
[Image]
MySQL
[Image]
SQL Server
[Image]
SQLite
Data warehouses[Image]
Snowflake
[Image]
BigQuery
Query engines & lakehouses[Image]
Trino / Presto
[Image]
DuckDB
Search[Image]
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.

Source: README.md at commit cb80075

Tools

0
SourceWeft started this package once in an isolated sandbox, without credentials, to list its tools. That failed: the server did not start.

Version history

32
  1. v0.10.49LatestNov 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

Score

40% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts

    Declare a license in the repository or the registry entry.