Skip to content
ThiruvarankanMPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

SafeBase

SafeBase stops your database from getting accidentally destroyed.

It sits between your app and your database. You change one line — your connection string — and every dangerous query gets caught before it runs.


Install (one line)

curl -fsSL https://raw.githubusercontent.com/ThiruvarankanM/SafeBase/main/install.sh | sh

This will:

  • Download the right binary for your OS and architecture
  • Install safebase-proxy and safebase-mcp to /usr/local/bin
  • Create a default safebase.yml in your current directory
  • Auto-configure Claude Desktop as an MCP server (if installed on macOS)
  • Print the config snippet for Cursor

The Problem

Every day, databases get wiped by accident.

  • A developer runs DELETE FROM users without a WHERE clause
  • An AI agent (Claude, Cursor, Copilot) executes DROP TABLE without understanding what it does
  • Someone runs a migration on production thinking it's dev

There's no undo button. The data is gone.


How SafeBase Fixes It

Before:   Your App  →  Database
After:    Your App  →  SafeBase  →  Database

SafeBase reads every query before it reaches your database. Depending on how dangerous it is:

Risk Example What happens
Low SELECT *, INSERT Passes through instantly
Medium DELETE WHERE id = 5 Slack alert, 60 seconds to cancel
Critical DROP TABLE, DELETE without WHERE Blocked — needs a human to approve
AI Agent Any write Always needs human approval

Option 1 — Database Proxy

Change one line in your app:

# Before
DATABASE_URL=postgresql://user:pass@your-db:5432/mydb

# After (just change the host + port)
DATABASE_URL=postgresql://user:pass@localhost:5433/mydb

Start SafeBase:

docker compose up -d

Your app works exactly the same. SafeBase is invisible until something dangerous runs.


Option 2 — MCP Server (Claude / Cursor)

After running the install script, SafeBase is already added to Claude Desktop automatically.

For Cursor, add this to .cursor/mcp.json in your project:

{
  "mcpServers": {
    "safebase": {
      "command": "/usr/local/bin/safebase-mcp",
      "args": ["--config", "/path/to/safebase.yml"]
    }
  }
}

Once connected, every database query from Claude or Cursor routes through SafeBase. AI tools get read-only access by default. Destructive operations are blocked automatically.

The AI tools will see these SafeBase tools:

  • safebase_query — run a SQL query through safety checks
  • safebase_classify — preview the risk level before running
  • safebase_pending — list queries waiting for approval
  • safebase_approve / safebase_cancel — approve or reject

What You Get

  • Approval dashboard — http://localhost:3000 to approve/cancel queries in one click
  • Slack alerts — notified before anything dangerous runs, with approve/cancel buttons
  • Audit log — every write logged forever, tamper-proof
  • Shadow execution — run query on a copy first, see exact row impact before touching real data
  • AI agent protection — Claude, Cursor, Copilot blocked from destructive operations
  • MCP server — native integration with all MCP-compatible AI tools
  • Metrics — http://localhost:9090/metrics (Prometheus-compatible)
  • TLS — encrypted proxy connections supported

User Roles

Role What they can do
dba Approve anything, full access
developer Read + safe writes
ai_agent Read-only — all writes need approval
auditor View audit logs only

Configuration

Edit safebase.yml:

database:
  host: your-real-database-host
  postgres_port: 5432

notifications:
  slack:
    enabled: true
    webhook_url: https://hooks.slack.com/your-webhook

environment: production

Docker

# Start everything (proxy + dashboard + Redis)
docker compose up -d

# Proxy:     localhost:5433 (PostgreSQL), localhost:3307 (MySQL)
# Dashboard: http://localhost:3000
# Metrics:   http://localhost:9090/metrics

Project Layout

cmd/proxy/       → proxy server
cmd/mcp/         → MCP server (for Claude/Cursor)
internal/
  config/        → reads safebase.yml
  parser/        → SQL risk classification
  proxy/         → PostgreSQL + MySQL wire protocol handlers
  approval/      → Redis queue + Slack notifications
  audit/         → immutable audit log
  auth/          → JWT-based RBAC
  shadow/        → dry-run execution on shadow DB
  metrics/       → Prometheus metrics + /health
mcp/             → MCP JSON-RPC protocol server
dashboard/       → Next.js approval UI

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages