Connect OpenAI Codex to your database.
Use the Codex CLI already signed in on your machine. Valv detects it, gives it read-only tools for your database, and lets you work in the desktop app or connect from your terminal over MCP.
Already have Valv? Go to the setup steps.
Work in Valv, or stay in your terminal.
Valv can run Codex inside the app, with tables, charts, files, and the current selection beside the chat. It can also expose the active workspace to Codex over a local MCP server.
Use Codex inside Valv.
Pick Codex during setup and ask in Valv's chat. The app starts an ephemeral Codex run with your chosen model and gives it the current workspace's database tools for that turn.
Existing Codex login · no API key in Valv
Use Valv from Codex.
Add Valv as an MCP server once. Codex in your terminal can then inspect and query whichever workspace is active in the open desktop app.
codex mcp add valv-desktop --url http://127.0.0.1:4319/mcp Setup
From an installed CLI to your first database answer.
You connect Codex to Valv, not directly to a database password. The whole setup takes place on your machine.
- 1
Install and sign in to Codex.
Valv uses the local
codexcommand and its existing login. Check that it is available before opening Valv.
Codex installation guidecodex --version - 2
Pick Codex in Valv.
Valv checks for
codexon your PATH. Pick Codex during onboarding. If you installed it afterwards, open Settings, Providers, then select Re-scan. - 3
Add your database.
Paste a PostgreSQL, MySQL, or ClickHouse connection string, try the experimental MongoDB support, or choose a local SQLite file. You can test the connection before saving. Valv encrypts the password through your OS keychain.
postgres://user:password@host:5432/database - 4
Review AI access, then ask.
Valv makes the active schemas available to Codex. Before the first question, hide any table or column it should not inspect. Then open Ask and try a question tied to a real decision.
Which plans had the biggest increase in cancellations this month?
The database tools are read-only.
Codex can discover the allowed schema and compose structured queries. Valv validates each query before it reaches the database. Codex does not receive tools to insert, update, delete, or run raw SQL.
Hide data before Codex discovers it.
AI access is separate from your own access in Valv. Hide a whole table or individual columns such as email and card number. You can still open that data yourself in the read-only table viewer.
AI access
Codex MCP
Query the active Valv workspace from your terminal.
Open Settings, MCP Server, and copy the command Valv shows for Codex. Keep the app open. The MCP server binds to localhost and follows the workspace currently selected in Valv.
Port 4319 is the default. If it is already in use, Valv chooses another local port, so use the command shown in the app.
For other servers, timeouts, and config.toml options, see the Codex MCP guide.
$ codex mcp add valv-desktop --url http://127.0.0.1:4319/mcp
$ codex
> Which customer segments grew fastest this quarter? Need setup details for other clients? Read the database MCP guide.
Codex and your database, answered
How do I connect Codex to a database?
Install and sign in to the Codex CLI, then open Valv Desktop. Valv detects Codex on your machine. Pick it as your agent, add a database, review its AI access, and ask your first question. You do not need to paste database credentials into Codex.
Can I use Valv from Codex in my terminal?
Yes. Valv runs a local MCP server while the desktop app is open. Copy the Codex command from Settings, MCP Server, and run it once in your terminal. Codex can then query the workspace that is active in Valv.
Can Codex write to my database?
No. The database tools Valv gives Codex are read-only. Codex can inspect the allowed schema and run structured queries, but it does not receive database write tools. Valv's own table viewer is read-only too, so nothing in Valv writes to your database.
Which databases work with Codex through Valv?
PostgreSQL, MySQL and MariaDB, SQLite, and ClickHouse are supported. MongoDB support is experimental. You can connect more than one database to the same workspace and ask Codex to work across them.
What data is sent to OpenAI?
Valv keeps database credentials in your OS keychain and never sends them to Codex. Valv queries the database directly on your machine. The schema and query results Codex needs are processed through your existing Codex session, under your OpenAI account settings and terms.
Do I need an OpenAI API key?
No API key goes into Valv. The Codex CLI must already be installed and signed in on your machine. Its usage follows the OpenAI account you use with Codex.
Put Codex to work on your data.
Free for personal use, every feature included. Commercial use needs a seat at beta pricing. See pricing.