# Grain [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/pattrnlabs/grain  
**GitHub Stars:** 3  
**Views:** 1  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/grain

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

## Claude Desktop Quick Installation
No generated config for this server: it installs through its own setup steps.

The project's own setup steps (from https://grain.tools), copied verbatim. Follow them in order; they are not an mcpServers config.

1. Install:

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

## Documentation

## 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.

_Full upstream README: https://allmcps.com/mcp/grain/readme_

