DEDUPED Hot AI repos, turned into use cases Get the Monday 5

How to gate the schema inside a SQL agent's Python code with Schemagate

Load a catalog, restrict a table to one role, and pass only the selected schema fragment into your agent prompt.

Who it is forA developer shipping a LangChain or MCP SQL agent who must make sure the system prompt never names tables the caller cannot read.

The problemAgent frameworks typically build the schema prompt before any access check, which leaks table names and structure to the model.

The outcomeYour agent's system prompt contains only the selected DDL, and a restricted table's name does not appear anywhere in the prompt text.

What you need first

  • Python and pip installed
  • For your own database: a reachable Postgres, Oracle, MySQL or SQL Server URL, and the matching schemagate extra
  • Optional: a model key only if you want generated answers or AI descriptions

Steps

  1. Run pip install schemagate and install the driver extra for your database, such as pip install 'schemagate[postgres]'.
  2. In Python, create the catalog with Catalog().bootstrap("postgresql://localhost/app") or load the bundled one with demo_catalog().
  3. Call cat.restrict("hr_compensation", ["payroll"]) to limit that table to the payroll role.
  4. Call cat.select("revenue by month", top_k=6, principal=Principal("okta:jdoe", roles={"finance"})) and pass sel.prompt_fragment() into your system prompt. (inferred, check the README)

Prompt for your agent

Using the schemagate Python API, bootstrap a Catalog from <database-url>, restrict the table <restricted-table> to the role <role>, and select tables for the question <question> for a Principal with that role. Return sel.prompt_fragment() and confirm the restricted table name does not appear in it.

Caveat. The README's example uses Catalog and Principal calls that you must verify against the installed version, since the library's documented API is what this depends on.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for ashishsinha1602/schemagate and "Gate the schema inside a SQL agent's Python code"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer