
Research
/Security News
737 Chrome VPN Extensions Linked to Brand Impersonation and Browser Traffic Redirection
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.
sql-preview
Advanced tools
Standalone SQL Preview MCP database server for VS Code, Claude Desktop, Cursor, and other MCP clients.
A fast SQL workspace for VS Code and MCP-enabled AI agents.
Run SQL in VS Code, manage database profiles securely, inspect results in a high-performance grid, and expose governed database tools to Claude, Cursor, Copilot, and other Model Context Protocol clients.
SQL Preview is built for the workflow where humans and agents both need real database context:
.sql file, press Cmd+Enter or
Ctrl+Enter, and inspect results without leaving VS Code.SQL Preview ships connector metadata and setup forms for:
| Database | Connector |
|---|---|
| PostgreSQL | postgres |
| MySQL | mysql |
| SQLite | sqlite |
| DuckDB | duckdb |
| Trino / Presto | trino |
| Elasticsearch | elasticsearch |
| Snowflake | snowflake |
| BigQuery | bigquery |
| SQL Server | mssql |
Trino/Presto and PostgreSQL are bundled into the extension build. Native and cloud-provider connectors are lazy-loaded and may require their driver runtime in the active environment; SQL Preview reports guided missing-driver errors instead of failing silently.
.sql file and press Cmd+Enter on macOS or Ctrl+Enter on
Windows/Linux.Results open in the SQL Preview panel at the bottom of the editor. To force a new tab, run SQL Preview: Run Query in New Tab.
If you previously configured sqlPreview.host, sqlPreview.port,
sqlPreview.user, sqlPreview.catalog, sqlPreview.schema, or
sqlPreview.databasePath, open SQL Preview: Show Welcome Guide or
SQL Preview: Manage Connections. SQL Preview can import those settings into a
named connection profile and keep passwords in VS Code Secret Storage.
sqlPreview.mcpEnabled).
This is required and ships off — the daemon serves no MCP surface until you turn it on.{
"mcpServers": {
"sql-preview": {
"command": "npx",
"args": ["-y", "sql-preview", "--stdio"]
}
}
}
This bridges to the daemon the VS Code extension is already running, so agent queries and sessions show up in the results grid alongside anything you run from the editor. It works with every MCP client — including ones that cannot send custom HTTP headers, such as Claude Desktop — and it needs no credential in your config, because the bridge reads the daemon's access token itself.
Launching this bridge yourself is treated as asking for MCP, so it works even
when the editor setting is off. If you want to refuse MCP everywhere, including
this bridge, set "mcp": { "enabled": false } in ~/.sql-preview/daemon.json.
You can also open the Extensions view, search @mcp SQL Preview, and install the
server into your user profile or current workspace from the MCP gallery.
The daemon requires an authorization token on every non-public route, so an HTTP client must send it. Use this when your client supports custom headers (Cursor and VS Code do):
{
"mcpServers": {
"sql-preview": {
"url": "http://localhost:8414/mcp",
"headers": {
"Authorization": "Bearer YOUR_TOKEN"
}
}
}
}
The settings panel offers this snippet with the token already filled in — copy it
from there rather than assembling it by hand. The token also lives at
~/.sql-preview/auth-token; treat it like a password, since it authorizes access
to your connections and query results.
Upgrading from 0.6.x? Two things changed. A bare
{"url": "http://localhost:8414/mcp"}config no longer connects — switch to the stdio config above (recommended) or add theAuthorizationheader. AndsqlPreview.mcpEnablednow genuinely gates the surface: with it off,/mcpreturns 404, because the route is not registered rather than being registered and refused. Previously the setting only decided whether the daemon started eagerly, so HTTP MCP answered whether or not you had enabled it.
For CI jobs or any client that should not share the editor's daemon, the standalone server can carry its own connection profiles:
{
"mcpServers": {
"sql-preview": {
"command": "npx",
"args": ["-y", "sql-preview", "--stdio"],
"env": {
"SQL_PREVIEW_CONNECTIONS": "[{\"id\":\"analytics\",\"name\":\"Analytics\",\"type\":\"postgres\",\"host\":\"localhost\",\"port\":5432,\"user\":\"analyst\",\"database\":\"warehouse\",\"password\":\"YOUR_PASSWORD\"}]"
}
}
}
}
--stdio first checks whether a shared daemon is already listening on the
configured port (--port, then SQL_PREVIEW_MCP_PORT, SQL_PREVIEW_PORT, or
MCP_PORT; default 8414) — for example, one started by the VS Code extension — and, if so, bridges to it, so
the agent's queries and sessions still appear in the VS Code grid exactly like
the HTTP form above. If no shared daemon is reachable, it falls back to
starting its own embedded, isolated daemon exactly as before. Pass
--embedded or set SQL_PREVIEW_EMBEDDED=1 to force the isolated daemon
unconditionally, which is recommended for CI and other headless runs that
shouldn't depend on (or interfere with) a locally running instance.
The MCP initialize response explicitly reports SQL Preview isolation mode: shared or isolated in its standard instructions field. Agents can use that
protocol signal to tell whether their query sessions are visible in the user's
editor; stderr is not required for detection.
The VS Code extension currently resolves its daemon from SQL_PREVIEW_MCP_PORT
or port 8414, while the daemon itself also accepts SQL_PREVIEW_PORT,
MCP_PORT, and daemon.json. If those resolve differently, SQL Preview now
warns with both endpoints before starting another daemon. This is detection,
not automatic correction: align the settings or remove the custom port.
The MCP server exposes tools for:
| Tool | What it does |
|---|---|
run_query | Execute SQL and return typed JSON rows |
list_connectors | Return supported connector types and setup schemas |
list_connections | List configured connection profiles without secrets |
save_connection | Add or update a connection profile |
test_connection | Validate saved or unsaved connection settings |
list_schemas | List schemas for a connection |
list_tables | List tables within a schema |
describe_table | Return column names and types |
get_tab_info | Inspect daemon result tab state |
cancel_query | Cancel a running query |
close_tab | Close a daemon result tab |
Safe mode is on by default and restricts agents to read-only statements such as
SELECT, SHOW, DESCRIBE, EXPLAIN, WITH, and connector-specific metadata
queries.
See the full Claude Desktop setup guide and daemon URL reference for advanced configuration.
Most users should use SQL Preview: Manage Connections instead of editing settings JSON by hand.
| Setting | Default | Description |
|---|---|---|
sqlPreview.activeConnectionId | empty | Connection profile used for VS Code query execution |
sqlPreview.maxRowsToDisplay | 500 | Max rows shown in the grid; full export is still available |
sqlPreview.fontSize | 0 | Results grid font size in px; 0 inherits from the editor |
sqlPreview.rowHeight | normal | Grid density: compact, normal, or comfortable |
sqlPreview.tabNaming | file-sequential | Result tab naming strategy |
sqlPreview.alwaysRunInNewTab | false | Always open query results in a new tab |
sqlPreview.mcpEnabled | false | Serve the local MCP surface for agent access. Off means /mcp is not registered (404) |
sqlPreview.mcpSafeMode | true | Restrict MCP query execution to read-only statements |
sqlPreview.telemetry.enabled | false | Opt in to anonymous product telemetry |
sqlPreview.telemetryHost | https://us.i.posthog.com | Advanced PostHog-compatible telemetry endpoint |
Legacy connection settings such as sqlPreview.host, sqlPreview.port,
sqlPreview.user, sqlPreview.catalog, sqlPreview.schema, and
sqlPreview.databasePath remain available for migration and backward
compatibility.
Passwords entered through the VS Code connection manager are stored per
connection in VS Code Secret Storage, backed by the operating system keychain.
They are not written to settings.json or sent to the webview.
Use these commands when needed:
SQL Preview telemetry is enabled by default when VS Code telemetry is enabled,
and you can turn it off at any time with sqlPreview.telemetry.enabled. Events
are anonymous and allowlisted, and are used to improve setup, connector
reliability, query workflows, MCP adoption, and product quality.
When something crashes, SQL Preview sends a redacted stack trace so the
failure can be diagnosed without asking you for logs. Before anything leaves
your machine, file paths are reduced to their extension (<path>/*.sql) and
usernames are removed; paths that point at code keep only the part from
node_modules/ or the build directory onward. If redaction fails for any
reason, the report is dropped rather than sent.
SQL Preview never sends SQL text, query results, credentials, hostnames, database/schema/table/column names, workspace names, environment variables, process arguments, or raw driver error messages. A driver's error message can embed table names, column names, and literal data values, so crash reports carry the error's type and its stack — not the message text.
Session replay is separately feature-flagged and disabled by default. When it is enabled, it covers only the VS Code results webview and masks every rendered character and input; it does not record SQL, results, or other displayed content.
Use SQL Preview: Show Telemetry Status to inspect the effective telemetry state.
SQL Preview uses a local daemon model:
VS Code extension / MCP client / browser surface
|
v
SQL Preview daemon on localhost
|
v
Database connector
|
v
Your database
The daemon owns connection profiles, query execution, result tabs, MCP transports, and browser/VS Code projections. That lets editor sessions and agent sessions share the same local state while keeping credentials and execution on your machine.
See Changelog.md for the full release history.
Contributions are welcome, especially new connector support, reliability improvements, and documentation fixes. See CONTRIBUTING.md for setup instructions and development workflow.
Found a bug? Open an issue on GitHub.
MIT (c) 2026 Mehul Fadnavis
FAQs
Standalone SQL Preview MCP database server for VS Code, Claude Desktop, Cursor, and other MCP clients.
The npm package sql-preview receives a total of 830 weekly downloads. As such, sql-preview popularity was classified as not popular.
We found that sql-preview demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.