schemagate
demo in the browser
Working when we checked on .
What is schemagate?
schemagate selects which database tables an AI agent may read before any SQL is written, showing a caller only the tables permitted by their role and cutting prompt tokens by 65–97%. It is aimed at developers building natural-language SQL or text-to-SQL tools on any SQLAlchemy-supported database. It ships as a Python package and an MCP server usable from clients like Cursor or Windsurf, plus a local studio for exploring a schema. Optional AI-generated table descriptions work with Anthropic, OpenAI, Gemini, OCI keys or a free local model, and only schema metadata is ever sent, never rows.
schemagate pricing
Pricing model: Free
Open source, Apache-2.0 licensed
schemagate pros
- Filters tables by caller role before the model writes any SQL
- Cuts prompt tokens 65–97% on supported schemas
- Works with any SQLAlchemy database
- Available as Python package, MCP server, and local studio
- Only schema metadata is sent to AI providers, never table rows
- Free local model option when no API key is available
schemagate cons
- Local model option downloads about 3 GB and runs on CPU only
- The 1.5B local model writes noticeably weaker descriptions than hosted models
- Backup and staging schema copies are demoted rather than fully excluded from ranking
Frequently asked questions about schemagate
What does schemagate do?
It shows an AI model only the database tables the current caller is allowed to read, decided before any SQL exists, and cuts prompt tokens by 65–97%. It works with any SQLAlchemy database.
Who is schemagate for?
It is for developers building natural-language, text-to-SQL, or AI agent tools that query relational databases, especially where different users or roles should see different parts of the schema.
How do I install schemagate?
Install it with pip via 'pip install schemagate'. An MCP variant is available as 'pip install schemagate[mcp]' and a local studio can be run with 'schemagate studio --url <database url>'.
Does schemagate read or send my table data?
No. It reads only schema metadata — names, types, and foreign keys. No rows are read unless you ask, nothing leaves your machine, and only schema metadata is ever sent to an AI provider.
Which databases are supported?
Any database supported by SQLAlchemy, such as the PostgreSQL example shown in the docs, can be used as the data source.
How does it cut prompt tokens?
It selects only the relevant, permitted tables for a query. In the demo, 9 of 42 objects are selected, cutting prompt tokens from 2,662 to 620, a 77% saving that grows with schema size up to 97% on a 260-object test schema.
Which AI providers can generate table descriptions?
Anthropic, OpenAI, Gemini, or OCI API keys are supported for generating descriptions. A free local model is also available when no key is an option.
What are the limits of the free local model?
It downloads about 3 GB the first time, runs on the CPU, and the 1.5B model writes noticeably weaker descriptions than a hosted one. The docs describe it as not the way to see schemagate at its best.
Can I use schemagate from Cursor or Windsurf?
Yes. Install with 'pip install schemagate[mcp]' and run 'python -m schemagate.mcp_server' with SCHEMAGATE_DATABASE_URL set, then connect any MCP client.
What license is schemagate released under?
It is open source under the Apache-2.0 license, with source code at github.com/ashishsinha1602/schemagate.