KingbaseES Fences AI Queries with MCP Isolation and Row-Level Audit
AI agents that generate SQL against a production database invalidate the old trust model of human-written, static queries. This architecture shows where to insert isolation, per-row audit, and output filtering, and it's honest about three spots where the design still depends on human decisions.
KingbaseES's KES AI database wraps AI access in three layers: an MCP isolation layer, row-level semantic audit, and full-chain LLM output validation. The premise is that keeping data inside the database is necessary but not sufficient, because AI generates SQL dynamically, reads large contextual chunks, and can produce misleading conclusions even from compliant queries. The design moves permission checking forward: the AI client never holds credentials and only passes query intent to an MCP Server, which validates SQL type, runs risk grading, and forwards only compliant requests to KingbaseES. The database remains the final arbiter, but the first filter happens before the SQL arrives.
Row-level access control ties permissions to specific rows, and audit records semantic context: which business scenario, which agent, which sensitive data tags. That granularity catches query sequences that are individually compliant but together amount to bulk extraction. On the output side, a generate-validate-grade-output loop blocks or flags high-risk model conclusions before they reach users.
The breakdown also names three open questions: the MCP Server's own security, who defines the AI's business permissions with a default of blocking DDL and large DML, and audit log integrity against tampering. The conclusion is that security is a set of continuously running mechanisms, not a one-time switch.
The design builds trust at the protocol layer by stripping the AI of direct database credentials, which is a cleaner pattern than trying to sanitize generated SQL after the fact.
Semantic audit that flags query sequences rather than individual statements treats an AI agent's access pattern as the attack surface, not a single misbehaving query.
The three open questions admit that no database-side mechanism settles who gets to decide what an AI may do; that remains a human policy decision, and a default of banning DDL and bulk DML is a pragmatic stand.
The layer of "who asked AI to query, and why" is equally missing from coding agents. Our team runs all AI tasks on a dedicated machine within the team, credentials are stored only on that machine, permissions are assigned per project, and every access can be traced back to which task was dispatched by whom, so at least it's auditable when something goes wrong. The issue of individual compliance but combined overreach is very real. I'd like to ask: when semantic audit identifies sequences of queries, does it aggregate by session, or by the task that the Agent undertook?