Metadata-Version: 2.5
Name: envdb
Version: 0.3.0
Summary: MCP server and terminal viewer for the databases in your project's .env (PostgreSQL, MySQL, SQLite)
Project-URL: Homepage, https://github.com/AkaMario/envdb
Project-URL: Issues, https://github.com/AkaMario/envdb/issues
Author: Mario
License-Expression: MIT
License-File: LICENSE
Keywords: database,dotenv,mcp,mysql,postgresql,sqlite,tui,zed
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Database :: Front-Ends
Requires-Python: >=3.10
Requires-Dist: mcp<3,>=2.3
Requires-Dist: mysql-connector-python>=9
Requires-Dist: psycopg[binary]>=3.2
Requires-Dist: textual[syntax]>=8
Description-Content-Type: text/markdown

# envdb

**Let your AI agent see your database.** envdb reads the `.env` of your project, finds every
database it points to and exposes them over [MCP](https://modelcontextprotocol.io) so the
agent in Zed (or Claude Code, Cursor, VS Code…) can list tables, read the schema, page through
rows and run SQL. PostgreSQL, MySQL/MariaDB and SQLite are supported.

It also ships a fast terminal viewer (`envdb`) for browsing, filtering and editing tables yourself.

<!-- mcp-name: io.github.AkaMario/envdb -->

- **Zero config**: uses the connection your app already has (`DATABASE_URL`, any `*_URL`,
  Laravel `DB_*`, `PG*`, `MYSQL_*`) plus any `.db`/`.sqlite` file in the project.
- **Read-only by default**: connections are opened read-only and `run_query` only accepts
  `SELECT`/`WITH`/`EXPLAIN`/`SHOW`/`PRAGMA`. Writes need an explicit opt-in.
- **Credentials never leave the machine**: passwords are never returned to the model.

## Tools

| Tool | What it does |
|---|---|
| `list_databases` | Connections found in `.env`, `.env.local`, `.env.development`… and SQLite files. Optionally the other databases on each server. |
| `list_tables` | Tables and views, optionally with row counts. |
| `describe_table` | Columns, types, nullability, defaults, primary and foreign keys, row count. |
| `query_table` | Paginated rows (10/25/50…) with per-column filters: `text` (contains), `42`, `>100`, `<=5`, `!=3`, `null`, `!null`. |
| `run_query` | One read-only SQL statement. |
| `execute_statement` | INSERT/UPDATE/DELETE/DDL. **Only exists when writes are enabled.** |

## Use it in Zed

### With the extension

Install **envdb** from Zed's extension page. The extension downloads
[uv](https://github.com/astral-sh/uv), which fetches Python and this package; nothing else to install.
Open a project with a `.env`, open the Agent Panel and ask things like
*"what tables does my database have?"* or *"show me the last 10 orders with their customer"*.

Optional settings (`settings.json`):

```jsonc
"context_servers": {
  "envdb": {
    "settings": {
      "allow_writes": false,      // true adds execute_statement
      "project_path": null,       // folder to scan, if not the opened one
      "max_rows": 500
    }
  }
}
```

### Without the extension

```jsonc
"context_servers": {
  "envdb": { "command": "uvx", "args": ["envdb", "mcp"] }
}
```

## Other MCP clients

```sh
claude mcp add envdb -- uvx envdb mcp          # Claude Code
```

Any client: command `uvx`, args `["envdb", "mcp"]`. Environment variables:

| Variable | Meaning |
|---|---|
| `ENVDB_PROJECT` | Project folder to scan (default: current directory). |
| `ENVDB_ALLOW_WRITES` | `1` enables `execute_statement`. |
| `ENVDB_MAX_ROWS` | Max rows per call (default 500). |

## Terminal viewer

```sh
uv tool install envdb
envdb            # pick a database from the project's .env, browse and edit tables
envdb --print    # show what was detected (no passwords)
```

Click a table, click a column header to filter, double-click a cell to copy or edit it,
`s` opens a SQL editor (F5 runs). To open it inside Zed's bottom panel with a shortcut,
see [`zed-config/`](zed-config) (a task plus a `Ctrl+Alt+D` key binding).

## What it understands in `.env`

| Variables | Example |
|---|---|
| `DATABASE_URL`, `DB_URL`, `POSTGRES_URL`, `MYSQL_URL`, any `*_URL`/`*_DSN` | `postgresql://u:pw@localhost:5432/app`, `mysql://…`, `sqlite:///app.db`, `file:./dev.db` (Prisma) |
| Laravel | `DB_CONNECTION=pgsql\|mysql\|sqlite`, `DB_HOST`, `DB_PORT`, `DB_DATABASE`, `DB_USERNAME`, `DB_PASSWORD` |
| libpq / MySQL | `PGHOST`, `PGUSER`… / `MYSQL_HOST`, `MYSQL_USER`… |

Files: `.env`, `.env.local`, `.env.development`, `.env.development.local` (and `.env.production`,
`.env.test`, `.env.example` for the list), searched in the project folder and its parents.

## Development

```sh
uv venv && uv pip install -e .
envdb mcp demo/            # run the MCP server against the sample databases
```

The Zed extension lives in [`zed-extension/`](zed-extension) (Rust → WebAssembly).
In Zed run `zed: install dev extension` and pick that folder; set
`"package": "/path/to/this/repo"` in the server settings to use your local checkout.

Leer en [español](README.es.md).

## License

MIT
