Grain logo

Grain

Query supported databases and inspect schemas from AI agents through Grain’s VS Code MCP integration.

Install Grain

Run the project’s own setup commands, in order.

Setup steps from the project

Grain installs with its own steps rather than a config we can generate, so these are copied as-is. Follow them in order and run the commands in a terminal. Source: grain.tools

  1. 1. Install
    curl -fsSL https://grain.tools/install.sh | sh
    

Overview

Grain MCP server connects AI agents to database profiles managed by its VS Code extension. Agents can run SQL and inspect schemas, while query activity appears in Grain’s results panel for review. Read-only safe mode is enabled by default, making Grain a fit for investigating data without granting agents unrestricted write access. It supports PostgreSQL, MySQL, SQL Server, SQLite, Snowflake, BigQuery, Trino/Presto, DuckDB, and Elasticsearch.

Use cases

  • Query production data from an AI coding client in read-only mode
  • Inspect database schemas while investigating an application
  • Analyze local CSV or Parquet files with DuckDB
  • Review agent-generated SQL in the VS Code results panel
  • Export complete query results for downstream analysis

Key features

  • MCP access to configured database connections
  • Read-only agent safe mode
  • Schema inspection and SQL execution
  • Support for nine database and query systems
  • Visible agent query results in VS Code
  • CSV, TSV, and JSON result export

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

13/13 checks healthy over the last 62d

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars3Stargazers on the source repository.
Last commit10d agoMost recent push to the default branch.
Directory activity1 viewsConfig copies, upvotes, and views on AllMCPs.

How Grain works

What Grain does

Grain combines a VS Code SQL workspace with MCP access for AI agents. It lets developers create and test database connection profiles, run SQL from .sql files, and view results in a sortable grid. When MCP is enabled, supported agents can use those same connections to query data and inspect database structure.

Supported systems include PostgreSQL, MySQL, SQL Server, SQLite, Snowflake, BigQuery, Trino/Presto, DuckDB, and Elasticsearch. Trino and Presto can reach Iceberg, Delta Lake, and Hive tables in the connected cluster. DuckDB can query local CSV and Parquet files.

How it works

Install the Grain extension in VS Code or an Open VSX-compatible editor, then create connection profiles from the Grain panel. Credentials are stored through VS Code Secret Storage and backed by the operating system keychain rather than a settings file. Grain connects directly from the editor to the selected database; it does not use a hosted Grain service.

Turning on grain.mcpEnabled makes the configured connections available to supported MCP clients. Agent queries are sent through Grain and appear in the extension’s results panel, so developers can review what ran. With grain.mcpSafeMode enabled, the default behavior permits read-oriented statements such as SELECT, SHOW, DESCRIBE, EXPLAIN, WITH, and metadata queries.

Setup and configuration

Install Grain from the VS Code Marketplace or Open VSX. To connect a database, open Grain: Manage Connections, add a profile, test it, and save it. A built-in DuckDB demo can query included CSV files without requiring an external database.

For agent access, enable grain.mcpEnabled in editor settings and follow the client-specific MCP setup for Claude Code, Cursor, or GitHub Copilot. Grain also supports remote development environments including WSL, dev containers, GitHub Codespaces, and Remote - SSH.

Telemetry can be disabled with grain.telemetry.enabled. The anonymous usage data excludes SQL, results, credentials, hostnames, and schema names.

Tools and capabilities

  • Run a complete SQL file, the statement under the cursor, or a query in a new tab.
  • Expose configured database connections to agents over MCP.
  • Run SQL and inspect schemas through agent-accessible tools.
  • Display query results with sorting, filtering, column resizing, and SQL type information.
  • Copy selected grid data as TSV.
  • Export complete query results as CSV, TSV, or JSON; exports rerun the query rather than using only the visible grid.
  • Keep slow queries from blocking the VS Code interface by running them in a background process.

Limitations and notes

The results grid displays the first 500 rows, while full exports can write every returned row. PostgreSQL and Trino/Presto drivers are bundled; other connectors load their drivers when first used and may require an additional installation identified by Grain.

Safe mode restricts agent operations by default and prevents agents from reading stored passwords or changing saved connections. Grain is closed-source, and its repository contains documentation, examples, and issue tracking rather than the extension’s source code.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Grain

Grain is an MCP server that connects AI agents to database connections managed in its VS Code extension. It provides tools for running SQL and inspecting schemas, with read-only access by default and query activity shown in Grain's results panel.

Install Grain from the VS Code Marketplace or Open VSX, then enable `grain.mcpEnabled` in editor settings. Create and test a connection through **Grain: Manage Connections**, and follow the MCP setup for your client.

Yes, Grain supports Cursor through MCP. Install the Grain extension, enable `grain.mcpEnabled`, and apply the Cursor-specific configuration described in Grain’s MCP documentation.

By default, agents are limited to read-oriented SQL through `grain.mcpSafeMode`. Allowed operations include `SELECT`, `SHOW`, `DESCRIBE`, `EXPLAIN`, `WITH`, and metadata queries; safe mode also prevents access to stored passwords and saved connection changes.

Grain supports PostgreSQL, MySQL, SQL Server, SQLite, Snowflake, BigQuery, Trino/Presto, DuckDB, and Elasticsearch. Trino and Presto can query Iceberg, Delta Lake, and Hive tables, while DuckDB can read local CSV and Parquet files.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewGrain AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/grain?style=directory)](https://allmcps.com/mcp/grain)
HTML Embed
<a href="https://allmcps.com/mcp/grain"><img src="https://allmcps.com/api/badge/grain?style=directory" alt="Grain on AllMCPs" /></a>