feat: per-database read_only mode with runtime tamper protection#548
Merged
dosco merged 5 commits intodosco:masterfrom Feb 21, 2026
Merged
Conversation
preview_schema_changes and apply_schema_changes used anyDB() and conf.DB, which hit an arbitrary database when multiple are configured. Add a required database parameter so DDL operations target the correct connection, type, and schema. Includes getDBByName helper and tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a `read_only` field to DatabaseConfig that blocks all mutations and DDL against a database. The value is snapshotted at MCP server startup and cannot be changed to false at runtime via MCP tools, preventing LLMs from accidentally modifying production/reporting databases. Enforcement points: - apply_schema_changes blocked on read-only databases - update_current_config preserves read_only: true from startup snapshot - NormalizeDatabases propagates DB-level read_only to role table entries - Admin API exposes readOnly in database stats Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…se-read_only # Conflicts: # serv/mcp_ddl.go # serv/mcp_ddl_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
read_only: trueoption onDatabaseConfigto block all mutations (insert, update, delete) and DDL against adatabase
read_onlyto role-table entries viaNormalizeDatabases(), leveraging existing blockenforcement in the query compiler
read_onlyflags at startup so MCP tools (update_current_config,apply_schema_changes) cannot disable them at runtimedatabaseparameter to DDL tools for explicit multi-db targetingTest plan
serv/mcp_test.go)serv/mcp_ddl_test.go)tests/readonly_test.go)