SuperAPIAI Directory

schemabrain

github.com · AI coding

Read-only Postgres access with SQL compiled from your own definitions, PII refusal and a tamper-evident audit chain.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux

About this tool

SchemaBrain is a database trust and intelligence layer for AI agents, designed to address the security and compliance risks brought by agents directly accessing databases. Through a read-only architecture, a semantic knowledge graph, and a tamper-evident audit log, it provides agents with controlled database access capabilities.

Purpose

The core purpose of SchemaBrain is to enable AI agents to safely query databases without directly touching raw SQL or database connection strings. It acts as an intermediary layer between agents and the database, ensuring that all queries are compiled and generated based on a user-predefined semantic layer (entities, metrics, joins), thereby preventing agents from generating arbitrary SQL statements.

Main Capabilities

  1. Architecture-level read-only: SchemaBrain exposes 12 tools via MCP, none of which have write capabilities. There is no execute() or query() tool, so agents cannot perform write operations on the database through any path.
  2. PII-aware rejection: PII tags propagate from the physical schema into joins and metrics. If a query involves a blocked PII category, SchemaBrain rejects the request before querying the database. Catastrophic disclosure categories (credential, payment_card, government_id) are blocked by default and can be adjusted via --pii-block.
  3. Tamper-evident audit chain: Every tool call, rejection, and recovery is recorded in a SHA256-hashed append-only log. The audit verify command re-traverses the chain and returns a non-zero exit code if any historical row has been rewritten.
  4. Structured recovery: All unsuccessful calls return a structured recovery.suggested_args block rather than a string that needs to be parsed. For example, PII blocks return retryable entities, and ambiguous dimensions return candidate options.
  5. Compilation path: Entities, metrics, and canonical joins are compiled into parameterized SQL, which is executed by SchemaBrain on its own side. Agents can only see the result rows and the executed SQL, and cannot send arbitrary statements to the database.
  6. Pluggable: The same MCP stdio interface can be used by any MCP host, including Anthropic, OpenAI, or LangGraph loops.

Usage

  1. Quick trial: Run uvx schemabrain demo to start the built-in demo. No API key is required. It builds a sample SaaS layer and opens a dashboard or terminal firewall display.
  2. Initialize: Run uvx schemabrain init to start the seven-stage wizard. You can paste your own Postgres URL, or press Enter to use the built-in demo database (which automatically invokes Docker). You can optionally provide ANTHROPIC_API_KEY for entity suggestions.
  3. Integrate into an MCP host:schemabrain init --host <X> can be written directly into the configuration for Claude Desktop, Claude Code, Cursor, and Windsurf. Other MCP stdio hosts can use --host manual to print a JSON snippet for manual pasting.
  4. Restart the host: Fully quit and restart the MCP host (for example, Claude Desktop requires Cmd+Q), then in a new conversation ask about entities known to SchemaBrain.
  5. Operations commands:schemabrain inspect to view what is available to the agent,schemabrain tail to view tool calls in a real-time stream.
  6. Customize the semantic layer: Use --emit-yaml-dir to generate an editable YAML file. After editing, run schemabrain apply ./schemabrain to apply it,schemabrain check Verification.

Applicable Scenarios

  • Scenarios where AI agents need to query production databases, but read-only access must be guaranteed.
  • Organizations with strict PII compliance requirements (GDPR, CCPA, HIPAA, PCI).
  • Scenarios where all database access records by agents need to be audited.
  • Developers using MCP hosts such as Claude Desktop, Claude Code, Cursor, and Windsurf.
  • Teams that want to provide agents with a controlled semantic layer rather than raw database access.

Limitations

  • The current version is 0.6.0 (beta), and only Postgres data sources are supported (local storage is SQLite). SQLite, Snowflake, BigQuery, and MySQL connectors are on the roadmap.
  • Cloud/HTTPS hosts are not supported.
  • PII detection is based on column name pattern matching; content-aware classification is on the roadmap.
  • The audit chain is best-effort: when the disk is full or no writer is configured, it logs a warning and continues rather than failing the query.
  • The dashboard binds only to 127.0.0.1, has no --host flag, and is read-only by design.
  • No dedicated adapters are provided for each framework; it relies on the framework's standard MCP client.
  • Some MCP hosts (such as Zed, Codex CLI, Cline, and Continue) have documentation guidance, but not all clients have been exhaustively tested.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools