# Lagaam

> Lagaam is an open-source MCP server for databases. Local MCP guard that blocks agent Trino and Pinot queries before they run if over budget. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, Self-hosted
- **Repository:** https://github.com/lagaam-ai/lagaam
- **GitHub stars:** 1
- **License:** Apache-2.0
- **MCP Registry name:** io.github.lagaam-ai/lagaam
- **Categories:** [databases](https://ai-powered.com/categories/databases), [security](https://ai-powered.com/categories/security)
- **Listing updated:** 2026-12-01

## About

Lagaam is aimed at shared lakehouse clusters, where one agent's missing partition filter or accidental cross join slows everyone else. Instead of limiting a query once it is running, it prices the query from the engine's own EXPLAIN plan first and refuses it with the number and a suggested fix. Queries that cannot be estimated, such as tables without statistics, are refused too.

Only a single SELECT is allowed, checked in the syntax tree. DDL, DML, multiple statements, SELECT * and table-function passthrough are rejected, and a LIMIT is added when missing. Access is limited to a list of granted tables, and the schema tools list_catalogs and describe_table only reveal names the agent is allowed to touch. Defaults include a 50 GiB scan budget, 1,000 returned rows and a 300-second timeout, all adjustable.

Results get warnings for zero rows or truncated pages, and every call is written to a JSONL audit line. The README reports it stopped 11 of 11 risky test queries before execution, and positions it alongside Trino's own limits rather than replacing them.

## Features

- **Pre-run cost quote:** Prices scan bytes and widest-step rows from EXPLAIN.
- **Read-only enforcement:** Allows a single SELECT, checked in the syntax tree.
- **Table grants:** The server will not start without an allowed-table list.
- **Grounding tools:** list_catalogs and describe_table are scoped to the grant.
- **Result checks:** Warns on empty, truncated or all-NULL results.
- **Audit trail:** One JSONL line per call with decision and reason.

## Good for

- Give agents Trino access on a shared cluster safely
- Stop accidental cross joins before they run
- Restrict an agent to specific tables
- Audit what agents queried and why it was allowed

## Install

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

```sh
claude mcp add lagaam --env LAGAAM_ALLOWED_TABLES='<LAGAAM_ALLOWED_TABLES>' --env TRINO_PASSWORD='<TRINO_PASSWORD>' --env TRINO_JWT='<TRINO_JWT>' --env PINOT_PASSWORD='<PINOT_PASSWORD>' -- uvx lagaam
```

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": {
    "lagaam": {
      "command": "uvx",
      "args": [
        "lagaam"
      ],
      "env": {
        "LAGAAM_ALLOWED_TABLES": "<LAGAAM_ALLOWED_TABLES>",
        "TRINO_PASSWORD": "<TRINO_PASSWORD>",
        "TRINO_JWT": "<TRINO_JWT>",
        "PINOT_PASSWORD": "<PINOT_PASSWORD>"
      }
    }
  }
}
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "lagaam": {
      "command": "uvx",
      "args": [
        "lagaam"
      ],
      "env": {
        "LAGAAM_ALLOWED_TABLES": "<LAGAAM_ALLOWED_TABLES>",
        "TRINO_PASSWORD": "<TRINO_PASSWORD>",
        "TRINO_JWT": "<TRINO_JWT>",
        "PINOT_PASSWORD": "<PINOT_PASSWORD>"
      }
    }
  }
}
```

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

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

```json
{
  "mcpServers": {
    "lagaam": {
      "command": "uvx",
      "args": [
        "lagaam"
      ],
      "env": {
        "LAGAAM_ALLOWED_TABLES": "<LAGAAM_ALLOWED_TABLES>",
        "TRINO_PASSWORD": "<TRINO_PASSWORD>",
        "TRINO_JWT": "<TRINO_JWT>",
        "PINOT_PASSWORD": "<PINOT_PASSWORD>"
      }
    }
  }
}
```

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

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

```json
{
  "mcpServers": {
    "lagaam": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "lagaam"
      ],
      "env": {
        "LAGAAM_ALLOWED_TABLES": "<LAGAAM_ALLOWED_TABLES>",
        "TRINO_PASSWORD": "<TRINO_PASSWORD>",
        "TRINO_JWT": "<TRINO_JWT>",
        "PINOT_PASSWORD": "<PINOT_PASSWORD>"
      }
    }
  }
}
```

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 lagaam --env LAGAAM_ALLOWED_TABLES='<LAGAAM_ALLOWED_TABLES>' --env TRINO_PASSWORD='<TRINO_PASSWORD>' --env TRINO_JWT='<TRINO_JWT>' --env PINOT_PASSWORD='<PINOT_PASSWORD>' -- uvx lagaam
```

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

