MCP Server & Clients
Connect Claude Code or Codex to DBVision's Streamable HTTP MCP server with OAuth 2.1, consent, and per-client grants.
DBVision exposes a remote MCP server at POST /mcp secured by OAuth 2.1 (Better Auth). External AI clients such as Claude Code and Codex can inspect schemas and run read-only queries according to each connection's AI data mode and per-client grant.
Prerequisites
- Set
BETTER_AUTH_URLto the public origin your browser and MCP client reach (for examplehttps://dbvision.example.comorhttp://localhost:3000locally), with scheme and host only. HTTPS is required outside loopback. - Restart DBVision after setting
BETTER_AUTH_URL. When unset, DBVision does not serve/mcpor OAuth discovery routes. - Ensure you have a DBVision user account.
Connect Claude Code
claude mcp add --transport http dbvision https://dbvision.example.com/mcp
claude mcp login dbvisionUse --scope user to share across projects or --scope project to write to .mcp.json.
Connect Codex
codex mcp add dbvision --url https://dbvision.example.com/mcp
codex mcp login dbvisionFor headless environments, pass --no-browser to codex mcp login dbvision, open the printed URL in a browser, and paste the callback URL back into the terminal. Codex supports both Client ID Metadata Documents (CIMD) and Dynamic Client Registration (DCR).
OAuth consent and per-client grants
- An unauthenticated
POST /mcpreturns401with aWWW-Authenticateheader pointing to/.well-known/oauth-protected-resource/mcp. - The client identifies itself via CIMD or public DCR (with HTTPS or loopback HTTP redirect URIs).
- On the consent page, review the client name, redirect host, and requested permissions, and select which saved connections the client may access.
- DBVision enforces that per-user, per-client grant on every
/mcprequest.
Available MCP tools
| Tool | Purpose |
|---|---|
list_connections | Lists authorized connections (id, name, engine). |
list_tables | Lists tables and views of a connection, optionally filtered by schema. |
describe_table | Returns columns, primary key, indexes, and foreign keys of a table or view. |
sample_rows | Reads the first rows of a table or view (subject to AI data mode). |
run_query | Runs one read-only SQL statement and returns up to 100 rows (subject to AI data mode). |
Serialized row arrays are capped at 64 KiB (truncated is set when rows are omitted), and the HTTP request body is capped at 1 MiB.
AI data modes
| Mode | sample_rows | run_query |
|---|---|---|
| Schema only (default) | Refused with data-mode-forbids-rows | Column metadata, retained row count, and truncated flag; no row values |
| Sample rows | Up to 20 rows | Up to 20 rows |
| Query results | Up to 20 rows | Up to 100 rows |
Manage and revoke clients
Open Settings → MCP clients in DBVision to inspect authorized clients, their registration type, last-used timestamp, and granted connections, or to revoke a client's access immediately. Revocation deletes the grant, consent, and stored tokens in one transaction.