Schemagate
Text-to-SQL schema selection that sends only the tables the caller may read
- Pricing
- Open source
- Platforms
- CLI, self-hosted
- Runs
- Locally
- Version
- 1.18.3
- Listing updated
- today
Similar MCP servers
About Schemagate
Schemagate is an open-source MCP server for databases. It runs locally on your machine and is started by your AI client.
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.
Install
Run in a terminal
claude mcp add schemagate --env SCHEMAGATE_DATABASE_URL='<SCHEMAGATE_DATABASE_URL>' -- uvx schemagateAdd to claude_desktop_config.json
{
"mcpServers": {
"schemagate": {
"command": "uvx",
"args": [
"schemagate"
],
"env": {
"SCHEMAGATE_DATABASE_URL": "<SCHEMAGATE_DATABASE_URL>"
}
}
}
}Add to ~/.cursor/mcp.json
{
"mcpServers": {
"schemagate": {
"command": "uvx",
"args": [
"schemagate"
],
"env": {
"SCHEMAGATE_DATABASE_URL": "<SCHEMAGATE_DATABASE_URL>"
}
}
}
}Add to .vscode/mcp.json
{
"servers": {
"schemagate": {
"type": "stdio",
"command": "uvx",
"args": [
"schemagate"
],
"env": {
"SCHEMAGATE_DATABASE_URL": "<SCHEMAGATE_DATABASE_URL>"
}
}
}
}Add to ~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"schemagate": {
"command": "uvx",
"args": [
"schemagate"
],
"env": {
"SCHEMAGATE_DATABASE_URL": "<SCHEMAGATE_DATABASE_URL>"
}
}
}
}Add to your client's MCP settings (most use this shape)
{
"mcpServers": {
"schemagate": {
"command": "uvx",
"args": [
"schemagate"
],
"env": {
"SCHEMAGATE_DATABASE_URL": "<SCHEMAGATE_DATABASE_URL>"
}
}
}
}Using several servers? Build one config file with the MCP config generator.
Configuration
SCHEMAGATE_DATABASE_URLSQLAlchemy URL of the database to reflect, or 'demo' for the bundled schemaRequiredSCHEMAGATE_CATALOG_CONFIGOptional path to a JSON file with roles, hints and shadow-name overrides
What it does
- 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
Pricing
Open source
Free PyPI package
Schemagate 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.



