# valv MCP server

> Allows coding agents to query SQL and NoSQL databases safely using read-only tools and policy-based access control.

- Repository: https://github.com/valv-dev/valv
- Page: https://hostedmcp.org/servers/valv-dev/mcp
- Transport: stdio
- Stars: 5
- License: MIT
- Latest version: 0.6.2

## Install

### Claude Code

```sh
claude mcp add --env DATABASE_URL=<YOUR_DATABASE_URL> mcp -- npx -y @valv/mcp
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@valv/mcp"
      ],
      "env": {
        "DATABASE_URL": "<YOUR_DATABASE_URL>"
      }
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@valv/mcp"
      ],
      "env": {
        "DATABASE_URL": "<YOUR_DATABASE_URL>"
      }
    }
  }
}
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@valv/mcp"
      ],
      "env": {
        "DATABASE_URL": "<YOUR_DATABASE_URL>"
      }
    }
  }
}
```

### Codex (`~/.codex/config.toml`)

```toml
[mcp_servers.mcp]
command = "npx"
args = ["-y", "@valv/mcp"]

[mcp_servers.mcp.env]
DATABASE_URL = "<YOUR_DATABASE_URL>"
```

### Gemini CLI (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@valv/mcp"
      ],
      "env": {
        "DATABASE_URL": "<YOUR_DATABASE_URL>"
      }
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `DATABASE_URL` | yes | yes | Database connection string. PostgreSQL, MySQL, SQLite, CockroachDB, or a ClickHouse HTTP URL. |
| `VALV_CONTEXT` | no | no | JSON context object the policy reads, e.g. {"tenant":{"id":"acme"}}. |
| `VALV_DATABASE` | no | no | Database name. Required for ClickHouse, whose URL does not carry one. |
| `VALV_EXCLUDE` | no | no | Comma-separated deny-list of tables, applied after the allow-list. |
| `VALV_HTTP_PORT` | no | no | Serve over Streamable HTTP on this port instead of stdio. |
| `VALV_POLICY_FILE` | no | no | Path to a policy module that takes full control of access. Without it, the server is read-only across all tables. |
| `VALV_PROVIDER` | no | no | Datasource provider: postgresql, mysql, sqlite, or clickhouse. Inferred from DATABASE_URL when omitted. |
| `VALV_TABLES` | no | no | Comma-separated allow-list of tables. When set, only these are exposed to the agent. |

## FAQ

### Which databases are supported?

The server works with PostgreSQL, MySQL, SQLite, CockroachDB, ClickHouse, and MongoDB.

### Is the database access read-only?

Yes, the server provides tools that are read-only by default to ensure safety.

### How can I restrict which tables or columns an agent can see?

You can use a policy file to define specific access rules, such as allowing reads on certain tables or denying specific columns.

### Can I use this with MongoDB?

Yes, you can use a standard connection string for MongoDB and set the VALV_DATABASE variable if the URL does not select a database.
