schemagate: identity-scoped schema selection for text-to-SQL

Shows the model only the tables this caller may read, before any SQL exists, and cuts prompt tokens 65–97%. Any SQLAlchemy database. pip install schemagate.

schemagatestudio
demo · runs in your browser · no database connected pip install schemagate
What this is. A demo of schemagate, running entirely in this browser tab on six invented example schemas. It is not connected to any database and does not call any AI model. The real thing is pip install schemagate, which runs on your own database.
The one thing to see. A user only gets the tables they are allowed to see — before the model writes any SQL.
Selected
Prompt tokens
Saved vs full schema
What that is worth at queries/day and $/M input tokens: per month on schema tokens, saved your numbers, your prices — this only multiplies the token counts above. Savings grow with schema size: the 260-object test schema is 97%.
pre-written examples of what a model would produce — no model is called on this page. With your own key, cat.describe(...) generates these for real.

Selected objects

    What the model receives

    
          

    Hidden from this caller

    These exist in the catalog but never reach the prompt for this identity. Not de-ranked — absent.

    Backup and staging copies demoted

    A copy carries the same name words in a shorter document, and cosine similarity rewards exactly that. These are ranked below the object they shadow — unless you name them outright.

    Use it from Python

    pip install schemagate
    
    from schemagate import Catalog, Principal
    cat = Catalog().bootstrap("postgresql://localhost/app")
    cat.select("revenue by month",
               principal=Principal("okta:jdoe", roles={"finance"}))

    Use it from Claude Desktop, Cursor, any MCP client

    pip install 'schemagate[mcp]'
    SCHEMAGATE_DATABASE_URL=postgresql://localhost/app \
      python -m schemagate.mcp_server

    Run this studio on your own database

    pip install schemagate
    schemagate studio --url postgresql://localhost/app

    Same page, your schema, nothing leaves your machine. github.com/ashishsinha1602/schemagate · Apache-2.0 · Ashish Sinha