# Lokra

> Lokra is an open-source MCP server for databases. Postgres gate for AI agents with row locks, masking and approved writes. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Starting price:** $49 a month
- **Platforms:** CLI, API, Self-hosted, Slack
- **Website:** https://lokra.dev/docs/
- **Repository:** https://github.com/lokrahq/lokra
- **MCP Registry name:** io.github.lokrahq/lokra
- **Categories:** [databases](https://ai-powered.com/categories/databases), [security](https://ai-powered.com/categories/security)
- **Listing updated:** 2026-11-28

## About

Lokra runs between an agent and a Postgres database and decides what that agent can read and change. Each agent logs in with its own database role, limited to the tables, columns and rows its policy allows, so the database itself enforces the scope instead of an application-level check.

Requests pass through several layers in order: a signed short-lived token, a SQL check that refuses DDL and stacked statements, the agent's own role, a read-only transaction, masking of identifiers such as emails, phone numbers and payment cards, and a hash-chained audit ledger. Writes are dry-run first, show how many rows they would change, and wait for a person to approve them, unless an approval rule lets a small write through.

The gate is an MCP server that runs next to your database, under an Apache-2.0 licence. It suits teams that want agents to query production data without handing them the application's database password.

## Features

- **Per-agent database roles:** Each agent gets its own Postgres role with grants only on the tables and columns in its policy.
- **Row-level locks:** Row-level security policies restrict an agent to rows whose column matches listed values.
- **Masking of sensitive values:** Emails, phone numbers, cards, IBANs and several national identifiers are masked in results, including inside free text and JSON.
- **Approved writes:** INSERT, UPDATE and DELETE are dry-run and held for a person to approve, with optional rules for small or two-person approvals.
- **Signed audit ledger:** Every request and write decision is appended to a hash-chained, signed log with a report command for activity and risk summaries.
- **Pause and revoke controls:** Agents can be paused or have individual tokens revoked, which also blocks their database login when an admin connection is set.

## Good for

- Letting a support bot read customer records without seeing card or contact details
- Having an operations agent propose database updates that a staff member approves first
- Connecting Claude Code or Cursor to a Supabase or RDS database with a restricted role
- Producing an audit trail of agent database access for a security review

## Install

### Claude Code: Add with the CLI (Terminal)

```sh
claude mcp add lokra --env LOKRA_CONFIG='<LOKRA_CONFIG>' --env LOKRA_TOKEN='<LOKRA_TOKEN>' -- uvx lokra
```

Add --scope user to use it in every project, or --scope project to share it in .mcp.json.

### Claude Code: Or share it with your project (.mcp.json)

```json
{
  "mcpServers": {
    "lokra": {
      "command": "uvx",
      "args": [
        "lokra"
      ],
      "env": {
        "LOKRA_CONFIG": "<LOKRA_CONFIG>",
        "LOKRA_TOKEN": "<LOKRA_TOKEN>"
      }
    }
  }
}
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "lokra": {
      "command": "uvx",
      "args": [
        "lokra"
      ],
      "env": {
        "LOKRA_CONFIG": "<LOKRA_CONFIG>",
        "LOKRA_TOKEN": "<LOKRA_TOKEN>"
      }
    }
  }
}
```

Settings → Developer → Edit Config, then quit and reopen Claude Desktop.

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

```json
{
  "mcpServers": {
    "lokra": {
      "command": "uvx",
      "args": [
        "lokra"
      ],
      "env": {
        "LOKRA_CONFIG": "<LOKRA_CONFIG>",
        "LOKRA_TOKEN": "<LOKRA_TOKEN>"
      }
    }
  }
}
```

Use .cursor/mcp.json in a project to share it with the project.

### VS Code (~/.copilot/mcp-config.json)

```json
{
  "mcpServers": {
    "lokra": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "lokra"
      ],
      "env": {
        "LOKRA_CONFIG": "<LOKRA_CONFIG>",
        "LOKRA_TOKEN": "<LOKRA_TOKEN>"
      }
    }
  }
}
```

Or put the same entry in .mcp.json at your workspace root to share it.

### Codex: Add with the CLI (Terminal)

```sh
codex mcp add lokra --env LOKRA_CONFIG='<LOKRA_CONFIG>' --env LOKRA_TOKEN='<LOKRA_TOKEN>' -- uvx lokra
```

### Codex: Or add to config.toml (~/.codex/config.toml)

```toml
[mcp_servers.lokra]
command = "uvx"
args = ["lokra"]
env = { LOKRA_CONFIG = "<LOKRA_CONFIG>", LOKRA_TOKEN = "<LOKRA_TOKEN>" }
```

### Gemini CLI and Antigravity: Gemini CLI (~/.gemini/settings.json)

```json
{
  "mcpServers": {
    "lokra": {
      "command": "uvx",
      "args": [
        "lokra"
      ],
      "env": {
        "LOKRA_CONFIG": "<LOKRA_CONFIG>",
        "LOKRA_TOKEN": "<LOKRA_TOKEN>"
      }
    }
  }
}
```

Or run: gemini mcp add -s user -e LOKRA_CONFIG='<LOKRA_CONFIG>' -e LOKRA_TOKEN='<LOKRA_TOKEN>' lokra uvx -- lokra

### Gemini CLI and Antigravity: Antigravity (~/.gemini/config/mcp_config.json)

```json
{
  "mcpServers": {
    "lokra": {
      "command": "uvx",
      "args": [
        "lokra"
      ],
      "env": {
        "LOKRA_CONFIG": "<LOKRA_CONFIG>",
        "LOKRA_TOKEN": "<LOKRA_TOKEN>"
      }
    }
  }
}
```

Use .agents/mcp_config.json to add it to one workspace only.

### Devin Desktop (~/.config/devin/mcp_config.json)

```json
{
  "mcpServers": {
    "lokra": {
      "command": "uvx",
      "args": [
        "lokra"
      ],
      "env": {
        "LOKRA_CONFIG": "<LOKRA_CONFIG>",
        "LOKRA_TOKEN": "<LOKRA_TOKEN>"
      }
    }
  }
}
```

On Windows the file is %APPDATA%\\devin\\mcp_config.json. Use .devin/mcp_config.json to share it with a project.

### Cline (cline_mcp_settings.json)

```json
{
  "mcpServers": {
    "lokra": {
      "command": "uvx",
      "args": [
        "lokra"
      ],
      "env": {
        "LOKRA_CONFIG": "<LOKRA_CONFIG>",
        "LOKRA_TOKEN": "<LOKRA_TOKEN>"
      }
    }
  }
}
```

Open it from the MCP Servers icon → Configure → Configure MCP Servers.

### Zed (Zed settings.json)

```json
{
  "context_servers": {
    "lokra": {
      "command": "uvx",
      "args": [
        "lokra"
      ],
      "env": {
        "LOKRA_CONFIG": "<LOKRA_CONFIG>",
        "LOKRA_TOKEN": "<LOKRA_TOKEN>"
      }
    }
  }
}
```

Open it with zed: open settings file. Merge context_servers into the settings you already have.

### JetBrains AI Assistant and Junie: AI Assistant (Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add)

```json
{
  "mcpServers": {
    "lokra": {
      "command": "uvx",
      "args": [
        "lokra"
      ],
      "env": {
        "LOKRA_CONFIG": "<LOKRA_CONFIG>",
        "LOKRA_TOKEN": "<LOKRA_TOKEN>"
      }
    }
  }
}
```

The AI Assistant docs only show command and args. If the env block is ignored, use Junie for this server.

### JetBrains AI Assistant and Junie: Junie (~/.junie/mcp/mcp.json)

```json
{
  "mcpServers": {
    "lokra": {
      "command": "uvx",
      "args": [
        "lokra"
      ],
      "env": {
        "LOKRA_CONFIG": "<LOKRA_CONFIG>",
        "LOKRA_TOKEN": "<LOKRA_TOKEN>"
      }
    }
  }
}
```

Use .junie/mcp/mcp.json to share it with a project.

### Kiro (~/.kiro/settings/mcp.json)

```json
{
  "mcpServers": {
    "lokra": {
      "command": "uvx",
      "args": [
        "lokra"
      ],
      "env": {
        "LOKRA_CONFIG": "<LOKRA_CONFIG>",
        "LOKRA_TOKEN": "<LOKRA_TOKEN>"
      }
    }
  }
}
```

Use .kiro/settings/mcp.json to add it to one workspace only.

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "lokra": {
      "command": "uvx",
      "args": [
        "lokra"
      ],
      "env": {
        "LOKRA_CONFIG": "<LOKRA_CONFIG>",
        "LOKRA_TOKEN": "<LOKRA_TOKEN>"
      }
    }
  }
}
```

## Tools

From the tool list in its README, going by the names, 3 of 6 tools change data; 1 name doesn't say. From the server's own tool labels and tool names; not verified by us.

- `whoami`: Shows the calling agent's identity.
- `list_tables` (name suggests: reads): Lists tables the agent can access.
- `query` (name suggests: reads): Runs a read-only SELECT with masking applied.
- `propose_write` (name suggests: changes): Submits a write for dry run and approval.
- `write_status` (name suggests: changes): Checks the status of a proposed write.
- `execute_write` (name suggests: changes): Runs an approved write.

## FAQ

### Is Lokra free?

The gate is open source under Apache-2.0 and free with no limits. Lokra Cloud has a free plan and a flat $49 a month for the whole team.

### Does the agent ever see my database password?

No. Agents receive a short-lived signed token and log in as their own limited Postgres role.

### Which databases are supported?

Lokra is tested on Postgres 16 and works with hosted Postgres such as Supabase and Amazon RDS.

### How are writes handled?

Writes are dry-run to count affected rows and held until approved by a person, through the terminal, dashboard or Slack. A write that would change more rows than approved is rolled back.

### How do I add Lokra to Claude Code?

Run this command in your terminal: claude mcp add lokra --env LOKRA_CONFIG='<LOKRA_CONFIG>' --env LOKRA_TOKEN='<LOKRA_TOKEN>' -- uvx lokra

### What are the best alternatives to Lokra?

The closest alternatives to Lokra are Lomberk, Pgmoat, pgleash, Orion Gate and pgbrake.

## Where this comes from

- Description: written from the project's README, the project's website and its MCP Registry entry.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [Lomberk](https://ai-powered.com/mcp/lomberk): Lomberk is an MCP server for databases.
- [Pgmoat](https://ai-powered.com/mcp/pgmoat): Pgmoat is an open-source MCP server for databases.
- [pgleash](https://ai-powered.com/mcp/pgleash): pgleash is an open-source MCP server for databases.
- [Orion Gate](https://ai-powered.com/mcp/orion-gate): Orion Gate is an open-source MCP server for databases.
- [pgbrake](https://ai-powered.com/mcp/pgbrake): pgbrake is an open-source MCP server for databases.
- [SQL MCP Server](https://ai-powered.com/mcp/sql-mcp-server): SQL MCP Server is an open-source MCP server for databases.
- [Midplane](https://ai-powered.com/mcp/midplane): Midplane is an open-source MCP server for databases.
- [Safedb MCP](https://ai-powered.com/mcp/safedb-mcp): Safedb MCP is an open-source MCP server for databases.

---
Source: https://ai-powered.com/mcp/lokra
