Integration · HTTP, MCP & A2A · Open Source (Apache-2.0) & Cloud

Production AI Agents + Claix: The Best Way to Connect Custom Agents to Your SQL Database
Shipping an AI agent in a prototype is easy; letting that same agent read customer records, issue refunds, cancel orders, or update account state in production is where engineering teams freeze. One indirect prompt injection inside a support ticket, one hallucinated WHERE clause, or one missing tenant filter can expose another customer's data or corrupt thousands of live rows in a single tool call.
Claix sits between your agent loop and PostgreSQL, MySQL, or MariaDB with row-scoped reads and a deny-by-default SQL firewall that decides in milliseconds — with zero model calls at check time. Deploy open-source Claix Core (Apache-2.0) as a private sidecar, or run staging and production on Claix Cloud with Slack approvals and a central audit log.
The problem
Why production agents need a deterministic perimeter (and why bypass is impossible here)
Unlike local coding editors with open shell access, a production AI agent can only touch what your backend code wires up. Teams that hand an LLM tool direct access to an application database pool — or put a second “judge LLM” in front of SQL — hit three production failure modes.
- Cross-tenant data leaks on reads: relying on a system prompt (“Only query rows where customer_id = 42”) fails the moment prompt injection or complex joins enter the conversation. Tenant isolation must be rewritten and enforced at the SQL layer, never trusted to model compliance.
- Unbounded blast radius on writes: a support agent authorized to cancel one pending order should never cancel 5,000 paid orders, burst 200 deletes in a loop, or run ALTER, DROP, or TRUNCATE. Static SQL linters cannot see how many live rows a WHERE clause will hit.
- LLM-as-a-judge latency and cost: calling another model on every database tool call adds hundreds of milliseconds, burns token budgets, and still guesses probabilistically.
Architecture
Check-Then-Execute that an agent cannot bypass
The agent holds zero database credentials
Your LLM never sees a connection string. For reads, your tool handler calls Claix (POST /retrieve/:agent or MCP). For writes, your tool handler sends the proposed SQL to POST /check-sql first and executes it on your write pool only when Claix returns an explicit allow.
Row-scoped retrieval per portal or role
Each agent configuration carries its own scope rules and call_limit. Scope predicates wrap every query automatically, so an acme-portal agent physically cannot return another tenant's rows — whether it uses parameterized fixed SQL routes or guarded open queries.
Affected-row preflight + rate caps
Using a read-only claix_agent role, Claix parses the statement, inspects the actual rows a write would touch, checks action frequency windows (recent_actions), and returns allow, deny, or needs_approval in milliseconds without running the write.
Deny-by-default & session-safe
Without an active permission covering that exact operation, writes are denied. A permission for a targeted DELETE never covers DROP, ALTER, or GRANT, and session commands that could disable security — switching roles or turning off RLS — cannot be permitted.
Core vs Cloud
Sidecar Claix Core vs hosted Claix Cloud in production
Both editions run the same SQL check. Match your infrastructure, latency, and governance requirements.
| Production requirement | Claix Core (Open Source · VPC Sidecar) | Claix Cloud (Hosted · Managed Governance) |
|---|---|---|
| Architecture | Self-hosted container (ghcr.io/claix-dev/claix-core, Node.js 22+, Apache-2.0) inside your VPC, Kubernetes cluster, or Docker network. | Managed service at claix.dev with database credentials encrypted in Cloud Vault. Zero sidecars to monitor. |
| Protocols | Private HTTP (POST /check-sql, POST /retrieve/:agent) and MCP (POST /mcp or stdio). | REST, MCP (https://claix.dev/mcp), and Agent-to-Agent (A2A), plus Claix Ingest when needed. |
| Human-in-the-loop (needs_approval) | Returns needs_approval JSON so you can wire your own internal ticket or webhook queue. | Built-in Slack approvals: high-value refunds, cancellations, or sensitive updates land in a Slack channel for 1-click sign-off. |
| Policy updates during incidents | Edit YAML mounted read-only (./claix:/claix:ro), run claix validate in CI, and redeploy. | Update guards, scopes, or limits live from the visual dashboard — zero container rebuilds. |
| Environments & teams | One deployment and one YAML directory per instance. | Isolated workspaces for dev, staging, production, and separate product teams under one organization. |
| Audit & rate-limit memory | Appends to local traces.jsonl; keeps 32 days / up to 50,000 events in memory (rereading the last 8 MB on restart) for recent_actions and call_limit. | Central company audit log across every microservice, agent, and workspace — durable across restarts and autoscaling. |
Choose your edition
When to run Core vs Cloud in production
When to run Claix Core in production
Choose Core when compliance requires zero external network hops (every check stays on http://claix:8787 inside your private network), when you want GitOps-driven YAML policies validated in CI via claix validate, or when you are building your own approval UI around needs_approval.
When to run Claix Cloud in production
Choose Cloud when you run stateless or serverless backends (Vercel, AWS Lambda, Cloud Run, edge workers) where maintaining stateful traces.jsonl volumes across replicas is friction, when ops leads need Slack approvals out of the box, or when security wants a central audit log and instant policy hotfixes without a redeploy.
Option 1 · Claix Core
Deploy Claix Core as a production sidecar (open source)
Validate every permission, route, and agent scope against your database catalog in CI, then run ghcr.io/claix-dev/claix-core alongside your backend with ./claix mounted read-only and a persistent volume for CLAIX_DATA_DIR so traces.jsonl preserves recent_actions and call_limit across restarts.
Add USER_LLM_KEY only if your agents answer open natural-language questions or use reasoned mode. Fixed routes and POST /check-sql require no model key at all.
Validate in CI
npx -y @claix-dev/core validate
docker-compose sidecar
services:
claix:
image: ghcr.io/claix-dev/claix-core
restart: unless-stopped
environment:
CLAIX_API_KEY: ${CLAIX_API_KEY}
CLAIX_DB_ENGINE: postgres
CLAIX_DB_HOST: db.internal
CLAIX_DB_NAME: app
CLAIX_DB_USER: claix_agent
CLAIX_DB_PASSWORD: ${CLAIX_DB_PASSWORD}
CLAIX_DB_SSL: require
CLAIX_CONFIG_DIR: /claix
CLAIX_DATA_DIR: /data
volumes:
- ./claix:/claix:ro
- claix_data:/data
volumes:
claix_data:Check-Then-Execute (TypeScript)
const CLAIX_URL = process.env.CLAIX_URL ?? "http://claix:8787";
const CLAIX_HEADERS = {
"Content-Type": "application/json",
"x-api-key": process.env.CLAIX_API_KEY!,
};
// 1. Scoped Read Tool — e.g. agent "acme-portal" only sees Acme's rows
export async function askScopedDatabase(
agentName: string,
questionOrParams: Record<string, unknown>,
) {
const res = await fetch(`${CLAIX_URL}/retrieve/${agentName}`, {
method: "POST",
headers: CLAIX_HEADERS,
body: JSON.stringify(questionOrParams),
});
if (!res.ok) throw new Error(`Claix retrieve rejected: ${res.status}`);
return res.json();
}
// 2. Governed Write Tool — SQL runs ONLY after deterministic allow
export async function executeGuardedWrite(
sql: string,
dbWritePool: { query: (q: string) => Promise<unknown> },
) {
const checkRes = await fetch(`${CLAIX_URL}/check-sql`, {
method: "POST",
headers: CLAIX_HEADERS,
body: JSON.stringify({ sql }),
});
const verdict = await checkRes.json();
if (verdict.needs_approval) {
return { status: "pending_human_approval", reason: verdict.reason };
}
if (!verdict.allowed) {
return { status: "denied", reason: verdict.reason };
}
// Explicitly permitted by Claix Guard -> safe to execute on write pool
const result = await dbWritePool.query(sql);
return { status: "executed", result };
}Option 2 · Claix Cloud
Connect production agents to Claix Cloud (Slack approvals & central audit)
When agents run across serverless functions, multiple services, or customer-facing operations where risky actions need a human in Slack, point your agent backend or MCP client at Claix Cloud.
- REST & HTTP: authenticate with your workspace Cloud API key (Authorization: Bearer ${CLAIX_CLOUD_API_KEY}) against hosted endpoints at https://claix.dev — no sidecar or disk volume to manage.
- MCP & A2A: connect frameworks speaking Model Context Protocol (https://claix.dev/mcp) or Agent-to-Agent (A2A) directly to your workspace agents (claix_retrieve_ask, claix_guard_check).
- Native Slack approvals: when an agent proposes a statement matching needs_approval_when (for example, cancelling a high-value order), Claix Cloud routes the request into your configured Slack channel.
Migrate
Start with a Core sidecar, import into Claix Cloud anytime
If you launch on Claix Core and later want Slack approvals, multi-team workspaces, a visual policy dashboard, and a centralized audit log, you do not have to rewrite a single rule.
- 01
Gather your Core files
Collect your Core .env (CLAIX_DB_HOST, CLAIX_DB_PORT, CLAIX_DB_NAME, CLAIX_DB_USER=claix_agent, CLAIX_DB_PASSWORD, and CLAIX_DB_SSL=require or verify-full), plus claix/guards/*.yaml, claix/routes/*.yaml, claix/agents/*.yaml, and optionally traces.jsonl (up to 8 MB; Cloud imports the newest 2,000 events). If you use Supabase, ensure CLAIX_DB_USER=claix_agent on a direct host that accepts that role rather than a pooler username like claix_agent.projectref.
- 02
Open Import from Core
Sign in at /dashboard/database-connection as the workspace owner and click Import from Core.
- 03
Upload and import
Upload your files and choose Import into Cloud. Any error detected before the connection saves aborts cleanly without half-applying anything and lists every issue by filename.
- 04
Go live on Cloud
Your database password moves into Cloud Vault, deny-by-default permissions and row scopes remain intact, and your agents are immediately live on the Cloud API with Slack approval support.
Frequently asked questions
- Can a production AI agent bypass Claix to run unauthorized SQL?
- No. In production, the AI agent holds zero database credentials. Your backend routes reads through Claix scoped agents and checks every proposed write via POST /check-sql, executing the SQL statement on your write pool only after Claix returns an explicit allow verdict.
- How much latency does Claix add to production AI agent tool calls?
- Deciding whether a SQL statement is allowed never calls an AI model in either Claix Core or Claix Cloud. Claix parses the statement deterministically, inspects affected rows via a read-only database role, and returns allow, deny, or needs approval in milliseconds.
- How does multi-tenant row isolation work for customer-facing AI agents in Claix?
- Each Claix agent defines row scope rules that travel with every query across both fixed SQL templates and open natural-language reads, ensuring a portal or role agent can never access rows belonging to another customer.
- What happens in production when a SQL write triggers needs_approval in Claix?
- Execution halts before touching data. Claix Core returns a needs_approval verdict for your own workflow, while Claix Cloud routes the statement directly to Slack so an authorized teammate can review and approve it from a channel.
Ship production agents with a deterministic SQL perimeter
Check-Then-Execute over HTTP or MCP, multi-tenant scopes, and Slack approvals when you need a human in the loop. Start with a Core sidecar, or scale on Claix Cloud.