An AI agent cannot write a reliable database query from table names alone.
It needs context:
- what each table means
- which rows are active
- which timestamps define freshness
- which joins are approved
- which columns should not be used for reporting
- where tenant scope lives
- what a safe example query looks like
Raw schema is not enough.
A column named status might mean subscription state, invoice state, support state, or deployment state. A table named events might be telemetry, billing events, audit events, or analytics.
If the MCP server hands the model a raw catalog and says “good luck,” the model will guess.
Better pattern:
- expose curated table descriptions
- document approved join paths
- include safe query examples
- separate schema discovery from query execution
- track context freshness/version
- make stale context visible before the answer
Longer version: Schema context for MCP database agents
The model does not just need access to the database. It needs the map.
Top comments (0)