sql-preview 0.5.11 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Changelog.md ADDED
@@ -0,0 +1,302 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ## [0.6.2] - 2026-06-03
6
+
7
+ ### Added
8
+
9
+ - Added a product strategy note on using SQL Preview's query wedge to accelerate toward a broader agentic query layer.
10
+ - Added the initial RFC-054 Zed MCP extension scaffold, local verification script, and setup guide.
11
+ - Added Zed marketplace readiness checks, CI, and publishing instructions for submitting the SQL Preview MCP extension to `zed-industries/extensions`.
12
+ - Added Snowflake Browser SSO profile support for VS Code by passing `EXTERNALBROWSER` auth options to the Snowflake driver without storing a Snowflake password.
13
+
14
+ ### Fixed
15
+
16
+ - Added Snowflake SDK optional-dependency handling so packaged VS Code installs surface guided installation advice instead of an unexplained missing-module failure.
17
+
18
+ ## [0.6.1] - 2026-05-29
19
+
20
+ ### Fixed
21
+
22
+ - Moved the welcome guide into the SQL Preview panel instead of opening a separate editor tab.
23
+ - Routed connection management actions to Settings > Connections instead of opening the raw daemon localhost URL.
24
+ - Fixed welcome guide connection summary state so existing active profiles are detected.
25
+ - Replaced raw "Session not found" query failures with clear rerun guidance when the daemon restarts during an in-flight query.
26
+ - Fixed settings refresh so a missing telemetry preference keeps the 0.6.1 default enabled state instead of clearing the checkbox.
27
+ - Removed the inactive "Start using SQL Preview" welcome action.
28
+
29
+ ### Changed
30
+
31
+ - Reworked the welcome guide into a reusable guide hub with multi-database, VS Code/Cursor, MCP, first-query, and latest-highlight sections.
32
+ - Added a Settings > About action to reopen the welcome guide at any time.
33
+ - Added Markdown export for the welcome guide and exposed the same guide as an MCP Markdown resource for agents.
34
+ - Switched SQL Preview product telemetry to enabled by default when VS Code telemetry is enabled, with opt-out available in Settings.
35
+
36
+ ## [0.6.0] - 2026-05-28
37
+
38
+ ### Added
39
+
40
+ - Added RFC-017 daemon configuration loading with strict JSON defaults, file/env/CLI precedence, validation, source reporting, and a read-only `/config` endpoint.
41
+ - Added documentation and RFC agent guidance for docs stewardship, in-progress RFC tracking, and RFC-to-code commit traceability.
42
+ - Added explicit VS Code active connection selection so users can choose which saved profile runs `.sql` queries.
43
+ - Added PostHog-backed product telemetry plumbing with VS Code telemetry gating, schema validation, safe query buckets, and transparency metadata.
44
+ - Added a General settings telemetry control so users can enable or opt out from the SQL Preview panel.
45
+ - Added RFC-048 query operation contracts with structured MCP results for query execution and tab page retrieval.
46
+ - Added multi-surface tab projection so daemon result tabs can be rendered across VS Code and the browser without session/tab ID collisions.
47
+ - Added RFC-047 daemon surface composition docs and `/status` surface diagnostics for HTTP, MCP HTTP, WebSocket, IPC socket, and stdio readiness.
48
+ - Added package-owned connector descriptors for built-in connector metadata, lazy factories, and dynamic connection form schemas.
49
+ - Added RFC-052 welcome UX and connector migration planning, plus RFC-053 agent skills integration planning.
50
+ - Added the RFC-052 welcome guide with legacy settings migration, migrated-profile connection testing, and explicit telemetry opt-in.
51
+
52
+ ### Fixed
53
+
54
+ - Made daemon PID-file cleanup verify an existing process via `/status` before terminating it, avoiding unsafe PID reuse kills.
55
+ - Applied the same safe PID verification to the extension daemon client before it terminates stale daemon PIDs.
56
+ - Hardened daemon subprocess connector cleanup with early close/error listeners, bounded stderr capture, abort escalation, and child cleanup for connection tests.
57
+ - Closed stale daemon HTTP MCP sessions instead of only dropping map entries, and included them in resource-change broadcasts.
58
+ - Aborted direct daemon HTTP query execution when clients disconnect before a response is sent.
59
+ - Redacted sensitive MCP request headers in daemon logs while preserving non-secret diagnostics.
60
+ - Added WebSocket MCP message-size enforcement and BigInt-safe serialization to match daemon socket transport behavior.
61
+ - Enforced daemon per-session tab limits during query execution to prevent unbounded result tab growth.
62
+ - Hardened daemon tab/query lifecycle cleanup so closed or reused tabs abort stale queries and cannot lose newer abort controllers.
63
+ - Enforced daemon query timeouts so long-running connector calls receive an abort signal and report a clear timeout error.
64
+ - Bundled the WebSocket runtime into daemon builds so packaged VS Code installs can start `out/server/standalone.js` without relying on an excluded `node_modules/ws` dependency.
65
+ - Fixed Trino connection tests from the Connections panel so they use the same saved credentials and Basic Auth path as normal query execution.
66
+ - Improved Connections panel test-result visibility by wrapping full error details instead of truncating them inline.
67
+ - Fixed ambiguous multi-profile query routing by honoring `sqlPreview.activeConnectionId` before falling back to connector type or list order.
68
+ - Fixed connection password commands so they target the active/selected connection instead of silently updating the first saved profile.
69
+ - Fixed unsaved Trino connection tests so form-entered passwords produce the required Basic Auth header.
70
+
71
+ ### Changed
72
+
73
+ - Updated the RFC process to include an `inprogress` lifecycle folder and implementation tracking expectations.
74
+ - Routed MCP, VS Code, and browser query execution through a shared daemon query operation lifecycle.
75
+ - Refactored daemon HTTP, MCP Streamable HTTP, WebSocket MCP, IPC socket MCP, and stdio MCP wiring into explicit `src/server/surfaces/` modules.
76
+ - The Connections panel now shows per-connection password status and native Set/Clear actions without exposing stored secrets to the webview.
77
+ - Reorganized the MCP Server settings tool list into clearer grouped sections with short descriptions.
78
+ - The browser session sidebar now filters the shared results layout and routes tab close, cancel, select, and rerun actions through session-aware daemon APIs.
79
+
80
+ ## [0.5.12] - 2026-02-19
81
+
82
+ ### Added
83
+
84
+ - **Modular Connection Profiles**: Implemented a robust connection management system supporting multiple profile stores (File, Environment Variables) and secure credential handling.
85
+ - **Environment Configuration**: Added support for configuring connections via `SQL_PREVIEW_CONNECTIONS` environment variable.
86
+ - **Profile Management**: Updated Daemon to serve as the single source of truth for connection profiles.
87
+
88
+ ### Fixed
89
+
90
+ - **Connection Listing**: Fixed `list_connections` tool to correctly return full profile details (excluding passwords) ensuring the extension can execute queries reliably.
91
+
92
+ ## [0.5.11] - 2026-02-16
93
+
94
+ ### Fixed
95
+
96
+ - **MCP Connection**: Resolved issues with MCP server startup and connection handling.
97
+ - **Testing**: Fixed failing unit and integration tests.
98
+
99
+ ## [0.5.1] - 2026-02-04
100
+
101
+ ### Added
102
+
103
+ - **Version Checking**: Added automated version checking for extension updates.
104
+ - **Testing**: Added comprehensive unit tests for `ResultsViewProvider`'s version check and webview message handling.
105
+
106
+ ## [0.5.0] - 2026-01-30
107
+
108
+ ### Architecture
109
+
110
+ - **Daemon Process**: Introduced a standalone `Daemon` service to decouple query execution and state management from the VS Code extension host. This improves stability and enables persistent sessions.
111
+ - **MCP Server Refactor**: Completely rewrote the MCP Server (`DaemonMcpServer`) to run within the Daemon, providing robust tool management and better integration with LLM agents.
112
+
113
+ ### Added
114
+
115
+ - **RFC Documentation**: Added RFCs 000-005 covering Roadmap, Agentic Testing, Single Server Architecture, MCP UI, and Session Security.
116
+ - **Comprehensive Testing**: Added extensive unit and integration tests (~9.5k lines changed) covering Daemon, MCP, ConnectionManager, and Query execution.
117
+ - **Session Management**: Implemented `SessionManager` and `DaemonClient` for robust state handling across extension reloads.
118
+
119
+ ### Changed
120
+
121
+ - **Query Execution**: Refactored `QueryExecutor` to support distinct execution modes and better error handling.
122
+ - **Repository**: Renamed repository to `sql-preview` and updated all internal references.
123
+
124
+ ## [0.4.2] - 2026-01-27
125
+
126
+ ### Added
127
+
128
+ - **Filter Improvements**: Added a "Select All" checkbox to the column set filter, enabling easier bulk selection and deselection of visible items.
129
+
130
+ ### Fixed
131
+
132
+ - **Data Parsing Integrity**: Fixed a critical issue where high-precision decimal numbers (e.g. `1932.53...`) were incorrectly parsed as "Invalid Number" or strings. The parser now intelligently handles BigInts while preserving standard floating point numbers for correct display and sorting.
133
+
134
+ ## [0.3.9] - Unreleased
135
+
136
+ ### Added
137
+
138
+ - **Open Source Preparation**:
139
+ - Added MIT License and updated copyright year to 2026.
140
+ - Added Security Policy (`SECURITY.md`) and Code of Conduct (`CODE_OF_CONDUCT.md`).
141
+ - Created Contribution Guidelines (`CONTRIBUTING.md`) and Developer Guide (`ARCHITECTURE.md`).
142
+ - Added GitHub Issue and Pull Request templates.
143
+ - configured GitHub Actions for CI/CD (lint, test, build).
144
+ - Added Dependabot configuration.
145
+ - **Testing & Quality**:
146
+ - Added `test:coverage` script for test coverage reporting.
147
+ - Improved unit test reliability (password management tests).
148
+ - Adopted strict linting and formatting standards.
149
+ - **Codebase**:
150
+ - Replaced console logs with structured `Logger` in MCP Server.
151
+ - Cleaned up unused dependencies (`body-parser`, `glob`, etc.).
152
+
153
+ ## [0.3.8] - 2026-01-20
154
+
155
+ ### Added
156
+
157
+ - **UI UX Polish**:
158
+ - Implemented "native-like" grid selection feel by removing browser text overlay.
159
+ - Enhanced copy/paste functionality to reliably copy rows as TSV with headers.
160
+ - Added persistence for "Row Height" preference (Normal, Compact, Comfortable).
161
+ - Unified gutter selection styling for a consistent visual experience.
162
+
163
+ ### Changed
164
+
165
+ - **Architecture**: Decoupled MCP Server from `ResultsViewProvider` for better modularity and stability.
166
+ - **MCP Server**: Improved robustness of server startup/shutdown to prevent `EADDRINUSE` and `ERR_SERVER_NOT_RUNNING` errors.
167
+
168
+ ### Fixed
169
+
170
+ - **Runtime Stability**: Resolved race conditions in MCP server lifecycle.
171
+ - **Styling**: Fixed AG Grid focus ring issues and selection color inconsistencies.
172
+
173
+ ## [0.2.4] - 2026-01-12
174
+
175
+ ### Fixed
176
+
177
+ - **State Persistence**: Resolved persistent test failures and ensured `workspaceState` is correctly managed.
178
+ - **Results Provider**: Fixed memory leaks by cleaning up event listeners on disposal.
179
+ - **Linting**: Addressed numerous code style and type safety issues (removed console logs, fixed strict types).
180
+
181
+ ## [0.2.2] - 2025-12-08
182
+
183
+ ### Added
184
+
185
+ - **Tab Naming Configuration**: Added `sqlPreview.tabNaming` setting to switch between `file-sequential` (Result 1, Result 2) and `query-snippet` naming.
186
+ - **Settings Organization**: Organized settings into transparent groups: Connection, Display, and Advanced (Beta).
187
+
188
+ ### Fixed
189
+
190
+ - **Tab Naming**: Fixed issue where tabs would revert to query snippet naming during loading.
191
+ - **Loading UX**: Improved loading experience by hiding the empty grid and random headers while the query executes.
192
+
193
+ ## [0.2.1] - 2025-12-01
194
+
195
+ ### Added
196
+
197
+ - **MCP Server**: Added Model Context Protocol (MCP) server feature for enhanced context awareness.
198
+
199
+ ### Fixed
200
+
201
+ - **Persistence**: Fixed issues with state persistence.
202
+ - **Tab Management**: Fixed tab focus issues and added comprehensive tests for tab management.
203
+ - **Sync**: Fixed MCP synchronization issues.
204
+
205
+ ## [0.2.0] - 2025-11-30
206
+
207
+ ### Added
208
+
209
+ - **AG Grid Improvements**:
210
+ - Added copy functionality for rows, columns, and cells.
211
+ - Added query tooltips.
212
+ - Added column datatypes display in headers.
213
+ - **Run in New Tab**: Added capability to execute queries in a new tab.
214
+ - **JSON Viewer**: Added a JSON viewer for better data inspection.
215
+
216
+ ### Changed
217
+
218
+ - **AG Grid Standardization**:
219
+ - Restored standard column menu.
220
+ - Enhanced context menu.
221
+ - Updated scrollbar styling.
222
+ - **Refactor**: Moved column type display to tooltips and fixed selection behavior.
223
+
224
+ ### Fixed
225
+
226
+ - **Windows Compatibility**: Addressed further Windows-specific bugs.
227
+ - **Network**: Fixed HTTPS request handling.
228
+
229
+ ## [0.1.6] - 2025-11-07
230
+
231
+ ### Fixed
232
+
233
+ - Work around Porta returning "Empty query not supported" for valid SQL when using the Trino client. The extension now executes the first page via direct HTTPS POST to `/v1/statement` with Trino and Presto headers, then follows `nextUri` using HTTP GET. This mirrors clients like DataGrip and restores compatibility.
234
+ - Pagination: continue even when `columns` are not present in the first response (some clusters send columns on later pages).
235
+ - Export flow aligned to the same direct POST + pagination path for consistency.
236
+
237
+ ### Added
238
+
239
+ - Probes to diagnose connectivity quickly:
240
+ - `npm run probe` (multiple HTTP variants)
241
+ - `npm run probe:extension` (matches extension path end-to-end)
242
+ - `.env.local` workflow (git-ignored) and `env.example` for credentials during local probes.
243
+
244
+ ### Added
245
+
246
+ - Initial VS Code extension setup for Presto/Trino database connections
247
+ - **Secure password storage** using VS Code's SecretStorage API
248
+ - Password management commands for secure credential handling
249
+ - **Settings UI integration** for password management with "Set Password" button
250
+ - Command palette integration with `Presto: Run Query` command
251
+ - Code lens provider for executing SQL queries directly from editor
252
+ - Results view panel with Tabulator integration for data visualization
253
+ - Configuration setting for maximum rows to display (`presto.maxRowsToDisplay`)
254
+ - Pagination support for fetching large result sets
255
+ - Visual styling improvements for the results grid:
256
+ - Integration with VS Code theme
257
+ - Row number column
258
+ - Improved formatting and density
259
+ - Header styling enhancements
260
+ - Connection handling with authentication support
261
+ - Error handling and display in the results view
262
+ - Query execution status indicators
263
+ - Dynamic theme color integration with VS Code:
264
+ - Table adapts to user's selected theme
265
+ - Row backgrounds, text colors, and borders match theme
266
+ - Support for light, dark, and high-contrast themes
267
+ - Live theme updates when user changes VS Code theme
268
+
269
+ ### Changed
270
+
271
+ - **SECURITY**: Removed plaintext password storage from settings - now uses secure VS Code SecretStorage
272
+ - Replaced Tabulator with AG Grid for the results view, providing enhanced features and a more modern grid experience.
273
+ - Enabled floating filters by default in the AG Grid results view for easier column-specific filtering.
274
+ - Updated results display to use Tabulator for better data visualization
275
+ - Improved results panel styling to better match VS Code themes
276
+ - Enhanced query result handling with pagination support
277
+ - Switched from `client.execute()` to `client.query()` for compatibility
278
+ - Refactored CSS to use theme variables for consistent styling
279
+
280
+ ### Fixed
281
+
282
+ - **Windows Compatibility**: Fixed "path must not be empty" error during extension activation on Windows systems
283
+ - Added comprehensive path validation and normalization for cross-platform compatibility
284
+ - Enhanced webview resource path handling with graceful fallback mechanisms
285
+ - Implemented proper error handling and logging for path-related issues
286
+ - Added validation for extension URI and resource roots to prevent empty path errors
287
+ - Improved extension activation robustness with detailed error reporting
288
+ - Properly mocked filesystem dependencies in tests instead of bypassing validation
289
+ - Resolved pagination issues when fetching large result sets
290
+ - Fixed layout and styling issues in the results view
291
+ - Corrected variable declarations (let vs const) based on usage patterns
292
+ - Addressed linter errors and warnings
293
+ - Fixed module resolution for the Results View Provider
294
+ - Resolved connection and authentication issues with Trino client
295
+
296
+ ### Developer Improvements
297
+
298
+ - Added ESLint configuration
299
+ - Configured TypeScript compilation settings
300
+ - Added proper module structure and organization
301
+ - Implemented better error handling and logging
302
+ - Created theme-aware UI components for improved user experience
package/README.md CHANGED
@@ -1,106 +1,257 @@
1
- # SQL Preview for VS Code
1
+ # SQL Preview
2
2
 
