Internal, read-first SQL explorer for your organization's databases — with built-in PHI tokenization, an AI query assistant, a governed write-approval workflow, multi-database support, and per-environment capability-based access control.
One pre-configured place where every team member can query the databases they're allowed to reach, without juggling credentials or desktop clients — and without PHI ever leaving the building in the clear.
- Multi-database support — PostgreSQL, SQL Server (MSSQL), MongoDB, and Elasticsearch, each with a dialect-aware editor, autocomplete, query templates, and default result view.
- Monaco editor — syntax highlighting and schema-aware autocomplete (tables, columns, PK and 🔐 PHI markers; Mongo
db.collection.find()style; ES/_searchpaths). Language adapts to the connection type. - Multi-tab workspace — independent tabs, inline rename, per-tab schema selection, and run-selection-or-whole-query (Cmd/Ctrl+Enter).
- Schema browser — connections grouped by environment; lazy table/column tree with PK/type/PHI flags; double-click a table to open a
SELECT * … LIMIT 100tab; copy table metadata as JSON / DDL / text. - Database objects — procedures, functions, views and triggers (Postgres/SQL Server), MongoDB views, indexes and validation rules, and Elasticsearch index templates, ingest pipelines, aliases and ILM policies, with their full definitions, "Uses / Used by" (including the jobs that run them), "Compare with…" any other connection or a pasted version, and a drift report listing every object — and every SQL Server Agent / pg_cron job, matched by name on its steps and schedules — that differs between two environments.
- Scheduled jobs — SQL Server Agent and pg_cron jobs that run against the database: step commands, plain-language schedules, last outcome, next run and recent history. Propose a change (enable/disable, step command, schedule, …) as a governed job-change request.
- Results grid (AG Grid) — sort/filter/resize, type-aware cell coloring, table ↔ JSON view toggle, row count / exec time / truncation badges.
- Cell inspector drawer — click a long cell to open a docked read-only inspector (auto-detects JSON vs text); double-click to copy; hover for a peek.
- Local-timezone datetimes — ISO datetime cells show a your-time conversion alongside the original source value on hover.
- Query history — your last executed queries, one click to reload.
- Saved queries — save (shared by default), search, load into a new tab; used as few-shot examples by the AI assistant.
- Tab persistence — open tabs, active connection, and sidebar state survive a reload (results are not persisted).
- Export — download results as CSV or JSON (masking enforced and audited).
- PHI tokenization ("shield") — pattern-based column matching with four masking types: FULL (
********), PARTIAL (last 4 shown), HASH (tok_…deterministic), REDACT ([REDACTED]). - Per-environment enforcement — every production environment (any name containing "prod":
PROD,SUPER_PROD, …) is always tokenized and cannot be turned off; the rest of the masked list is configurable. QA/DEV return real values by default. alwaysMasked(locked) rules — never unmask regardless of role or shield state.- Audited unmasking — de-tokenizing requires a reason (and optional notes), is gated per-environment, and is logged with user, IP, session, and timestamp. Unauthorized attempts stay masked and are logged as denied.
- Write mode with a request → review → approval → execute lifecycle. Globally toggleable by admins.
- Two-person rule on production — writes to any production environment (any name containing "prod") always require a second approver and can never be direct-execute; other environments can be configured for direct write. The one exception is the admin override below.
- Admin override — an admin can run a pending write request without any approver (their own included), on any environment including production. A written reason is mandatory and the run is audited as
OVERRIDDEN/WRITE_OVERRIDE. Non-admins cannot; there is no capability list for it. - Bound to its connection — a request is bound to where its connection points when it is submitted (environment, type, host, port, database, username, default schema, URI, and the stored connection itself). If an admin edits any of those, or deletes and re-creates the connection under the same id, approving it is refused with a 409 until it is cancelled or rejected and resubmitted. Renaming the connection or rotating its password does not unbind it. Existing pending requests and drafts are bound to their connection as of the upgrade.
- Paired verify SELECT — every write request carries a read-only SELECT to preview affected rows before execution.
- Object changes — "Edit" a procedure, function, view or trigger and save it as a draft write request, then run it (direct-write environments) or submit it for approval from the request page; "Changing this … affects N objects and M jobs" shows first. Reviewers see a diff against the deployed version, approval refuses to run if that version changed meanwhile (409 — revise to re-base), and an executed change offers "Restore previous version" and "Copy as migration" for your migrations repo.
- AI safety review — verdict (Safe / Caution / Dangerous), blast-radius estimate, SELECT-matches-write check, and one-click suggested corrections.
- Single-statement, scoped writes only — one INSERT/UPDATE/DELETE (or Mongo/ES equivalent); UPDATE/DELETE must be scoped (WHERE required); transactional where the engine supports it.
- Save without running — "Save request" stores a request as a draft that executes nothing until someone submits or runs it, on any environment. This is also what the MCP endpoint creates, so an AI agent can propose a change but never make one.
- Full lifecycle audit — save, submit, AI review, approve/reject/admin override, execute/fail, cancel, revise & resubmit — each with an activity timeline.
- Natural-language → query for read and write modes, dialect-aware, with a table-selection pass for large schemas and few-shot examples pulled from saved queries.
- Schema, not results — Azure OpenAI receives schema metadata (tables, columns, types, keys, PHI flags) and, while Settings → Azure OpenAI → Include column values in AI context is on (the default), the distinct values of short text columns with at most 20 values that no PHI rule matches — e.g.
status: draft | placed | shipped, so queries use the stored spelling. Postgres reads those from planner statistics (pg_stats, no table scan); SQL Server samples them with a boundedSELECT DISTINCT. Never PHI, never query results or any other row data. Turn the setting off to send metadata only. Every generation is logged (prompt, response, model, tokens, latency) for admin review.
- Hosted MCP endpoint at
/api/mcp— agents discover connections, browse schema, and run read-only queries through the same API the UI uses, so capabilities, PHI tokenization, row caps and audit logging all apply unchanged. Configure with just a URL, username, and password; nothing to install. - Agents propose, humans dispose — an agent can save a write request as a draft (statement plus its verify SELECT); it cannot submit, approve or execute one, so nothing an agent writes reaches a database until a person acts on it in D-Pilot.
- Shareable documents that live next to the data — prose plus runnable read queries, opened as a tab from
/artifacts/:idby anyone who can log in. Each query block has its own Run button and its own results. - Rich explainer pages — besides markdown, a document can hold
htmlblocks: layout, cards and inline SVG diagrams, themed to match the app. They render in a sandboxed iframe with its own opaque origin and a no-network, no-script CSP, so a page written by a colleague or an agent cannot read the reader's session or call the API as them. Agents writing over MCP get a writing brief (short answer, how it works with a diagram, the evidence queries, the rule to remember). - Stores queries, never rows — running a block goes through the normal read path, so every reader gets their own capability checks, their own PHI tokenization and their own audit entry. An artifact cannot carry a snapshot past masking policy.
- Markdown prose, safely rendered — text blocks are GitHub-flavoured markdown (headings, bold, lists, tables). The renderer never emits raw HTML, so a document written by one colleague cannot script the app for everyone who opens the link.
- Archive, never delete — a shared link is somebody else's bookmark, so artifacts can only be archived, and archiving is reversible. Archived artifacts drop out of listings but their links still open.
- Agent-authored — the MCP endpoint can create, update and delete them, so an AI agent's analysis lands somewhere the whole organization can open instead of in one person's chat window.
- Capability-based access control — each user has an
isAdminflag plus four per-environment capability lists: read, unmask PHI, write, and approve. Admin implies all capabilities on all environments. - Audit log — every query, error, export, PHI unmask (and denial), and write-lifecycle event is recorded, with date/type filtering, free-text search (user, action, SQL, connection), paging, automatic 30-day archival to a separate database, and audited CSV export (up to 14 days / 10,000 entries at a time). Users can export their own query history the same way.
- Usage analytics — admin dashboard: users, DAU/WAU/MAU, query volume/latency, AI usage and success rate, PHI unmasks, top users, per-connection activity.
- Read-only enforcement — the read path blocks all DML/DDL; writes only ever go through the governed write workflow (a separate executor).
- White-label branding — custom app name, logo (light/dark), and favicon via environment variables.
- Installable app (PWA) — install to the desktop or home screen for a standalone window with an identical UI; the manifest picks up
APP_NAME, and new deploys prompt to reload. No API response is ever cached, so PHI never reaches on-disk storage. See Install as an App.
| Layer | Technology |
|---|---|
| Frontend | React 19, TypeScript, Vite, Mantine UI v8, Monaco Editor, AG Grid, Zustand |
| Backend | Node.js, Express, TypeScript |
| App Database | SQLite (via better-sqlite3, WAL mode) |
| Auth | JWT (bcrypt + jsonwebtoken) |
| AI | Azure OpenAI (optional) |
# Install dependencies
npm install
# Copy and configure environment
cp .env.example .env
# Edit .env with your settings (see Configuration below)
# Development (hot-reload client + server)
npm run dev
# Production build
npm run build
npm startBy default, the dev client runs at http://localhost:3100 and the server at http://localhost:3101.
npm run dev:db # needs Docker; re-run any time to reset the data
npm run dev:db:down # stop themThis starts three Postgres servers — DEV on localhost:5433, QA on 5434, PROD on
5435 (user and password dpilot) — seeds each with sample data from
scripts/seed-local.sql, and adds them as connections. The environments differ on
purpose: more rows in QA and PROD, an unreleased function version and an audit trigger
that PROD doesn't have yet (so the drift report has something to show), and pg_cron
jobs, one of them paused in PROD. Restart a running server to pick up the connections.
Both ports are configured in .env:
| Variable | Purpose | Default |
|---|---|---|
PORT |
Server port (also used as proxy target in dev) | 3101 |
VITE_PORT |
Dev client port | 3100 |
By default D-Pilot assumes it owns the root of whatever domain it is served on
(https://d-pilot.internal/). If a reverse proxy instead mounts it under a
prefix of a shared domain — https://intranet.example/d-pilot — set BASE_PATH.
Read "The prefix is not a security boundary" below before choosing that domain:
sharing one with another app has consequences a path prefix does not contain.
BASE_PATH=/d-pilotThen build and start with that variable set:
BASE_PATH=/d-pilot npm run build # bakes the prefix into the asset URLs
BASE_PATH=/d-pilot npm start # mounts Express at the same prefixBoth steps matter, and they have to agree. Vite writes the prefix into every
<script>, stylesheet and icon URL at build time; Express reads it at startup
and mounts its API, its manifest and the built client there. Putting it in .env
is the reliable way to keep them in step — deploy.sh builds and restarts in one
go, and both halves read the same file. Changing BASE_PATH requires a
rebuild, not just a restart; a restart alone leaves a client full of URLs
pointing at the old prefix.
Moving an existing deployment off the domain root leaves old bookmarks, old
links and any service worker registered at the root scope still asking for /.
Express would answer those with a bare Cannot GET /, which reads as an outage,
so when BASE_PATH is set the server redirects such requests to the prefix
instead, path and query intact. API paths are deliberately excluded — a stale
client gets an honest 404 rather than a redirect that makes it look half-alive.
A cached service worker still serves its own shell, though, so a browser that
used the old root URL needs that registration cleared before the redirect can
run at all.
Because the server mounts itself under the prefix, the proxy is a plain pass- through with no path rewriting:
location ^~ /d-pilot/ {
proxy_pass http://10.0.0.5:3101; # no trailing slash: pass the path through as-is
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}Two things are easy to get wrong here. A trailing slash on proxy_pass
strips the prefix before it reaches D-Pilot, which now expects to see it — leave
it off. And if the same server block also serves another app at the root, ^~
is required rather than a plain prefix: a regex location for static file
extensions takes priority over a plain prefix location, so without it every
/d-pilot/assets/*.js request is answered by the root app instead.
In local development, npm run dev reads .env for both halves and needs
nothing extra. npm run dev:local does not: the server half is pinned to
.env.dev while the Vite half reads .env and .env.dev, so a BASE_PATH
set only in .env serves the client under the prefix and proxies to a server
still mounted at the root — every API call 404s. Set it in both files.
What this does not cover is a deployment that cannot set BASE_PATH at build
time — a prebuilt artifact, say. There is no runtime switch for it, because the
prefix is inside the emitted bundle filenames and the service worker's scope.
BASE_PATH puts D-Pilot on its own path, but browser storage is scoped per
origin. D-Pilot keeps the session JWT, the signed-in user and the persisted
tab workspace — which holds the SQL you have been writing — in localStorage,
so every one of those is readable by any script running anywhere else on the
same domain, and D-Pilot can read theirs. A cross-site scripting flaw in an
unrelated app at / is therefore a full session takeover of a tool that reaches
PHI, with no flaw in D-Pilot at all.
Mount D-Pilot under a prefix of a domain whose other occupants you trust as much as D-Pilot itself — ideally a dedicated internal hostname, which is what the default root deployment gives you for free. This is the same reasoning that keeps API responses out of the service worker's Cache Storage: the protection D-Pilot applies to a query result is worth nothing once the data is somewhere the browser hands to anyone sharing the origin.
Configuration comes in three kinds. Copy .env.example to .env; it is laid out the
same way. Every variable is described in docs/environment-variables.md.
Bootstrap — env only. Needed before the app database exists or baked into the
client build; change them in .env and restart (BASE_PATH: rebuild).
PORT=3101
VITE_PORT=3100
NODE_ENV=production
# BASE_PATH=/d-pilot # see "Serving under a sub-path"
# DATA_DIR=data # app database + settings.key
# JWT — CHANGE THIS to a random string (e.g. openssl rand -hex 32)
JWT_SECRET=<your-random-secret-here>
# Default admin password (only used on first run to seed the admin user)
DEFAULT_ADMIN_PASSWORD=<strong-password>
# Encrypts secrets stored in the app database. Unset = a key generated into DATA_DIR/settings.key
# SETTINGS_ENCRYPTION_KEY=<any-long-random-string>
# HTTPS_PROXY=http://proxy.example:8080 # outbound proxy for the Azure OpenAI call
# Operator ceilings — can only LOWER a limit's built-in cap (shown here)
# MAX_ROWS_LIMIT=1000000
# MCP_MAX_ROWS_LIMIT=1000000
# QUERY_TIMEOUT_MS_LIMIT=2147483647
# SCHEMA_CACHE_TTL_HOURS_LIMIT=8760Operator ceilings. A *_LIMIT caps what an admin may save for that limit in
Settings: a higher value is refused ("MAX_ROWS must be ≤ 500 (set by the server
operator)"), and Settings shows the max next to the field. Lowering a ceiling below a
value already saved (or set in .env, or the default) clamps it — nothing breaks. A
ceiling above the built-in cap, zero, negative or not a number is ignored with a
warning.
Initial values / fallbacks — overridden by Settings. Branding and limits. Admins
change these in Settings → Branding & Limits without a restart. Precedence is
saved in Settings > .env > built-in default; once a value is saved in Settings,
editing .env no longer changes it. Reset drops the saved value so .env (or the
default) applies again.
# Branding
APP_NAME="Your App Name"
LOGO_URL=/logo/your-logo.svg # dark-ink mark, shown on the light theme (empty = text-only)
LIGHT_LOGO_URL=/logo/your-logo-light.svg # light-ink mark, shown on the dark theme and the login panel
FAVICON_URL=/logo/favicon.svg # optional
# LOGIN_TAGLINE="Internal query tool" # login-page lines under the app name;
# LOGIN_SUBTITLE="HIPAA · PHI tokenized" # save one empty in Settings to hide it
# NETWORK_HINT="Connect to the VPN and retry." # shown when a database can't be reached, and in
# # the server-unreachable banner and sign-in error
EMAIL_DOMAIN=yourcompany.com # enforced on user creation, used for the default admin seed
# APP_BASE_URL=https://d-pilot.internal # origin for artifact links in MCP output
# Limits
JWT_EXPIRES_IN=24h
MAX_ROWS=10000 # hard cap on returned rows
QUERY_TIMEOUT_MS=90000 # per-query timeout
MCP_MAX_ROWS=1000 # rows per MCP agent query (agents may raise per call)
SCHEMA_CACHE_TTL_HOURS=24 # schema cache (autocomplete + AI); hours, 0 disablesSettings only — no env var. Database connections (Settings → Connections) and
the AI assistant (Settings → Azure OpenAI: endpoint, key, deployment, model, API
version, TLS) live in the app database and are never read from .env. A fresh install
starts with no connections; the first admin adds them.
Bulk import. Settings → Connections → Import takes a JSON array of connections
(or a single connection object) and previews each row before anything is saved. It is
all-or-nothing and create-only: an invalid item, a repeated id or an id that already
exists stops the whole import, and an existing connection is never overwritten. API:
POST /api/settings/connections/import with { "connections": [...] } (up to 200):
[
{
"id": "qa-pg",
"name": "QA PostgreSQL",
"env": "QA",
"type": "postgres",
"host": "your-db-host",
"port": 5432,
"database": "your_database",
"username": "your_user",
"password": "your_password",
"schema": "public"
}
]Upgrading from an
.env-configured install:DBFORGE_CONNECTIONSand theAZURE_OPENAI_*variables are no longer read. Connections and AI settings an earlier version already imported or saved are kept. Anything that only lived in.env: re-create connections via Settings → Connections → Import (paste the old JSON array as-is) and re-enter the AI settings in Settings → Azure OpenAI. Then delete those lines from.env.One change to the JSON: a MongoDB
username/passwordmust be the raw value (p@ss, notp%40ss). D-Pilot now percent-encodes them itself when it builds the connection string, so a value that was escaped by hand for the old.envwould be escaped twice and fail to log in. A fulluriis used as-is, unchanged.
Secrets are encrypted at rest. Connection passwords/URIs and AZURE_OPENAI_KEY are
stored AES-256-GCM encrypted, with SETTINGS_ENCRYPTION_KEY or — if unset — a key
generated once into DATA_DIR/settings.key. Settings never shows a stored secret back,
and a kept password cannot be redirected: editing a connection keeps it only when the
change is limited to name, env or schemas — anything else (host, port, username,
database, …) needs it typed again, as does changing the AI endpoint or TLS setting.
A stored password or URI can be removed with Clear in the connection editor.
Back up settings.key along with the database, but store it separately (anyone
holding both can decrypt the secrets). Lose it and the app still starts, but every
stored secret must be re-entered in Settings.
One process per data directory. D-Pilot runs as a single Node process. Saving a
connection or a setting invalidates pools and caches only in the process that handled
the save, so several processes or replicas sharing one DATA_DIR would keep serving
stale connections and limits — that deployment shape is unsupported. Scale up the one
instance instead.
Note: PHI masking and the write workflow are configured in-app too — masked environments, PHI rules, write-mode toggle, and direct-write environments are stored in the SQLite app database and have no env var.
| Type | Required fields |
|---|---|
postgres |
host, port, database, username, password, schema (optional) |
mssql |
host, port, database, username, password |
mongodb |
uri (full connection string) |
elasticsearch |
host, port, username, password, and schema set to http or https (used as the protocol) |
D-Pilot reads objects and jobs with the connection's own login, so what it can show is a deployment decision. The minimum grants:
| To | SQL Server | PostgreSQL |
|---|---|---|
| List procedures, functions, views, triggers | CONNECT (catalog views list what the login can see) |
none — the catalog is public |
| Read their definitions | VIEW DEFINITION on the schema or database (else "definition not available") |
none (pg_get_functiondef, pg_get_viewdef, pg_get_triggerdef) |
| Change one through an object change | ALTER on the object's schema (plus CREATE PROCEDURE/FUNCTION/VIEW to create) |
owner of the object (and CREATE on the schema to create) |
| Read jobs | SQLAgentReaderRole in msdb |
USAGE on schema cron + SELECT on cron.job, cron.job_run_details |
| Change jobs | SQLAgentOperatorRole in msdb (or job ownership) and SHOWPLAN in the database (to check step commands), plus a D-Pilot Change jobs grant |
owner of the job (or superuser) for cron.alter_job, plus Change jobs |
MongoDB needs listCollections and listIndexes (the built-in read role); Elasticsearch
needs the manage_index_templates, manage_ingest_pipelines, read_ilm and
view_index_metadata privileges to list templates, pipelines, ILM policies and aliases.
Without the job grant, the explorer says which grant is missing rather than failing.
Keep job steps thin: put the logic in a procedure and have the step only EXEC/CALL it.
Then most fixes are object changes, with a diff and a rollback, and the job itself rarely
changes. A job change D-Pilot writes is one action (enable/disable, rename, description,
edit/add/delete a step, change a schedule — not a schedule shared with other jobs, and on a job that also runs steps on another database only this database's own step commands). A step command is parsed by the database itself (the Postgres
parser; SQL Server compiles it under SHOWPLAN_XML without running it): it may call the
database's own procedures and functions and run scoped INSERT/UPDATE/DELETE, but never DDL,
dynamic SQL, an unscoped write, a built-in or extension routine that runs SQL from a string,
or anything that reads outside the database. CmdExec/PowerShell/SSIS steps can't be changed,
and every refusal is audited as JOB_CHANGE_REFUSED.
Access is capability-based and scoped per environment (typically DEV, QA, UAT,
STG, PROD — whatever envs your connections use; see Custom environments).
Each user has an isAdmin flag plus five capability lists, managed from Settings → User Management:
| Capability | Grants |
|---|---|
Read (allowedEnvironments) |
Query connections in those environments |
Unmask PHI (unmaskEnvironments) |
De-tokenize PHI (still audited) in those environments |
Write (writeEnvironments) |
Author write requests for those environments |
Approve (approveEnvironments) |
Approve others' write requests in those environments |
Change jobs (jobEnvironments) |
Raise requests that change scheduled jobs there (with write and read) |
Admin implies every capability on every environment. Production safety rails (mandatory PHI tokenization and two-person write approval) always apply regardless of capabilities — except that an admin can override approval on a single request (see Write workflow) — on every environment whose name contains "prod" — see Custom environments.
The environment list is not hardcoded — it is derived from the env values of the
configured connections. Adding a connection with a new env (in Settings →
Connections) is all it takes:
SUPER_PROD then shows up on its own in the connection tree, the four
capability pickers in Settings → User Management, the PHI masked-environment toggles
and the write policy. Only environments the deployment actually has are accepted by the
API, so a stale name can't be granted to anyone.
Notes:
- Custom names sort after
PRODand are treated as the most sensitive. - Any environment whose name contains "prod" gets the full production rails —
PROD,SUPER_PRODandPREPRODalike are always PHI-tokenized and can never be direct-write (every change needs a second approver). Both toggles for them in Settings are locked. Naming a production environment something new does not opt it out. - Existing users don't gain a new environment automatically; grant it per user.
D-Pilot hosts a read-only (see the write-request exception below) MCP endpoint at
/api/mcp, so AI agents can query the same databases under the same rules as the UI.
It runs inside the existing server process — nothing extra to deploy, install, or clone.
Agents just point at the URL everyone already uses.
Its tools call D-Pilot's own REST API over loopback, so environment capabilities, PHI
tokenization, row limits and audit logging are enforced exactly as they are for the UI and
cannot be bypassed. Every agent query lands in the audit log under its service account,
marked via MCP (the audit drawer's Via field, and the source column of both CSV
exports), so agent traffic can be told apart from people using the UI.
| Tool | Does |
|---|---|
whoami |
Which account is connected and which environments it may read |
list_connections |
Databases available, one CSV line each (optional env filter) |
list_schemas |
Schemas on a connection (Postgres/SQL Server) |
list_tables |
Tables, collections or indices; withColumns adds every table's columns in one call |
describe_table |
Columns, types, keys and FK targets of one table or several (tables) |
list_objects |
Procedures, functions, views and triggers (overloads separately); MongoDB views, indexes, validators; Elasticsearch templates, pipelines, aliases, ILM |
get_object_definition |
Full source of one of those objects, read live |
get_object_dependencies |
What an object uses and what uses it |
compare_objects |
Drift report: objects and jobs that differ between two connections |
list_jobs |
SQL Server Agent / pg_cron jobs on the database: schedule, last outcome, next run |
get_job |
One job's step commands, schedules and recent runs |
run_query |
Runs a read-only query on one connection or several (connectionIds); compact CSV |
create_artifact |
Publishes a shareable document (rich page + runnable read queries), returns its link |
update_artifact |
Edits an artifact the service account created |
get_artifact |
Reads one artifact's full body |
list_artifacts |
Artifacts visible to the account (optional search) |
archive_artifact |
Archives (or restores) an artifact the service account created |
create_write_request |
Saves a draft change request for a human to review — it never runs |
get_write_request |
Reads one request back, including the AI safety review a human ran on it |
update_write_request |
Edits a draft the service account saved — drafts only, and it stays a draft |
Token cost: an agent pays for every character a tool returns, for as long as it stays in
its context, so tool output is kept compact. run_query returns rows as CSV under a one-line
status (an empty field is NULL, "" an empty string, nested values JSON) — about half the
tokens of pretty JSON on real queries. Cells over 300 characters are cut and marked
…[+N chars] (an agent raises maxCellChars to read a payload in full), and a result that
would exceed ~25k tokens stops at whole rows with advice to aggregate or page. format: "json"
returns one compact object per row instead. To compare environments an agent passes connectionIds
(up to 6): the same query runs on each — every one its own checked, masked and audited
/query/execute — and comes back in one labelled result. Schema tools answer in the same spirit:
describe_table writes one line per column (- id: bigint [PK, NOT NULL]) instead of a JSON
object per column, and list_tables names each schema once. The server log has one line per tool call with the
size it returned ([mcp] run_query 1840 chars (~460 tokens) 12ms).
Database writes are deliberately not exposed — those stay in the write-approval workflow, where a human reads the paired verify SELECT and a second person approves.
create_write_request is how an agent proposes a change without being able to make one. It
saves a DRAFT: title, the write statement, and the verify SELECT that previews the affected
rows, validated by exactly the same rules the UI applies. A draft executes nothing — not even
on an environment configured for direct writes — until a person opens it in D-Pilot and clicks
Submit for approval or Run now. There is no tool to submit, approve, run or delete one,
and the account still needs Write capability on the target environment to save a draft at all.
Submitting also makes the submitter the requester, so nobody can have an agent draft a change,
submit it, and then approve their own work.
get_write_request closes the review loop: after someone clicks Review with AI on the
request, the agent can read the verdict, the risks and the suggested statements back, and fix
the draft with update_write_request. Editing is drafts only — the moment a person submits,
approves or runs a request, the agent can no longer change what they are signing off on — and an
edited draft stays a draft, so revising one can never become a way to run it.
The artifact tools are the one exception to read-only, and only because they touch no target
database: an artifact holds prose and unexecuted read queries in D-Pilot's own SQLite, an
agent may only edit the ones its own account created, and nothing it writes reaches a database
until a human opens the artifact and runs a block as themselves. Set APP_BASE_URL so the
tools hand back clickable links instead of bare /artifacts/<id> and /write-requests/<id>
paths.
-
Pick the account. Either create a service account in Settings → User Management, or let each person connect with their own login — then every agent action is audited under that person and bounded by their capabilities. Grant only the Read capability, on only the environments agents should reach — not an admin. Add Write on an environment only if agents should be able to save draft write requests there (they still cannot run one).
-
Connect the agent — by hand, in your own terminal. Not through an agent: don't use Claude Code's
!prefix or paste these into a chat, because anything an AI sees ends up in its context and its transcript. The in-app/docs/mcppage (account menu → Connect an AI agent) builds these commands for you: your URL and username are filled in, you type the password on the page, and the browser encodes it (it is never sent anywhere). The screen shows the credential masked; only the copied text carries it. It picks macOS / Linux or Windows from your browser, and you can switch.Below,
<base64 of user:password>isbase64("username:password")— the setup page builds it for you. The commands contain that credential, so it ends up in your shell history and in Claude's config: don't share them.Claude Code, through the local bridge (recommended — see Behind a VPN?). Needs Node 18+. Download the bridge, register it, then restart Claude Code and check that
claude mcp listshows d-pilot as Connected.macOS / Linux (bash, zsh):
mkdir -p ~/.d-pilot && curl -fsSo ~/.d-pilot/mcp-bridge.mjs 'https://d-pilot.example.com/mcp-bridge.mjs' claude mcp add -s user -e 'DPILOT_MCP_URL=https://d-pilot.example.com/api/mcp' \ -e 'DPILOT_MCP_AUTH=Basic <base64 of user:password>' -t stdio d-pilot node ~/.d-pilot/mcp-bridge.mjs
Windows (PowerShell 5.1 or 7):
New-Item -ItemType Directory -Force "$HOME\.d-pilot" | Out-Null; Invoke-WebRequest -UseBasicParsing -Uri 'https://d-pilot.example.com/mcp-bridge.mjs' -OutFile "$HOME\.d-pilot\mcp-bridge.mjs" claude mcp add -s user -e 'DPILOT_MCP_URL=https://d-pilot.example.com/api/mcp' -e 'DPILOT_MCP_AUTH=Basic <base64 of user:password>' -t stdio d-pilot node "$HOME\.d-pilot\mcp-bridge.mjs"
Then ask the agent to "call the d-pilot whoami tool" — a prompt like that carries no credential. If Node comes from nvm or another version manager, use the absolute path from
command -v node(Windows:(Get-Command node).Source) instead ofnode. Ifd-pilotalready exists, runclaude mcp remove d-pilot -s userfirst.-t stdioends the list of-evalues, so the command needs no--(which PowerShell has not always passed on to native programs).Claude Code, direct HTTP (no Node). Registers the endpoint itself. Simpler, but while D-Pilot is unreachable the server just fails with no reason given, and you reconnect it by hand. The same line works in bash, zsh and PowerShell:
claude mcp add --scope user --transport http d-pilot 'https://d-pilot.example.com/api/mcp' --header 'Authorization: Basic <base64 of user:password>'
Claude Desktop launches local servers only, so it runs the same bridge — and the bridge adds itself to Desktop's config, with absolute paths to this
nodeand to itself, so there is no JSON to edit and no path to look up. In this order:- Download the bridge as above.
- Fully quit Claude Desktop. It rewrites its config while it runs, so a change made then is lost. Windows: right-click the tray icon, then Quit — closing the window is not enough. macOS: Cmd+Q. Linux: quit from the tray or menu.
- Run the install command:
node ~/.d-pilot/mcp-bridge.mjs --install-desktop 'https://d-pilot.example.com/api/mcp' 'Basic <base64 of user:password>'
node "$HOME\.d-pilot\mcp-bridge.mjs" --install-desktop 'https://d-pilot.example.com/api/mcp' 'Basic <base64 of user:password>'
- Start Claude Desktop: Settings → Developer lists d-pilot.
It sets
mcpServers["d-pilot"]inclaude_desktop_config.json(macOS~/Library/Application Support/Claude/, Windows%APPDATA%\Claude\, Linux~/.config/Claude/;DPILOT_DESKTOP_CONFIGoverrides it), keeps everything else, and saves the previous file asclaude_desktop_config.json.bak. The Microsoft Store version of Claude Desktop keeps its config in its package folder instead,%LOCALAPPDATA%\Packages\Claude_<id>\LocalCache\Roaming\Claude\; the command finds it (anyClaude_*package; of several, the one that already has a config) and prints the path with "(Microsoft Store version)". It warns if Claude Desktop looks like it is still running (Windows matchesclaude.exe, which a native Claude Code install shares). A file it cannot parse is left untouched. It recordsnodeasPATHfinds it (e.g./opt/homebrew/bin/node), so Homebrew upgrades keep working; with nvm, whose path changes per version, run it again after switching versions. With Node 22.15 or newer it also adds--use-system-ca, so the bridge trusts the OS certificate store as the browser does. A symlinked config is updated in place. On Windows it needs%APPDATA%(orDPILOT_DESKTOP_CONFIG) unless it finds the Store version.Any other MCP client works the same way: run the bridge as a stdio server with
DPILOT_MCP_URLandDPILOT_MCP_AUTH(Basic <base64 of user:password>), or point an HTTP client at/api/mcpwith anAuthorization: Basic …header.
Why Basic auth: MCP clients can send static headers but cannot run D-Pilot's
username/password login flow, so /api/mcp accepts the credentials directly and exchanges
them for a normal JWT internally (kept in memory, never on disk, refreshed automatically).
Because the credentials cross the network on every request, serve D-Pilot over HTTPS if
agents connect from other machines — see the reverse-proxy section below.
Optional server-side setting:
| Variable | Default | Purpose |
|---|---|---|
MCP_MAX_ROWS |
1000 |
Rows returned per query. Agents are told this default (via whoami and the run_query schema) and can raise it per call with limit; MAX_ROWS remains the hard ceiling. |
APP_BASE_URL |
(unset) | The origin users browse D-Pilot on, used to build clickable artifact and write-request links in tool output. Just the origin — BASE_PATH is appended for you, and an origin that already spells the prefix out is left as written. Unset means agents return a bare /artifacts/<id> path, sub-path included. |
PHI: the endpoint never sends the unmask headers, so tokenized columns stay tokenized for
agents regardless of the account's capabilities. run_query names the tokenized columns so an
agent doesn't mistake mask characters for real values. Unmasking stays a UI-only action that
requires a human-supplied reason.
Revoking access: delete (or change the password of) the service account. Note this stops
new logins but does not kill a token already issued — as everywhere else in D-Pilot, a JWT
stays valid until it expires, so revocation takes effect within JWT_EXPIRES_IN (24h by
default). Lower that value if you need a tighter window.
If D-Pilot is only reachable over a VPN, an agent pointed straight at the URL just times out while the VPN is off: the server shows as failed with no reason given, and stays failed until you reconnect it by hand. No request reaches D-Pilot, so D-Pilot cannot explain anything.
That is what the bridge in the setup steps above is for. D-Pilot serves it at
/mcp-bridge.mjs (under BASE_PATH too): one file, Node 18+, no dependencies, configured by
DPILOT_MCP_URL and DPILOT_MCP_AUTH. The agent launches it as a local (stdio) server and it
relays to /api/mcp. It always starts, and while D-Pilot is unreachable it offers a single
dpilot_status tool that tells the agent (and so you) that D-Pilot is probably fine and your
network/VPN can't reach it. It checks D-Pilot's health every 10 seconds and, the moment the
VPN is back, tells the agent to re-list its tools — the real tools come back without a
reconnect.
With the VPN off, the agent sees only dpilot_status, and a call already under way returns
"D-Pilot at https://d-pilot.example.com can't be reached from this machine (…). D-Pilot itself
is probably running — check your network or VPN connection." Turn the VPN on and the full tool
list is back within about 10 seconds. Bad credentials are reported as such, not as an outage.
- Any answer from the health check except 502/503/504 counts as reachable, and
tools/listalways tries D-Pilot itself, so a wrong guess never hides the tools for good. - A captive portal or VPN login page answering in D-Pilot's place is reported as unreachable, with that as the reason.
- An untrusted HTTPS certificate is reported as configuration, not an outage: see Troubleshooting.
- d-pilot doesn't show up in Claude Desktop. Its config was most likely changed while it was
running, and it wrote its own copy back. Quit it fully (Windows: right-click the tray icon,
then Quit), run
--install-desktopagain, then start it. For the Microsoft Store version, check the path the install command printed (under%LOCALAPPDATA%\Packages\Claude_*). - Logs. Windows:
%LOCALAPPDATA%\Claude\logs\mcp-server-d-pilot.log, or under the Store package folder for the Microsoft Store version. macOS:~/Library/Logs/Claude/mcp-server-d-pilot.log. UNABLE_TO_GET_ISSUER_CERT_LOCALLYor another certificate error. A VPN or proxy that inspects HTTPS re-signs traffic with its own certificate, and Node doesn't use the OS certificate store by default. With Node 22.15 or newer, add--use-system-cabefore the bridge path (--install-desktopadds it for you; run it again after upgrading Node). Otherwise setNODE_EXTRA_CA_CERTSto that CA's PEM file in the bridge'senv.- Off the VPN. Through the bridge, the agent is told D-Pilot can't be reached, and the tools come back by themselves when you reconnect. A direct HTTP setup just times out; reconnect it by hand.
D-Pilot is a Progressive Web App, so it can be installed as a standalone desktop or home-screen app. The installed app is the web app, unchanged — same layout, same routes, same behavior — just in its own window without browser chrome.
Installing. In Chrome or Edge, use the install icon in the address bar, or the Install button in the footer (it appears only while the browser reports the app as installable, and disappears once installed). On iOS, use Safari's Share → Add to Home Screen.
A service worker requires a secure context: HTTPS, or localhost. Behind the Nginx
setup below with a certificate, this works out of the box; over plain http://<lan-ip> the
app still runs normally but cannot be installed.
Branding. The manifest is rendered by Express at /manifest.webmanifest from
APP_NAME, so the installed app carries your deployment's own name. The icons are the
bundled PNGs in public/ (pwa-192.png, pwa-512.png, pwa-maskable-512.png,
apple-touch-icon.png) — installers require raster icons at declared sizes, so unlike
LOGO_URL they are not taken from a URL. To use your own mark, either replace those files
or edit scripts/generate-pwa-icons.mjs and run:
npm run icons:pwaUpdates. After a deploy, open clients show a New version available notification with a Reload button. Nothing reloads on its own — an unattended reload would discard open editor tabs and any in-flight query.
What is cached — and what is deliberately not. Only the app shell is cached (HTML, JS, CSS, icons, fonts; ~2.5 MB), plus the Monaco editor and its language workers fetched on first use (~10 MB, kept out of the install so it stays lean).
No API response is ever cached. Query results, schema listings, saved queries, exports and audit records all carry PHI, and Cache Storage is unencrypted on disk and survives a logout. Every
/apicall goes to the network every time, which is enforced by a test (vite.pwa.config.test.ts). The practical consequence: the installed app is not usable offline — it will load and show its shell, but running a query needs the server. Offline write queueing is likewise absent by design, since replaying writes later would reorder the write workflow's audit trail.
The service worker is disabled in npm run dev (it would serve stale modules and break
HMR). Verify PWA behavior against a production build — npm run build && npm start.
- SQLite database created at
data/dbpilot.sqlite(WAL mode) - Default admin user seeded:
admin@<EMAIL_DOMAIN>(admin@example.comwhenEMAIL_DOMAINis unset) withDEFAULT_ADMIN_PASSWORD; as an admin it has every capability on every environment - Default PHI masking rules seeded (name / DOB / phone / email / address / ZIP patterns, PARTIAL masking)
- Default app settings seeded: PHI masked on
PROD, write mode enabled, direct-write onDEV - No connections — log in as the admin and add them in Settings → Connections (or Import a JSON array)
- Unless
SETTINGS_ENCRYPTION_KEYis set, a secrets key generated atdata/settings.key
git clone <repo-url> /opt/d-pilot
cd /opt/d-pilot
npm installnpm run buildThis produces:
dist/client/— optimized frontend (HTML, JS, CSS)dist/server/— compiled backend
npm startThe app will be available at http://<server-ip>:<PORT> (default 3101, configurable via .env).
If you set LOGO_URL=/logo/your-logo.svg, place the file at:
mkdir -p public/logo
cp /path/to/your-logo.svg public/logo/your-logo.svgThe app ships its own faces (Archivo, Inter and JetBrains Mono, as variable
woff2 under public/fonts/) and never requests a font CDN, so an air-gapped
deployment needs nothing here. To swap in your own, drop the files alongside
them and point the three family tokens at the new names:
mkdir -p public/fonts/YourFace
cp /path/to/YourFace-*.woff2 public/fonts/YourFace/
# then: add an @font-face to src/styles/fonts.css and set
# --font-disp / --font-body / --font-mono in src/styles/tokens.cssThese directories are gitignored — they won't be pushed back to the repo.
Create /etc/systemd/system/d-pilot.service:
[Unit]
Description=D-Pilot Internal Query Tool
After=network.target
[Service]
Type=simple
User=www-data
WorkingDirectory=/opt/d-pilot
ExecStart=/usr/bin/node dist/server/index.js
Restart=on-failure
RestartSec=5
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.targetEnsure the www-data user owns the application directory:
sudo chown -R www-data:www-data /opt/d-pilotEnable and start:
sudo systemctl daemon-reload
sudo systemctl enable d-pilot
sudo systemctl start d-pilot
# Check status
sudo systemctl status d-pilot
# View logs
sudo journalctl -u d-pilot -fTo serve on port 80/443 or add SSL, put Nginx in front.
Install: sudo apt install nginx (Ubuntu/Debian)
Create /etc/nginx/sites-available/d-pilot:
server {
listen 80;
server_name _; # or your domain/IP
location / {
proxy_pass http://127.0.0.1:3101;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
}
}sudo ln -s /etc/nginx/sites-available/d-pilot /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginxNow accessible at http://<server-ip> (port 80).
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d your-domain.com# If using Nginx (port 80/443)
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# If accessing Node directly (port 3101)
sudo ufw allow 3101/tcpcd /opt/d-pilot
git pull
npm install
npm run build
# Restart the service
sudo systemctl restart d-pilot # systemd
# or
pm2 restart d-pilot # pm2The SQLite database (
data/dbpilot.sqlite) persists across updates. Users, saved queries, PHI rules, audit logs, write requests, and settings are preserved.
The stateful files live in data/ — back them up regularly:
cp data/dbpilot.sqlite data/dbpilot-backup-$(date +%Y%m%d).sqlite
# audit_archive.sqlite holds audit entries older than 30 days
cp data/audit_archive.sqlite data/audit_archive-backup-$(date +%Y%m%d).sqliteBack up data/settings.key too (unless you use SETTINGS_ENCRYPTION_KEY), but keep the
copy apart from the database backups: it decrypts the connection passwords and AI key
stored in dbpilot.sqlite. Without it a restored database works, but every stored secret
has to be re-entered in Settings.
| Issue | Fix |
|---|---|
EADDRINUSE on startup |
Another process is using the port. lsof -i :3101 to find it |
| Database connection errors | Verify the server can reach DB hosts: telnet <host> <port> |
| AI assistant returns 503 | Fill in Settings → Azure OpenAI, then Test Connect |
| Logo not showing | Check file exists at public/logo/ and LOGO_URL matches the path |
| Forgot admin password | Delete data/dbpilot.sqlite and restart — re-seeds from .env |
Permission denied on data/ |
chown -R www-data:www-data /opt/d-pilot/data |
{ "id": "sp-pg", "name": "Super Prod PostgreSQL", "env": "SUPER_PROD", "type": "postgres", … }