```toml
[mcp_servers.lagaam]
command = "uvx"
args = ["lagaam"]
env = { LAGAAM_ALLOWED_TABLES = "<LAGAAM_ALLOWED_TABLES>", TRINO_PASSWORD = "<TRINO_PASSWORD>", TRINO_JWT = "<TRINO_JWT>", PINOT_PASSWORD = "<PINOT_PASSWORD>" }
```

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

```json
{
  "mcpServers": {
    "lagaam": {
      "command": "uvx",
      "args": [
        "lagaam"
      ],
      "env": {
        "LAGAAM_ALLOWED_TABLES": "<LAGAAM_ALLOWED_TABLES>",
        "TRINO_PASSWORD": "<TRINO_PASSWORD>",
        "TRINO_JWT": "<TRINO_JWT>",
        "PINOT_PASSWORD": "<PINOT_PASSWORD>"
      }
    }
  }
}
```

Or run: gemini mcp add -s user -e LAGAAM_ALLOWED_TABLES='<LAGAAM_ALLOWED_TABLES>' -e TRINO_PASSWORD='<TRINO_PASSWORD>' -e TRINO_JWT='<TRINO_JWT>' -e PINOT_PASSWORD='<PINOT_PASSWORD>' lagaam uvx -- lagaam

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

```json
{
  "mcpServers": {
    "lagaam": {
      "command": "uvx",
      "args": [
        "lagaam"
      ],
      "env": {
        "LAGAAM_ALLOWED_TABLES": "<LAGAAM_ALLOWED_TABLES>",
        "TRINO_PASSWORD": "<TRINO_PASSWORD>",
        "TRINO_JWT": "<TRINO_JWT>",
        "PINOT_PASSWORD": "<PINOT_PASSWORD>"
      }
    }
  }
}
```

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

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

```json
{
  "mcpServers": {
    "lagaam": {
      "command": "uvx",
      "args": [
        "lagaam"
      ],
      "env": {
        "LAGAAM_ALLOWED_TABLES": "<LAGAAM_ALLOWED_TABLES>",
        "TRINO_PASSWORD": "<TRINO_PASSWORD>",
        "TRINO_JWT": "<TRINO_JWT>",
        "PINOT_PASSWORD": "<PINOT_PASSWORD>"
      }
    }
  }
}
```

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": {
    "lagaam": {
      "command": "uvx",
      "args": [
        "lagaam"
      ],
      "env": {
        "LAGAAM_ALLOWED_TABLES": "<LAGAAM_ALLOWED_TABLES>",
        "TRINO_PASSWORD": "<TRINO_PASSWORD>",
        "TRINO_JWT": "<TRINO_JWT>",
        "PINOT_PASSWORD": "<PINOT_PASSWORD>"
      }
    }
  }
}
```

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

### Zed (Zed settings.json)

```json
{
  "context_servers": {
    "lagaam": {
      "command": "uvx",
      "args": [
        "lagaam"
      ],
      "env": {
        "LAGAAM_ALLOWED_TABLES": "<LAGAAM_ALLOWED_TABLES>",
        "TRINO_PASSWORD": "<TRINO_PASSWORD>",
        "TRINO_JWT": "<TRINO_JWT>",
        "PINOT_PASSWORD": "<PINOT_PASSWORD>"
      }
    }
  }
}
```

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": {
    "lagaam": {
      "command": "uvx",
      "args": [
        "lagaam"
      ],
      "env": {
        "LAGAAM_ALLOWED_TABLES": "<LAGAAM_ALLOWED_TABLES>",
        "TRINO_PASSWORD": "<TRINO_PASSWORD>",
        "TRINO_JWT": "<TRINO_JWT>",
        "PINOT_PASSWORD": "<PINOT_PASSWORD>"
      }
    }
  }
}
```

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": {
    "lagaam": {
      "command": "uvx",
      "args": [
        "lagaam"
      ],
      "env": {
        "LAGAAM_ALLOWED_TABLES": "<LAGAAM_ALLOWED_TABLES>",
        "TRINO_PASSWORD": "<TRINO_PASSWORD>",
        "TRINO_JWT": "<TRINO_JWT>",
        "PINOT_PASSWORD": "<PINOT_PASSWORD>"
      }
    }
  }
}
```

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

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

```json
{
  "mcpServers": {
    "lagaam": {
      "command": "uvx",
      "args": [
        "lagaam"
      ],
      "env": {
        "LAGAAM_ALLOWED_TABLES": "<LAGAAM_ALLOWED_TABLES>",
        "TRINO_PASSWORD": "<TRINO_PASSWORD>",
        "TRINO_JWT": "<TRINO_JWT>",
        "PINOT_PASSWORD": "<PINOT_PASSWORD>"
      }
    }
  }
}
```

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": {
    "lagaam": {
      "command": "uvx",
      "args": [
        "lagaam"
      ],
      "env": {
        "LAGAAM_ALLOWED_TABLES": "<LAGAAM_ALLOWED_TABLES>",
        "TRINO_PASSWORD": "<TRINO_PASSWORD>",
        "TRINO_JWT": "<TRINO_JWT>",
        "PINOT_PASSWORD": "<PINOT_PASSWORD>"
      }
    }
  }
}
```

