Skip to content

feat: allow MCP admin CREATE/ALTER; keep DROP and TRUNCATE blocked - #82

Merged
venkateshsakamuri-lab merged 3 commits into
mainfrom
cursor/mcp-ddl-schema-gate-c497
Aug 25, 2026
Merged

feat: allow MCP admin CREATE/ALTER; keep DROP and TRUNCATE blocked#82
venkateshsakamuri-lab merged 3 commits into
mainfrom
cursor/mcp-ddl-schema-gate-c497

Conversation

@venkateshsakamuri-lab

@venkateshsakamuri-lab venkateshsakamuri-lab commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Coding agents were blocked from DDL because MCP bearer SQL used a hard-coded read-only QueryExecutionContext. Admins can now run DML and non-destructive DDL (CREATE, ALTER, CREATE INDEX) through execute_sql / deepsql query with the same confirmation, privilege, and WHERE gates as the SQL Editor.

DROP and TRUNCATE stay blocked on MCP and coding-agent loops even with confirmMutation: true. The web SQL Editor is unchanged: it still blocks only DROP TABLE; other Editor DROPs and TRUNCATE remain confirm-gated.

apply_index_recommendation is still the only MCP path that can drop an index (server-generated DDL).

Policy

Surface CREATE / ALTER / DML DROP / TRUNCATE
MCP bearer, developer 403 403
MCP bearer, admin, no confirm requiresConfirmation blocked (UNSAFE_MUTATION_BLOCKED)
MCP bearer, admin, confirmMutation=true runs (WHERE still required for UPDATE/DELETE) still blocked
SQL Editor unchanged DROP TABLE blocked; other DROP / TRUNCATE confirmable

Changes

  • QueryExecutionContext.mcp(...) is MAY_MUTATE for admins and accepts mutationConfirmed
  • QueryExecutionPolicyService blocks MCP DROP* / TRUNCATE (including EXPLAIN-wrapped forms)
  • SchemaController and ExplainController pass MCP vs Editor origin plus confirmation through forSqlSurface
  • MCP tool copy, CLI help, agent SOUL, and docs updated; @deepsql/mcp bumped to 0.28.0

Testing

Backend unit tests (QueryExecutionPolicyServiceTest, QueryExecutionContextTest, ExplainControllerPolicyTest, McpTokenServiceTest): 63 passed.

MCP package: npm test — 269 passed.

Live against ACME ERP with an admin MCP token:

  • unconfirmed CREATE TABLEEDITOR_MUTATION_CONFIRMATION_REQUIRED
  • confirmed CREATE TABLE / ALTER TABLE / CREATE INDEX → 200 success
  • confirmed MCP DROP TABLE / TRUNCATE / DROP INDEXUNSAFE_MUTATION_BLOCKED
  • Editor JWT TRUNCATE and DROP INDEX still succeed; Editor DROP TABLE still blocked
Open in Web Open in Cursor 

cursoragent and others added 2 commits August 24, 2026 14:12
Coding agents were stuck on MCP's read-only query context. Admins can now
run DML and non-destructive DDL through execute_sql with the existing
confirmation and WHERE gates. DROP and TRUNCATE stay blocked on MCP even
when confirmed; the SQL Editor still only blocks DROP TABLE.

Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
Mockito strict stubbing failed when ClientContext read other
X-DeepSQL-* headers besides Authorization.

Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
@venkateshsakamuri-lab
venkateshsakamuri-lab marked this pull request as ready for review August 24, 2026 14:15
@venkateshsakamuri-lab
venkateshsakamuri-lab merged commit 93553f4 into main Aug 25, 2026
9 checks passed
@venkateshsakamuri-lab
venkateshsakamuri-lab deleted the cursor/mcp-ddl-schema-gate-c497 branch August 25, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants