SuperAPI AI Directory

lagaam

Lagaam is an MCP server for AI agents, deployed between AI agents and the Trino and Apache Pinot lakehouse to intercept queries that could overwhelm a shared cluster before they are executed. It performs schema validation, table-level allowlist checks, cost quotes based on the engine's own execution plan, and budget gating on every query; queries that exceed the budget or whose cost cannot be estimated are rejected, with actionable remediation suggestions for the agent. It allows only a single SELECT, prohibits DDL/DML, multi-statement injection, SELECT *, and table function passthrough, and automatically injects a LIMIT when one is missing; it provides three tools—list_catalogs, describe_table, and query_data—issues warnings when results are anomalous, and writes a JSONL audit log entry on every call. It is suited to scenarios where read-only query access is opened to AI agents on shared Trino/Pinot clusters.

Open website

About this tool

Lagaam is an MCP server positioned between AI agents and the lakehouse (Trino and Apache Pinot). Its goal is to solve the problem of agents on shared clusters writing syntactically correct but highly destructive SQL: missing partition filters causing full table scans, accidental cross joins filling worker memory, retry loops executing repeatedly, and SELECT * pulling large numbers of columns into the context window.

Key capabilities:

  1. Pre-execution cost quotes: on Trino, use EXPLAIN (TYPE IO) to estimate bytes scanned, and EXPLAIN (TYPE LOGICAL) to estimate the widest row count built by any operator (a number that cross joins inflate and LIMIT cannot mask); if the budget is exceeded, block the query and provide the numbers and remediation suggestions. When estimation is impossible (no table statistics, self-joins breaking estimates, passthrough invisible to the planner), reject on a fail-safe basis.
  2. Read-only enforced at the AST layer: only a single SELECT is allowed; DDL/DML, multi-statement injection, SELECT *, and table function passthrough are prohibited, and a LIMIT is automatically injected when missing; the validated SQL is re-rendered to ensure that what executes is exactly what was checked.
  3. Schema grounding: list_catalogs and describe_table return exact names, types, and row count estimates, scoped to the agent's table grants.
  4. Result validation: cases such as zero rows, truncated pagination, and all-NULL columns return warnings to the agent with next-step actions.
  5. Auditing: each tool call writes one JSONL line recording who did what, whether it was allowed or denied, and why; query lines place the quote alongside the engine's actual bytes read, making it easy to tune budgets.

Usage: configure allowed tables via environment variables or command-line arguments (LAGAAM_ALLOWED_TABLES; the server does not start if unset; LAGAAM_ALLOW_ALL_TABLES=true means allow all), Trino host/port/user, or Pinot controller/broker URLs (LAGAAM_ENGINE=pinot). TRINO_PASSWORD or TRINO_JWT login is supported (using https in that case), and PINOT_USER/PINOT_PASSWORD are used for authenticated Pinot. It can connect to any MCP client (such as Claude Code, Claude Desktop), and can also be installed as a Claude Code plugin (lagaam@lagaam). Agents can use only three tools: list_catalogs, describe_table, and query_data.

Use cases: teams that need to open read-only query access to AI agents on shared Trino or Pinot clusters while preventing a single query from overwhelming other users' workloads.

Limitations: one agent per server process, stdio transport only, no HTTP transport or per-request tokens; tables without statistics cannot be quoted and their queries are rejected, so ANALYZE must be run first; budgets are calculated per query and are not accumulated across sessions; only Trino and Pinot are supported; actual bytes read in the audit are recorded but not enforced; truncation during actual execution depends on LAGAAM_QUERY_TIMEOUT and the engine's own limits. Pinot has no execution plan, so its quotes are synthesized from static segment metadata, broker pruning results, and plan shape.