## Tools

From the tool list in its README, going by the names, all 2 tools only read data. From the server's own tool labels and tool names; not verified by us.

- `list_catalogs` (name suggests: reads): Lists catalogs scoped to the agent's table grant.
- `describe_table` (name suggests: reads): Returns column names, types and row estimates for a granted table.

## FAQ

### Which engines does Lagaam support?

Trino by default and Apache Pinot via LAGAAM_ENGINE.

### How do I install Lagaam?

Run uvx lagaam with LAGAAM_ALLOWED_TABLES and your Trino host set.

### How is Lagaam different from Trino's own limits?

Trino limits act during or after execution. Lagaam refuses before the query starts.

### What are the default limits?

50 GiB scan budget, 1,000 returned rows, 300-second timeout.

### Can I run without a table grant?

Only by setting LAGAAM_ALLOW_ALL_TABLES to true, an explicit opt-out.

### Is Lagaam free?

Yes. Lagaam is open source, so you can use and self-host it for free.

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

Run this command in your terminal: claude mcp add lagaam --env LAGAAM_ALLOWED_TABLES='<LAGAAM_ALLOWED_TABLES>' --env TRINO_PASSWORD='<TRINO_PASSWORD>' --env TRINO_JWT='<TRINO_JWT>' --env PINOT_PASSWORD='<PINOT_PASSWORD>' -- uvx lagaam

### What are the best alternatives to Lagaam?

The closest alternatives to Lagaam are REA, MCP Toolbox for Databases, redamon, AiSOC and Bernstein.

## Where this comes from

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

## Alternatives

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [MCP Toolbox for Databases](https://ai-powered.com/mcp/mcp-toolbox-for-databases-2): MCP Toolbox for Databases is an open-source MCP server for databases.
- [redamon](https://ai-powered.com/mcp/redamon): redamon is an open-source MCP server for ai models and llm tooling.
- [AiSOC](https://ai-powered.com/mcp/aisoc): AiSOC is an open-source MCP server for ai models and llm tooling.
- [Bernstein](https://ai-powered.com/mcp/bernstein): Bernstein is an open-source MCP server for developer tools.
- [SSH — policy-gated remote access](https://ai-powered.com/mcp/ssh-policy-gated-remote-access): SSH — policy-gated remote access is an open-source MCP server for security.
- [ClickHouse](https://ai-powered.com/mcp/clickhouse): ClickHouse is an open-source MCP server for databases.
- [postgres-mcp](https://ai-powered.com/mcp/postgres-mcp-4): postgres-mcp is an open-source MCP server for databases.

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