Integration · Cursor MCP · Open Source (Apache-2.0) & Cloud


Cursor + Claix: The Best Way to Connect Cursor to Your SQL Database
Cursor writes better backend code, migrations, and queries when it can inspect real database state instead of guessing column names from stale files. Yet most developers either keep Cursor blind to the database out of fear, or paste a raw database URL into .cursor/mcp.json and hope Agent never runs the wrong query.
Claix is the best way to connect Cursor to PostgreSQL, MySQL, or MariaDB. Instead of an unrestricted socket — or a rigid read-only wall that still leaks sensitive rows — Claix sits between Cursor and your database with scoped reads and a deny-by-default SQL firewall that decides in milliseconds with zero model calls at check time. Run Core (Apache-2.0) on your machine, or standardize every Cursor seat with Claix Cloud.
The problem
Why raw MCP servers fall short in Cursor
Connecting Cursor directly to a generic PostgreSQL or MySQL MCP server creates two immediate problems.
Too much data on reads, zero safety net on writes: a raw read-only MCP connection still lets Cursor pull unrestricted SELECT * payloads, sensitive columns, or cross-customer rows into prompt context. The moment you ask Agent to fix seed data or run a cleanup — especially with Auto-Run enabled — a standing write credential lets a hallucinated DELETE, TRUNCATE, or DROP execute before you can cancel.
Database rules belong in an engine, not in a prompt. Telling Cursor to “only touch test rows” is a suggestion, not a boundary. One misread .env pointing at staging turns a routine refactor into a data incident.
How Claix helps
What Claix gives Cursor
Claix gives Cursor the database context it needs to ship faster while enforcing hard boundaries in code.
Scoped retrieval built for agents
Cursor asks for data through defined Claix agents and routes. Row scope rules travel with every query, so an agent scoped to one tenant, branch, or test slice never sees rows outside its boundary.
Deny-by-default SQL firewall
A statement passes only when an active permission covers that exact operation. A permission for a targeted DELETE never covers DROP, ALTER, TRUNCATE, or GRANT. Without a match, writes are denied.
Session-escape immunity
Plain SELECT and transaction statements (BEGIN, COMMIT) pass. Session mutations that could turn security off — switching roles or disabling RLS — cannot be permitted.
Pre-flight affected-row inspection
Using a read-only claix_agent role, Claix inspects the rows a proposed write would touch and returns allow, deny, or needs_approval without running the write and without calling an LLM.
Core vs Cloud
Claix Core on your machine vs Claix Cloud for your team
The exact same SQL check in two operational modes — match how you work today without locking yourself in tomorrow.
| Scenario | Claix Core | Claix Cloud |
|---|---|---|
| Ideal setup | Solo developers, local Docker/Postgres stacks, private networks, YAML rules committed with code | Engineering teams sharing staging/production, company-wide Cursor rollouts, compliance and approvals |
| Runtime & license | Open source (Apache-2.0), Node.js 22+ or Docker (ghcr.io/claix-dev/claix-core). No account required | Managed at claix.dev. Credentials in Cloud Vault; no containers or Node versions to watch |
| Cursor MCP setup | Local stdio (npx -y @claix-dev/core mcp) or local HTTP API | Shared remote MCP (https://claix.dev/mcp) committed once in .cursor/mcp.json |
| Approvals (needs_approval) | Returns needs_approval to Cursor so the agent halts before risky SQL | Sends the statement to Slack for a tech lead or DB owner to approve |
| Visibility & audit | Local traces.jsonl on your machine | Central company audit log and workspaces across developers and agents |
| Rule management | Versioned YAML validated against your catalog with claix validate | Visual policy editor in the dashboard — no redeploys for team rule updates |
When to choose which
Why run Core locally — why Cloud for teams
Why open-source Claix Core locally
Even on localhost, a corrupted local database, broken migrations, or an .env still pointed at a remote staging tunnel wastes hours. Core runs next to Cursor with zero signup, validates every route and permission via claix validate, and keeps traffic on your machine.
Why connect team projects to Claix Cloud
When many engineers use Cursor across shared environments, scattering passwords and isolated traces.jsonl files breaks governance. Cloud gives each developer a controlled API key per workspace, encrypts claix_agent credentials in Cloud Vault, routes sensitive changes to Slack, and records every check in one audit log.
Option 1
Set up Claix Core in Cursor
Open source and self-hosted. Register the MCP server in .cursor/mcp.json, then initialize and validate your YAML perimeter.
- 01
Configure .cursor/mcp.json
Create .cursor/mcp.json at the repository root so Cursor launches Claix Core automatically for the project via npx -y @claix-dev/core mcp.
- 02
Initialize and validate
Scaffold ./claix (guards/, routes/, agents/) and verify every rule against your PostgreSQL, MySQL, or MariaDB catalog before Cursor runs its first query.
- 03
Optional Docker quickstart
Clone claix-core and start the Compose quickstart with a pre-seeded sample shop database to try denials and scoped reads live.
Core snippets
.cursor/mcp.json, init/validate, and Docker
Prefer project-scoped MCP config so every checkout gets the same perimeter. Validate against the live catalog before Agent runs queries.
.cursor/mcp.json (Core)
{
"mcpServers": {
"claix": {
"command": "npx",
"args": ["-y", "@claix-dev/core", "mcp"],
"env": {
"CLAIX_API_KEY": "replace-with-local-key",
"CLAIX_CONFIG_DIR": "./claix",
"CLAIX_DB_ENGINE": "postgres",
"CLAIX_DB_HOST": "127.0.0.1",
"CLAIX_DB_NAME": "app",
"CLAIX_DB_USER": "claix_agent",
"CLAIX_DB_PASSWORD": "replace-with-readonly-password"
}
}
}
}Init & validate
npx -y @claix-dev/core init npx -y @claix-dev/core validate
Docker quickstart
git clone https://github.com/claix-dev/claix-core cd claix-core docker compose up -d --build --wait
Option 2
Connect Cursor to Claix Cloud
When the team wants zero local setup, visual rule management, workspaces, central audit logs, and Slack approvals, point .cursor/mcp.json at Claix Cloud. Open Cursor Settings → MCP and confirm the green active indicator next to claix.
.cursor/mcp.json (Cloud)
{
"mcpServers": {
"claix": {
"url": "https://claix.dev/mcp",
"headers": {
"Authorization": "Bearer YOUR_CLAIX_CLOUD_API_KEY"
}
}
}
}Cursor rule
Drop-in .cursor/rules/claix-database.mdc
Make Cursor Agent follow the database perimeter on every prompt — including multi-step Composer / Agent runs — with this alwaysApply rule. Keep raw superuser credentials out of Cursor’s shell environment. Bonus: after editing YAML under ./claix, ask Cursor to run npx -y @claix-dev/core validate, and mount ./claix:/claix:ro so an active agent cannot rewrite its own permissions.
.cursor/rules/claix-database.mdc
--- description: Enforce safe SQL reads and firewall checks through Claix MCP alwaysApply: true --- # Database Access via Claix - Never run raw `psql`, `mysql`, destructive ORM `--force` flags, or unverified SQL scripts directly against the database. - Whenever you need rows or data context to debug or build a feature, call `claix_retrieve_ask` through the `claix` MCP server so route and row scopes are enforced. - Before executing or proposing any `INSERT`, `UPDATE`, `DELETE`, or schema change, call `claix_guard_check` with the exact SQL statement. - Proceed ONLY if `claix_guard_check` returns `allow`. If the verdict is `deny` or `needs_approval`, stop immediately and report the exact reason to the user.
Grow into Cloud
Start in local files, import into Cloud when ready
Starting on Claix Core never means redoing setup later. Copy the entire Core setup into a Claix Cloud workspace in about two minutes.
- 01
Collect Core files
Gather Core .env (CLAIX_DB_* with CLAIX_DB_USER=claix_agent and SSL require or verify-full), plus claix/guards, routes, agents YAML, and optional traces.jsonl (up to 8 MB; Cloud imports the newest 2,000 events).
- 02
Import from Core
Sign in at /dashboard/database-connection as the workspace owner, select Import from Core, upload files, and import into Cloud. Validation errors before the connection saves leave the workspace untouched and list every issue by filename.
- 03
Vault, scopes, Slack
The database password is encrypted in Cloud Vault, deny-by-default permissions and row scopes stay active, and every needs_approval rule can trigger human review in Slack.
Frequently asked questions
- What is the best way to connect Cursor to PostgreSQL, MySQL, or MariaDB safely?
- Connect Cursor over MCP through Claix using either open-source Claix Core (@claix-dev/core, Apache-2.0) on your own machine or hosted Claix Cloud (https://claix.dev/mcp). Claix enforces row-scoped reads and a deny-by-default SQL firewall with zero model calls at check time.
- Does Claix add LLM latency to Cursor Agent SQL checks?
- No. Deciding whether a SQL statement may run never calls an AI model in either Claix Core or Claix Cloud. Claix parses the statement deterministically, inspects the rows a write would affect via a read-only database role, and returns allow, deny, or needs approval.
- Should I use Claix Core (Open Source) or Claix Cloud in Cursor?
- Use Claix Core (Apache-2.0) when you want to run the open-source engine locally via Docker or npx with YAML permissions in Git and no signup. Use Claix Cloud when teams need shared workspaces, visual policy management, Slack approvals, and a central audit log.
- Can I start with Claix Core in Cursor and move to Claix Cloud later?
- Yes. Workspace owners can use Import from Core at /dashboard/database-connection to import their database connection (claix_agent with TLS require or verify-full), guards, routes, agents, and up to 8 MB (newest 2,000 events) of traces.jsonl into Claix Cloud.
Give Cursor real database context — safely
Start with Claix Core beside Cursor on your laptop, then Import from Core when the team needs Slack approvals and a central audit log. Same SQL check either way.