3
- A Visual Studio Code extension for connecting to **Trino** databases, running SQL queries, and visualizing results directly within your editor.
3
+ **A fast SQL workspace for VS Code and MCP-enabled AI agents.**
4
4
 
5
- ## Features
5
+ Run SQL in VS Code, manage database profiles securely, inspect results in a
6
+ high-performance grid, and expose governed database tools to Claude, Cursor,
7
+ Copilot, and other Model Context Protocol clients.
6
8
 
7
- - **SQL Query Execution**: Run SQL queries against Trino databases directly from VS Code.
8
- - **Interactive Results View**: View query results in a high-performance AG Grid table with sorting, filtering, and resizing.
9
- - **Code Lens Integration**: Execute queries with a single click from your `.sql` files.
10
- - **Client-Server Architecture**: Uses a dedicated background daemon for reliable connection management and query execution.
11
- - **Secure Password Storage**: Passwords are encrypted using the OS keyring via VS Code's SecretStorage API.
12
- - **MCP Integration (Beta)**: Exposes database tools to AI agents via the Model Context Protocol.
9
+ [![VS Code Marketplace](https://img.shields.io/visual-studio-marketplace/v/mehul.sql-preview?label=VS%20Code%20Marketplace&color=0066b8)](https://marketplace.visualstudio.com/items?itemName=mehul.sql-preview)
10
+ [![Installs](https://img.shields.io/visual-studio-marketplace/i/mehul.sql-preview)](https://marketplace.visualstudio.com/items?itemName=mehul.sql-preview)
11
+ [![OpenVSX](https://img.shields.io/open-vsx/v/mehul/sql-preview?label=OpenVSX&color=a60ee5)](https://open-vsx.org/extension/mehul/sql-preview)
12
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
13
13
 
14
- ## Usage
14
+ ---
15
15
 
16
- ### Running Queries
16
+ ## Why SQL Preview?
17
17
 
18
- 1. Open a `.sql` file.
19
- 2. **Code Lens**: Click "Run Query" above the SQL block.
20
- 3. **Command Palette**: Open the palette (`Cmd+Shift+P`) and run `SQL Preview: Run Query`.
21
- 4. **Shortcut**: Press `Cmd+Enter` (Mac) or `Ctrl+Enter` (Windows/Linux) to run the query.
18
+ SQL Preview is built for the workflow where humans and agents both need real
19
+ database context:
22
20
 
23
- ### Viewing Results
21
+ - **Query from the editor**: open a `.sql` file, press `Cmd+Enter` or
22
+ `Ctrl+Enter`, and inspect results without leaving VS Code.
23
+ - **Manage real connection profiles**: create, test, select, and migrate
24
+ database connections from the SQL Preview panel.
25
+ - **Give agents governed access**: expose read-only MCP tools for running
26
+ queries, listing schemas and tables, describing columns, and inspecting shared
27
+ result tabs.
28
+ - **Stay local-first**: there is no hosted SQL Preview service and no bundled
29
+ AI model. Credentials stay in your VS Code Secret Storage or your local
30
+ daemon profile configuration.
24
31
 
25
- Results appear in the **SQL Preview** panel.
32
+ ---
26
33
 
27
- - **Sort**: Click column headers.
28
- - **Filter**: Use the text boxes below headers.
29
- - **Export**: Right-click to copy cells.
34
+ ## Highlights
30
35
 
31
- ## Architecture
36
+ - **Connection manager** with dynamic connector forms, active profile selection,
37
+ legacy settings migration, and per-connection password actions.
38
+ - **Tabbed result grid** powered by AG Grid with sorting, filtering, column type
39
+ display, adjustable density, TSV copy, and full CSV export.
40
+ - **Daemon-backed execution** so heavy queries do not block the editor and
41
+ results can be shared across VS Code, browser, and MCP surfaces.
42
+ - **MCP server** for Claude Desktop, Cursor, Copilot, and other MCP clients,
43
+ with safe mode enabled by default for read-only operation.
44
+ - **Multi-surface sessions** so agent-triggered and editor-triggered work can be
45
+ inspected through the same local daemon without tab ID collisions.
46
+ - **Transparent telemetry** that is off by default, opt-in only, and never sends
47
+ SQL text, results, credentials, hostnames, database names, schema/table/column
48
+ names, file paths, usernames, or raw errors.
32
49
 
33
- This extension uses a robust **Client-Server** model:
50
+ ---
34
51
 
35
- 1. **Extension (Client)**: The VS Code frontend that handles UI, commands, and configuration.
36
- 2. **Daemon (Server)**: A separate Node.js process that manages database connections and executes queries.
37
- 3. **Communication**: The Client and Daemon communicate via the **Model Context Protocol (MCP)** over local sockets.
52
+ ## Supported Databases
38
53
 
39
- This separation ensures that long-running queries do not block the VS Code UI and provides a stable environment for database interactions.
54
+ SQL Preview ships connector metadata and setup forms for:
40
55
 
41
- ## Configuration
56
+ | Database | Connector |
57
+ | -------------- | ----------- |
58
+ | PostgreSQL | `postgres` |
59
+ | MySQL | `mysql` |
60
+ | SQLite | `sqlite` |
61
+ | DuckDB | `duckdb` |
62
+ | Trino / Presto | `trino` |
63
+ | Snowflake | `snowflake` |
64
+ | BigQuery | `bigquery` |
65
+ | SQL Server | `mssql` |
66
+
67
+ Trino/Presto and PostgreSQL are bundled into the extension build. Native and
68
+ cloud-provider connectors are lazy-loaded and may require their driver runtime in
69
+ the active environment; SQL Preview reports guided missing-driver errors instead
70
+ of failing silently.
71
+
72
+ ---
73
+
74
+ ## Quick Start: VS Code
75
+
76
+ 1. Install SQL Preview from the
77
+ [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=mehul.sql-preview)
78
+ or [OpenVSX](https://open-vsx.org/extension/mehul/sql-preview).
79
+ 2. Run **SQL Preview: Manage Connections** from the Command Palette.
80
+ 3. Add a connection profile, set its password, test it, and make it active.
81
+ 4. Open a `.sql` file and press **`Cmd+Enter`** on macOS or **`Ctrl+Enter`** on
82
+ Windows/Linux.
83
+
84
+ Results open in the **SQL Preview** panel at the bottom of the editor. To force a
85
+ new tab, run **SQL Preview: Run Query (+ Tab)**.
86
+
87
+ ### Migrating from Legacy Settings
88
+
89
+ If you previously configured `sqlPreview.host`, `sqlPreview.port`,
90
+ `sqlPreview.user`, `sqlPreview.catalog`, `sqlPreview.schema`, or
91
+ `sqlPreview.databasePath`, open **SQL Preview: Show Welcome Guide** or
92
+ **SQL Preview: Manage Connections**. SQL Preview can import those settings into a
93
+ named connection profile and keep passwords in VS Code Secret Storage.
94
+
95
+ ---
42
96
 
43
- Add the following configuration to your `settings.json`:
97
+ ## Quick Start: MCP Agents
98
+
99
+ ### From VS Code
100
+
101
+ 1. Run **SQL Preview: Manage Connections** and confirm your active connection.
102
+ 2. Open the SQL Preview settings panel and enable the MCP server.
103
+ 3. Keep safe mode enabled unless you explicitly want agents to run mutating SQL.
104
+ 4. Configure HTTP-capable MCP clients with the local endpoint shown in the panel,
105
+ typically:
44
106
 
45
107
  ```json
46
108
  {
47
- "sqlPreview.defaultConnector": "trino",
48
- "sqlPreview.host": "trino-coordinator.example.com",
49
- "sqlPreview.port": 443,
50
- "sqlPreview.user": "your-username",
51
- "sqlPreview.catalog": "hive",
52
- "sqlPreview.schema": "default",
53
- "sqlPreview.ssl": true,
54
- "sqlPreview.sslVerify": true,
55
- "sqlPreview.maxRowsToDisplay": 1000,
56
- "sqlPreview.logLevel": "INFO" // Options: DEBUG, INFO, WARN, ERROR
109
+ "mcpServers": {
110
+ "sql-preview": {
111
+ "url": "http://localhost:8414/mcp"
112
+ }
113
+ }
57
114
  }
58
115
  ```
59
116
 
60
- ### Secure Password Management
117
+ You can also open the Extensions view, search `@mcp SQL Preview`, and install
118
+ the server into your user profile or current workspace from the MCP gallery.
119
+
120
+ ### Standalone Server
61
121
 
62
- For security, passwords are never stored in plain text.
122
+ For Claude Desktop, Cursor, CI jobs, or any headless MCP client, use the
123
+ standalone server:
124
+
125
+ ```json
126
+ {
127
+ "mcpServers": {
128
+ "sql-preview": {
129
+ "command": "npx",
130
+ "args": ["-y", "sql-preview", "--stdio"],
131
+ "env": {
132
+ "SQL_PREVIEW_CONNECTIONS": "[{\"id\":\"analytics\",\"name\":\"Analytics\",\"type\":\"postgres\",\"host\":\"localhost\",\"port\":5432,\"user\":\"analyst\",\"database\":\"warehouse\",\"password\":\"YOUR_PASSWORD\"}]"
133
+ }
134
+ }
135
+ }
136
+ }
137
+ ```
63
138
 
64
- 1. **Set Password**: Run the command `SQL Preview: Set Database Password` or click "Set Password" in the Settings UI.
65
- 2. **Clear Password**: Run `SQL Preview: Clear Stored Password`.
139
+ The MCP server exposes tools for:
66
140
 
67
- ## 🤖 Model Context Protocol (MCP) Integration (Beta)
141
+ | Tool | What it does |
142
+ | ------------------ | --------------------------------------------------- |
143
+ | `run_query` | Execute SQL and return typed JSON rows |
144
+ | `list_connectors` | Return supported connector types and setup schemas |
145
+ | `list_connections` | List configured connection profiles without secrets |
146
+ | `save_connection` | Add or update a connection profile |
147
+ | `test_connection` | Validate saved or unsaved connection settings |
148
+ | `list_schemas` | List schemas for a connection |
149
+ | `list_tables` | List tables within a schema |
150
+ | `describe_table` | Return column names and types |
151
+ | `get_tab_info` | Inspect daemon result tab state |
152
+ | `cancel_query` | Cancel a running query |
153
+ | `close_tab` | Close a daemon result tab |
68
154
 
69
- This extension includes a built-in MCP server that allows AI assistants (like Claude) to interact with your database.
155
+ Safe mode is on by default and restricts agents to read-only statements such as
156
+ `SELECT`, `SHOW`, `DESCRIBE`, `EXPLAIN`, `WITH`, and connector-specific metadata
157
+ queries.
70
158
 
71
- ### Enabling MCP
159
+ See the full [Claude Desktop setup guide](docs/engineering/guides/claude-desktop-setup.md)
160
+ and [daemon URL reference](docs/engineering/guides/daemon-url-reference.md) for
161
+ advanced configuration.
72
162
 
73
- 1. Open VS Code Settings.
74
- 2. Set `sqlPreview.mcpEnabled` to `true`.
75
- 3. (Optional) Set `sqlPreview.mcpSafeMode` to `true` (default) to restrict AI to read-only queries.
76
- 4. Restart the extension or run `SQL Preview: Restart Background Server`.
163
+ ---
77
164
 
78
- ### Available Tools
165
+ ## Configuration
79
166
 
80
- When enabled, the following tools are available to MCP clients:
167
+ Most users should use **SQL Preview: Manage Connections** instead of editing
168
+ settings JSON by hand.
81
169
 
82
- - `run_query`: Execute a SQL query.
83
- - `list_tables`: List tables in a schema.
84
- - `describe_table`: Show table schema.
85
- - `get_ddl`: Get the CREATE TABLE statement.
170
+ | Setting | Default | Description |
171
+ | ------------------------------- | -------------------------- | ---------------------------------------------------------- |
172
+ | `sqlPreview.activeConnectionId` | empty | Connection profile used for VS Code query execution |
173
+ | `sqlPreview.maxRowsToDisplay` | `500` | Max rows shown in the grid; full export is still available |
174
+ | `sqlPreview.fontSize` | `0` | Results grid font size in px; `0` inherits from the editor |
175
+ | `sqlPreview.rowHeight` | `normal` | Grid density: `compact`, `normal`, or `comfortable` |
176
+ | `sqlPreview.tabNaming` | `file-sequential` | Result tab naming strategy |
177
+ | `sqlPreview.alwaysRunInNewTab` | `false` | Always open query results in a new tab |
178
+ | `sqlPreview.mcpEnabled` | `false` | Enable the local MCP server for agent access |
179
+ | `sqlPreview.mcpSafeMode` | `true` | Restrict MCP query execution to read-only statements |
180
+ | `sqlPreview.telemetry.enabled` | `false` | Opt in to anonymous product telemetry |
181
+ | `sqlPreview.telemetryHost` | `https://us.i.posthog.com` | Advanced PostHog-compatible telemetry endpoint |
86
182
 
87
- ## Project Structure
183
+ Legacy connection settings such as `sqlPreview.host`, `sqlPreview.port`,
184
+ `sqlPreview.user`, `sqlPreview.catalog`, `sqlPreview.schema`, and
185
+ `sqlPreview.databasePath` remain available for migration and backward
186
+ compatibility.
88
187
 
188
+ ### Passwords and Secrets
189
+
190
+ Passwords entered through the VS Code connection manager are stored per
191
+ connection in VS Code Secret Storage, backed by the operating system keychain.
192
+ They are not written to `settings.json` or sent to the webview.
193
+
194
+ Use these commands when needed:
195
+
196
+ - **SQL Preview: Set Connection Password**
197
+ - **SQL Preview: Clear Connection Password**
198
+ - **SQL Preview: Manage Connections**
199
+
200
+ ### Telemetry
201
+
202
+ SQL Preview telemetry is off by default. If enabled, events are anonymous,
203
+ allowlisted, and used to improve setup, connector reliability, query workflows,
204
+ MCP adoption, and product quality. SQL Preview never sends SQL text, query
205
+ results, credentials, hostnames, database/schema/table/column names, file paths,
206
+ workspace names, usernames, environment variables, process arguments, raw error
207
+ messages, or stack traces.
208
+
209
+ Use **SQL Preview: Show Telemetry Status** to inspect the effective telemetry
210
+ state.
211
+
212
+ ---
213
+
214
+ ## Architecture
215
+
216
+ SQL Preview uses a local daemon model:
217
+
218
+ ```text
219
+ VS Code extension / MCP client / browser surface
220
+ |
221
+ v
222
+ SQL Preview daemon on localhost
223
+ |
224
+ v
225
+ Database connector
226
+ |
227
+ v
228
+ Your database
89
229
  ```
90
- sql-preview/
91
- ├── src/
92
- │ ├── extension.ts # Main extension entry point (Client)
93
- │ ├── server/ # Daemon process (Server)
94
- │ │ ├── Daemon.ts # Server entry point
95
- │ │ └── DaemonMcpServer.ts # MCP implementation
96
- │ ├── connectors/ # Database connectors (Trino)
97
- │ └── ui/ # Webview logic
98
- └── webviews/ # Frontend assets (React/HTML/CSS)
99
- ```
100
230
 
101
- ## Development
231
+ The daemon owns connection profiles, query execution, result tabs, MCP
232
+ transports, and browser/VS Code projections. That lets editor sessions and agent
233
+ sessions share the same local state while keeping credentials and execution on
234
+ your machine.
235
+
236
+ ---
237
+
238
+ ## Release Notes
239
+
240
+ See [Changelog.md](Changelog.md) for the full release history.
241
+
242
+ ---
243
+
244
+ ## Contributing
245
+
246
+ Contributions are welcome, especially new connector support, reliability
247
+ improvements, and documentation fixes. See [CONTRIBUTING.md](CONTRIBUTING.md)
248
+ for setup instructions and development workflow.
249
+
250
+ Found a bug? Open an issue on
251
+ [GitHub](https://github.com/fadnavismehul/sql-preview/issues).
252
+
253
+ ---
254
+
255
+ ## License
102
256
 
103
- 1. **Clone**: `git clone ...`
104
- 2. **Install**: `npm install`
105
- 3. **Build**: `npm run build`
106
- 4. **Debug**: Press `F5` to start the Extension Host.
257
+ MIT (c) 2026 [Mehul Fadnavis](https://github.com/fadnavismehul)