# Use QuerentDB as an MCP server in Claude Code, Cursor and VS Code

> Connect Claude Code, Cursor or VS Code to your databases through QuerentDB's local MCP server: a personal token, your permissions, and your approval for every write.

Source: https://www.keepware.dev/guides/querentdb-mcp-server · Product: QuerentDB (https://www.keepware.dev/querentdb) · Published 2026-11-11

QuerentDB, a desktop database client by Keepware, runs a local MCP server at `http://127.0.0.1:7466/mcp`. Add it to Claude Code, Cursor, Codex or VS Code with a personal token, and the agent can list your environments and connections, look at their structure, run read-only queries and explain them, with your permissions and nothing more. When it wants to change data, QuerentDB shows you the statement and how many rows it would affect, and nothing runs until you choose **Allow once**. Passwords and SSH tunnels never leave QuerentDB.

## How do I connect Claude Code to QuerentDB?

1. In QuerentDB, open **Settings → MCP & CLI**. **Local server** should say **Running**, at `http://127.0.0.1:7466/mcp`.
2. Under **Personal tokens**, choose **New token**.
3. Keep the defaults or adjust them, then choose **Create**:
   - **Name**: which agent and computer it's for, such as *Claude Code (PC)*.
   - **Access**: **Follow my permissions**, or **Custom** to pick environments.
   - **Read-only**: the token can't write anywhere.
   - **Approve writes**: on by default; every write asks you first. Off, writes in unprotected environments go through without asking. Protected environments always ask.
   - **Expires**: 30 days, 90 days (the default), 1 year or never.

   ![The New personal token sheet: name, access, read-only, approve writes, expiry](https://www.keepware.dev/guides/querentdb-mcp-server/mcp-new-token.png)

4. **Token created** shows the token once, with the command for your agent. Choose **Claude Code**, copy the command and run it in a terminal (add `--scope user` to use it in every project):

   ```sh
   claude mcp add --transport http qdb http://127.0.0.1:7466/mcp \
     --header "Authorization: Bearer qdb_pat_••••••••"
   ```

   ![Token created: the token, shown once, and the claude mcp add command](https://www.keepware.dev/guides/querentdb-mcp-server/mcp-token-created.png)

The server's name, `qdb`, is only what your agent calls it (its tools show up as `mcp__qdb__…`); a configuration that names it `querentdb`, from an earlier version, keeps working.

QuerentDB keeps only a hash of the token, so copy it before you choose **Done**. If you lose it, revoke it and make a new one.

## How do I add QuerentDB to Cursor or VS Code?

Pick **Cursor** or **VS Code** on the **Token created** sheet (or under **Connect** on the same page) and copy the configuration.

Cursor: add this to `~/.cursor/mcp.json` (every project) or `.cursor/mcp.json` in a project:

```json
{
  "mcpServers": {
    "qdb": {
      "url": "http://127.0.0.1:7466/mcp",
      "headers": {
        "Authorization": "Bearer qdb_pat_••••••••"
      }
    }
  }
}
```

VS Code: add this to `.vscode/mcp.json` in a project, or to your user configuration with **MCP: Open User Configuration**:

```json
{
  "servers": {
    "qdb": {
      "type": "http",
      "url": "http://127.0.0.1:7466/mcp",
      "headers": {
        "Authorization": "Bearer qdb_pat_••••••••"
      }
    }
  }
}
```

For Codex, the sheet shows a `[mcp_servers.qdb]` block for `~/.codex/config.toml`.

## Which tools does the QuerentDB MCP server provide?

| Tool | What it does |
|---|---|
| `list_environments` | Your environments, with your access, protection and AI policy |
| `list_connections` | Connections (never their passwords), as `environment/name` |
| `describe` | A database's tables, collections or indices, or one object's structure |
| `query` | A read-only statement; up to 50 rows by default, 200 at most, cut-off results flagged |
| `explain` | The execution plan |
| `execute` | A write, after you approve it in QuerentDB |
| `audit_query` | A team's audit log, within what you're allowed to see |

`query` refuses anything that writes; the agent has to use `execute`.

## What happens when an agent wants to write?

QuerentDB comes to the front and shows who's asking, through which token, where, the statement, and how many rows it's expected to affect, counted with the same conditions:

![Claude Code wants to write to dev: the statement, 18 rows expected, Deny or Allow once](https://www.keepware.dev/guides/querentdb-mcp-server/mcp-approval.png)

Choose **Allow once** to run it, or **Deny**. If you don't answer within a minute, it's denied. In a protected environment you also type the environment's name first. A denied write reaches the agent as:

```json
{
  "error": {
    "code": "cancelled",
    "message": "The user denied this write in QuerentDB"
  }
}
```

## What can an agent see through MCP?

- **Your permissions, live.** A token follows your access in each environment; if your role changes, the token follows at once. **Custom** and **Read-only** only narrow it further.
- **The AI policy** of each environment: with **Off**, MCP can't use its connections at all (they aren't listed); with **Schema only**, the agent can describe structure but not read data.
- **Rows, not the database.** Queries run inside QuerentDB on your read-only account and come back as rows; long cells are shortened. Database passwords, private keys and SSH tunnels stay in QuerentDB.

## Is the MCP server safe to leave on?

It listens on `127.0.0.1` only, so other computers can't reach it, and it rejects requests from web pages (it checks the `Host` and `Origin` headers). Every request needs a token; QuerentDB stores only a hash of it, and **Revoke** stops it immediately. The server keeps running after you close the window and stops when you quit QuerentDB; turn it off with **Enable the local MCP server**.

## FAQ

### How many tokens can I have?

A personal workspace has one personal token, plus the one the `qdb` command uses. Team workspaces have no limit.

### Port 7466 is taken. Can I change it?

Yes: enter another **Port** (1024 to 65535) under **Local server** and choose **Apply**, then update the URL in the agents you've set up.

### Claude Code says "Unauthorized". What's wrong?

The token is missing, mistyped, expired or revoked. Create a new one and run the `claude mcp add` command again with it.

### Can I use the same connections from a terminal?

Yes, with the [qdb command line](https://www.keepware.dev/guides/querentdb-qdb-cli): the same tools, permissions and approvals.
