# Schemagate

> Schemagate is an open-source MCP server for databases. Text-to-SQL schema selection that sends only the tables the caller may read. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, self-hosted
- **Repository:** https://github.com/ashishsinha1602/schemagate
- **MCP Registry name:** io.github.ashishsinha1602/schemagate
- **Categories:** [databases](https://ai-powered.com/categories/databases), [AI models and LLM tooling](https://ai-powered.com/categories/ai-and-llm)
- **Listing updated:** 2026-11-18

## About

A text-to-SQL prompt that carries a whole schema spends most of its tokens on tables the question never needs. schemagate picks a handful of relevant tables first and filters by the caller's grants before ranking, so a restricted table is absent from the prompt rather than ranked low. The README argues this avoids the quiet failure of row-level security alone, where the model writes valid SQL against a table the caller cannot read and the user sees empty results.

The README reports a median 91.1 percent reduction in schema tokens on databases with 50 or more tables, and on small schemas such as BIRD's the saving is closer to 9 percent, with a table occasionally left out. It also reports first place on BIRD Mini-Dev for three dialects using Claude Opus 5.5. These are the project's own figures.

It reflects a database through a SQLAlchemy URL set in SCHEMAGATE_DATABASE_URL, or a bundled demo schema, with an optional catalog JSON for roles, hints and shadow-name overrides. A demo command shows the effect with no database or key. It can print a prompt to paste anywhere, or call OpenAI, Anthropic, Gemini, OCI or a local model, and a local studio page shows what reaches the prompt.

## Features

- **Identity-scoped selection:** Filters tables by the caller's grants before ranking, so restricted ones never reach the prompt.
- **Smaller prompts:** Sends about six relevant tables instead of the whole schema.
- **Keyless demo:** Runs a bundled 42-object schema in the CLI or in the browser with no database.
- **Studio page:** A local page to type questions, switch roles, edit hints and see what is included.
- **Provider choice:** Can answer through OpenAI, Anthropic, Gemini, OCI or a local model, or print a prompt.
- **Framework fit:** Works with LangChain, LlamaIndex, MCP or any SQL agent.

## Good for

- Cut schema tokens for a large warehouse
- Keep payroll or clinical tables out of an analyst agent's prompt
- Check which tables a role would expose
- Move from Vanna to identity-aware schema selection
- Try text-to-SQL locally without a database

## Install

### Claude Code (Terminal)

```sh
claude mcp add schemagate --env SCHEMAGATE_DATABASE_URL='<SCHEMAGATE_DATABASE_URL>' -- uvx schemagate
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "schemagate": {
      "command": "uvx",
      "args": [
        "schemagate"
      ],
      "env": {
        "SCHEMAGATE_DATABASE_URL": "<SCHEMAGATE_DATABASE_URL>"
      }
    }
  }
}
```

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "schemagate": {
      "command": "uvx",
      "args": [
        "schemagate"
      ],
      "env": {
        "SCHEMAGATE_DATABASE_URL": "<SCHEMAGATE_DATABASE_URL>"
      }
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "schemagate": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "schemagate"
      ],
      "env": {
        "SCHEMAGATE_DATABASE_URL": "<SCHEMAGATE_DATABASE_URL>"
      }
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "schemagate": {
      "command": "uvx",
      "args": [
        "schemagate"
      ],
      "env": {
        "SCHEMAGATE_DATABASE_URL": "<SCHEMAGATE_DATABASE_URL>"
      }
    }
  }
}
```

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "schemagate": {
      "command": "uvx",
      "args": [
        "schemagate"
      ],
      "env": {
        "SCHEMAGATE_DATABASE_URL": "<SCHEMAGATE_DATABASE_URL>"
      }
    }
  }
}
```

## FAQ

### Is a database required to try it?

No. The demo command and the browser page use a bundled schema with no database, key or model call.

### Which variables does the MCP server use?

SCHEMAGATE_DATABASE_URL, required, takes a SQLAlchemy URL or demo; SCHEMAGATE_CATALOG_CONFIG optionally points to a JSON file.

### Can a needed table be missed?

Yes. The README says cutting can leave a table out, and gives measured recall figures from its benchmarks.

### How do I install it?

pip install schemagate, or pipx and uvx from PyPI; it needs a recent Python.

### Is Schemagate free?

Yes. Schemagate is open source, so you can use and self-host it for free.

### How do I add Schemagate to Claude Code?

Run this command in your terminal: claude mcp add schemagate --env SCHEMAGATE_DATABASE_URL='<SCHEMAGATE_DATABASE_URL>' -- uvx schemagate

### What are the best alternatives to Schemagate?

The closest alternatives to Schemagate are headroom, omniget, next-ai-draw-io, mcp-for-blender and Claude Code Ultimate Guide.

## Where this comes from

- Description: written from the project's README.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [headroom](https://ai-powered.com/mcp/headroom-3): headroom is an open-source MCP server for ai models and llm tooling.
- [omniget](https://ai-powered.com/mcp/omniget): omniget is an open-source MCP server for ai models and llm tooling.
- [next-ai-draw-io](https://ai-powered.com/mcp/next-ai-draw-io-2): next-ai-draw-io is an open-source MCP server for ai models and llm tooling.
- [mcp-for-blender](https://ai-powered.com/mcp/mcp-for-blender): mcp-for-blender is an open-source MCP server for design and media.
- [Claude Code Ultimate Guide](https://ai-powered.com/mcp/claude-code-ultimate-guide): Claude Code Ultimate Guide is an open-source MCP server for ai models and llm tooling.
- [unity-mcp](https://ai-powered.com/mcp/unity-mcp-2): unity-mcp is an open-source MCP server for ai models and llm tooling.
- [fastapi_mcp](https://ai-powered.com/mcp/fastapi-mcp): fastapi_mcp is an open-source MCP server for ai models and llm tooling.
- [tyk](https://ai-powered.com/mcp/tyk): tyk is an open-source MCP server for developer tools.

---
Source: https://ai-powered.com/mcp/schemagate
