---
id: w5/m9/t002
title: MCP tool query_render_postgres (Render's exact name/args, MCP-only)
worker: worker5
status: done
estimate: 20m
depends_on: [w5/m9/t001]
---

## Objective

Register the MCP tool under Render's exact official name `query_render_postgres` (keeping the name verbatim — Render-trained agents call it literally; deviating breaks drop-in compat) with Render's argument names (`postgresId`, `sql`), delegating to t001's verb. MCP-only: Render exposes no REST/GraphQL equivalent, and neither does bex.

## Context

- Tool-name fidelity is the w2/m1 rule ("tool names track Render's official server the way rest.go tracks the OpenAPI spec").
- Fragment lives beside the feature: `lego/backend/internal/postgres/mcp.go`.

## Steps

1. Register the tool with Render's name/args and a result shape of columns/rows/truncated.
2. Tool errors for unknown `postgresId` and RO violations (value-free messages).
3. Update `docs/ADR006-bex-api.md` (remove the "omitted" note; add the tool row).

## Files

- `lego/backend/internal/postgres/mcp.go`
- `docs/ADR006-bex-api.md`

## Acceptance criteria

- [ ] MCP round-trip test: tool advertised as `query_render_postgres`; a `SELECT 1` returns a row; a write attempt surfaces as a tool error.

## Out of scope

- A REST/GraphQL query surface (deliberately absent, matching Render).
