PostgreSQL + Redis + ClickHouse + SQLite + Kafka + SQL Server in one extension. Free. Open source. No paywalls.
Why Viewstor?
Database extensions for VS Code are either locked to one database, or freemium with crippled free tiers (limited connections, no export, closed source). Switching between DBeaver and VS Code breaks flow. DataGrip costs money.
Viewstor is a free, open-source extension that covers PostgreSQL, Redis, ClickHouse, SQLite, Apache Kafka, and SQL Server in a single tool — with features you won't find elsewhere:
Passwords are excluded for security — you'll enter them on first connect. See the Wiki for detailed migration guides.
Features
Safe Mode
Production databases deserve guardrails. Safe mode runs EXPLAIN before every SELECT and catches full table scans:
Mode
Behavior
Block
Blocks queries with full scans. Shows EXPLAIN plan
Warn
Warning with "Run Anyway" / "See EXPLAIN" / "Cancel"
Off
No checks
Supports PostgreSQL (Seq Scan), SQLite (SCAN TABLE via EXPLAIN QUERY PLAN), ClickHouse, and SQL Server (estimated plans via SET SHOWPLAN_TEXT ON). Set globally in settings or per connection. Viewstor preserves SQL Server statements as entered. Add TOP or OFFSET/FETCH in T-SQL when you want a bounded result.
Read-only Mode
Mark a connection or an entire folder as read-only. Child connections inherit the setting. Mutations are blocked in the query editor, result grid, and MCP commands, including raw SQL supplied to standalone execute_query and build_chart. PostgreSQL connections also set default_transaction_read_only=on, and ClickHouse requests use readonly=1, providing database-level enforcement in addition to SQL screening.
Connections
Nested folders with drag-and-drop for connections and folders
Multi-database — list several databases in one connection, each as a separate tree node
Color coding — theme-aware palette or hex picker, tints icons; folders pass color to children
SSL and SSH tunnel / SOCKS5 proxy support
Native VS Code form chrome — Connection / Folder forms built on @vscode-elements/elements with @vscode/codicons; render correctly in light, dark, and high-contrast themes. Power-user settings (Safe mode override, Store in, Hidden schemas) tucked under a collapsible Advanced section so the default form stays short
Auto-collapse single-database and single-schema levels
Hide schemas/databases from context menu
Inaccessible objects (no permissions) rendered in error color
ER Diagram
Right-click a connected connection, database, or schema → Show ER Diagram:
Tables and views share one continuous canvas and always render as complete cards with columns: PostgreSQL schemas and ClickHouse databases occupy separate tinted regions, while engines without namespaces keep a plain canvas; views use a dashed purple border
Search matches table, view, and column names and mirrors matches in a dropdown with matching columns; table and view type labels reuse the legend's blue and purple colors. Multiple matching tables are highlighted on the full diagram, while a unique or explicitly selected result opens that table's direct-neighbour graph
Right-click a table or view card for the same object actions as in the Connections tree; both surfaces share one action registry guarded by a synchronization test
The toolbar stays task-focused and does not expose internal zoom, render-mode, or focused-node diagnostics
Foreign-key lines include column mappings and ON DELETE / ON UPDATE details; lines are slightly muted below 3×, where arrowheads, relationship hover highlighting, and relationship tooltips appear
Scroll anywhere on the canvas to zoom, including empty space beyond the graph; target-based easing stays responsive to trackpads
Cards highlight and mark primary keys as PK, source foreign-key columns as FK, and indexed columns as IDX. Combined roles are preserved, such as FK, IDX
Zoom enlarges each card as one graphics group, so its frame, text, row spacing, and padding inherit exactly the same camera transform and preserve their proportions at every level; role colors are intentionally muted to keep dense schemas readable
Hover a column to see its database comment, foreign-key role, and index names when available
Hover a table or relationship to keep its adjacent graph visible while unrelated objects fade smoothly over a fast 150 ms transition
Double-click a table to isolate it in the centre with its directly related tables; double-click the centre or blank canvas, or press Esc, to return
Use the relationship icon to toggle edges; it is crossed out while edges are hidden, and both toolbar icons explain their actions on hover or keyboard focus. The canvas legend explains namespace regions, tables, views, relationships, primary keys, foreign keys, indexes, and required columns
Start a left-button drag even on empty canvas beyond the outermost tables, or hold the middle mouse button, to pan horizontally and vertically
PostgreSQL and SQLite relationships are detected natively. ClickHouse still shows its tables and columns with a clear note that the driver has no FK metadata; Redis has no relational tables to diagram
Query Editor
Per-connection SQL tabs (Ctrl+Enter to execute)
SQL autocomplete — context-aware: tables after FROM/JOIN, columns from referenced tables, table.column dot trigger, alias resolution, enum value suggestions after =/IN
SQL diagnostics — error underline for non-existent tables, warning for unknown columns
Index hints — warning diagnostics on WHERE/ORDER BY columns without an index
Estimated row count from statistics, exact count via refresh
Editable SQL bar above the table — edit the query in place, pagination stays live (host re-applies LIMIT N OFFSET p*N and fetches an exact COUNT(*) for the user's query); your explicit LIMIT acts as a ceiling across pages; only read-only SQL (SELECT / WITH / EXPLAIN / SHOW / VALUES) runs from the bar
Inline editing with PK-based UPDATE, type-aware SQL (numeric PKs without quotes, ::jsonb cast)
Add / delete rows — insert with DEFAULT values, delete from toolbar or right-click context menu
Resizable columns — drag column header edge to adjust width
Refresh button — re-run current query without page reload
Column sorting (shift-click for multi-column); manual ORDER BY in the SQL bar syncs back to the header indicators
Cell selection with drag, Shift+Click range, resize handle
Search with Ctrl+F, Enter to cycle matches
Export & Copy
Export all rows (not just current page) — CSV, TSV, JSON, Markdown
Click the chart button in the Result Panel toolbar to open the chart panel
Config sidebar — axis mapping, aggregation, group by, area fill, legend
Auto-detection — suggests the best chart type based on column types (time → line, categorical → pie, etc.)
Multi-source charts — overlay data from multiple queries on one chart:
Execute and pin queries you want to combine (pin icon in Query History)
Open a chart from any result set
Click + Data Source in the chart toolbar, pick a pinned query
Choose merge mode:
Separate series — each source rendered as independent series (different X values are fine)
Join by column — rows matched by a key column (like SQL LEFT JOIN), additional Y columns merged into the primary dataset
Select which numeric columns to include, set a label — done
Example: pin SELECT ts, cpu FROM metrics and SELECT ts, mem FROM metrics, open chart from CPU, add Memory as data source with join on ts — both metrics on the same time axis.
Data Diff
Compare data between tables — even across different connections (dev vs staging):
Right-click a table and choose Compare With.... The comparison tab opens with the source table identified, and the picker offers tables from connected databases. If you dismiss the picker, select Pick a table to compare with in the tab to reopen it.
Row diff — matches rows by a compatible primary key from either side, or by user-selected columns shared by both sources; highlights added/removed/changed cells side-by-side with zebra-striped rows. ClickHouse MergeTree keys are resolved from system.columns
Schema diff — compare column names, types, nullability, PK status, plus indexes, constraints, triggers, and sequences
Statistics diff — same-type comparisons show each driver's complete metric set. All drivers normalize the presence of row_count, total_size, and last_modified where meaningful, using null when an engine cannot provide a value. Cross-type comparisons show only metrics with explicitly compatible semantics (currently row count), disclose that PostgreSQL counts may be estimated, and hide incompatible storage metrics instead of presenting misleading deltas
Custom SQL — editable queries per side under the collapsible "SQL" block, with Synced toggle + lock indicator for mirrored edits
Tab headers show colored count badges (e.g. Schema Diff •6); filter chips per tab (click to solo, Shift+click to toggle)
Export diff as CSV or JSON
Configure max rows in settings (viewstor.diffRowLimit, default 10,000)
Also available via Command Palette: Viewstor: Compare Data.
Database Statistics
Open Show Database Statistics from a connected PostgreSQL, ClickHouse, or SQLite connection, a database node, or the Command Palette. Choose a database if the connection has several visible databases.
Overview shows the database size and object counts. Hidden databases and schemas are excluded from the corresponding lists and object counts.
Top tables shows sortable sizes and row estimates. Select a table name to open its data. PostgreSQL groups visible partitions under their parent. SQLite lists tables by name when DBSTAT is unavailable or the logical database exceeds 64 MiB.
Connection metrics shows connected sessions and cache statistics in PostgreSQL, active parts and running queries in ClickHouse, or page and journal information in SQLite.
Refresh updates statistics on demand. viewstor.databaseStats.topTablesLimit defaults to 50 (max 500). viewstor.databaseStats.autoRefreshSeconds defaults to 0 (off) and refreshes only while the panel is visible.
Click the 🗺 map button in the Result Panel toolbar to open the map for the current result set
Auto-detects coordinate columns:
GeoJSON Point ({"type":"Point","coordinates":[lng,lat]})
WKT (POINT(lng lat))
{lat, lng} / {latitude, longitude} objects
[lng, lat] arrays or PG array strings ({lng,lat})
Separate lat / lng columns
Manual column picker — toolbar has a Mode toggle (Single column / Lat + Lng) and selects for picking the coordinate and label columns by hand when auto-detection doesn't match; hover a field label for a tooltip with format hints
Circle markers tinted with the VS Code accent color, with a popup (click) that shows the full row
Labels — when the result contains ≤50 points the chosen label column is rendered permanently on each marker; otherwise it shows on hover
Auto-zoom to fit all points; up to 10,000 points rendered per view
Copilot Chat (@viewstor)
Ask questions about your database in natural language:
@viewstor describe the users table
@viewstor write a query to find orders without payments
@viewstor what indexes are missing for this query?
@viewstor /chart show request latency over the last hour grouped by endpoint
Schema context is injected automatically from the active connection. Slash commands: /schema, /query, /describe, /chart. Requires GitHub Copilot.
Apache Kafka
Enter bootstrap brokers as a comma-separated list of hostnames or IPv4 addresses. A broker without an explicit port uses the port from the connection form. Select PLAIN, SCRAM-SHA-256 or SCRAM-SHA-512 when using SASL credentials. Enable SSL for TLS listeners. Use a user connection to keep SASL credentials available after restarting VS Code or when connecting through standalone MCP.
Expand the Kafka connection to browse topics, partitions, and consumer groups. Opening a topic shows a read-only snapshot of recent retained offsets from its partitions, capped at 1,000 messages. Offset gaps can yield fewer messages. JSON messages can be opened in a separate editor. Non-UTF-8 keys and values display as Base64.
Use LIST TOPICS, LIST GROUPS, DESCRIBE <topic>, CONSUME <topic> [N] [from-beginning], and PRODUCE <topic> [key] <value> in a query tab or through MCP. CONSUME defaults to listening for new messages. Use from-beginning to sample retained history. Quote text with spaces or pass a JSON object or array as one value. Publish to an existing topic. The usual agent write approval applies to PRODUCE.
AI Agent Integration (MCP)
Use AI agent access in the connection or folder form to choose Full, Schema only, or None. Full uses the existing read-only and write-approval settings. Schema only allows discovery and schema inspection. None hides the connection from agents. An unset mode inherits the nearest folder choice or your user setting viewstor.defaultAgentAccess (Full by default). Workspace connection and folder settings can narrow user access. Manually opening a connection in VS Code is still available.
VS Code saves the user default in the standalone MCP profile. After changing the default, connection, or folder, call reload_connections in an already running MCP session. Reload the VS Code window after editing an access mode directly in its user profile JSON.
Two MCP interfaces — pick the one that fits your workflow:
VS Code MCP commands (for Copilot, Cursor — agents running inside VS Code):
Command
What it does
viewstor.mcp.listConnections
List connections with status
viewstor.mcp.getSchema
Flattened schema (tables, columns, types)
viewstor.mcp.executeQuery
Run SQL (read-only enforced)
viewstor.mcp.getTableData
Fetch rows with limit
viewstor.mcp.getTableInfo
Column metadata, PKs, nullability
viewstor.mcp.visualize
Execute query and open chart panel
viewstor.mcp.openQuery
Open SQL editor with query text (optionally execute one statement)
viewstor.mcp.openTableData
Open table data view with optional custom query
Standalone MCP server (for Claude Code, Cline — CLI agents running outside VS Code):
The extension installs a launcher at ~/.viewstor/mcp-server.js that auto-updates on each activation — no manual path changes needed when the extension updates.
Quick setup:Ctrl+Shift+P → Viewstor: Setup MCP → Copy Config → paste into your agent's MCP config.
9 tools: list_connections, get_schema, execute_query, get_table_data, get_table_info, add_connection, reload_connections, build_chart, export_grafana_dashboard. Reads connections from ~/.viewstor/connections.json and .vscode/viewstor.json. Connections sync bidirectionally with the VS Code extension. See the MCP Server wiki page for setup instructions.
Both interfaces auto-connect for queries and respect connection and folder read-only settings. For a user connection, choose Advanced → Agent write approval. A user folder can supply a default for its connections. In VS Code the default asks for each non-read query and shows the full query and destination. Ask for schema changes, administrative and unclassified queries allows recognized data writes in VS Code. Standalone MCP requires Allow non-read queries without prompting before it can run a write. After editing user settings, call reload_connections or restart the MCP server before submitting another write. Writes on project connections always require confirmation in VS Code. Chart tools accept read queries. Choose the Redis database with the tool’s database argument.
Use database credentials with only the privileges the agent needs. Query classification is a safeguard against accidental writes. Database permissions also apply to operations inside SQL functions and extensions.
add_connection safety modes — controlled by settings.allowAddConnection in the user-owned ~/.viewstor/connections.json (project files cannot override it):
"restricted" (default): agent-created connections are forced read-only, project-scoped (password stripped), and prefixed [agent] . PostgreSQL, ClickHouse, and file-backed SQLite are supported; Redis and in-memory/temporary SQLite are rejected with invalid_config because safe read-only enforcement is unavailable.
The explicit user-global VS Code setting viewstor.standaloneMcp.allowAddConnection syncs to the same JSON key on activation and configuration changes. Default and workspace-only values do not overwrite a manually edited JSON policy. Restart the standalone server or call reload_connections after changing the file.
Every call is recorded in ~/.viewstor/audit.jsonl, including disabled/malformed calls, the resolved final configuration, and persistence failures. Passwords and other secrets are omitted from the audit log.
Data-oriented tools (execute_query, get_schema, get_table_data, get_table_info, build_chart) accept an optional database parameter — query another database on the same server without creating a new connection or re-entering the password.
Other
Query history with execution time and row count — click to re-execute
DDL viewer for tables, views, indexes, triggers, sequences
JSON/JSONB cell editor with syntax highlighting (double-click to open)
SQL Server connections use SQL authentication with a host and TCP port. Use SQL Server 2022 or later for preset chart time buckets. The table browser pages ordinary table reads using OFFSET/FETCH. When you enter custom T-SQL in its SQL bar, Viewstor runs the statement as written and displays a single result page.
The SQL Server E2E suite uses a disposable local SQL Server 2022 instance. Set VIEWSTOR_MSSQL_TEST_PASSWORD to its sa password and VIEWSTOR_MSSQL_TEST_PORT if the instance uses a port other than 1433. Tests create and drop a dedicated schema in tempdb.
Development
Prerequisites
Node.js ^22.14.0 or >=23.6.0 (N-API 10)
VS Code 1.101+
Docker (for e2e tests)
Commands
npm run dev # development build
npm run watch # rebuild on changes
npm run build # production build
npm run lint # ESLint check
npm run lint:fix # auto-fix
npm test # unit tests (vitest)
npm run test:e2e # e2e tests (Docker required)
npm run package # .vsix package