Read-Only Mode
Read-only mode blocks all modification operations, allowing only SELECT queries.
Configuration
Section titled “Configuration”# Enable read-only modeMSSQL_READ_ONLY=trueBehavior
Section titled “Behavior”Allowed operations
Section titled “Allowed operations”-- All SELECT queriesSELECT * FROM usersSELECT u.*, o.total FROM users u JOIN orders o ON u.id = o.user_id
-- SubqueriesSELECT * FROM (SELECT id, name FROM users) sub
-- CTEsWITH active AS (SELECT * FROM users WHERE active = 1)SELECT * FROM active
-- Aggregations and window functionsSELECT department, AVG(salary) FROM employees GROUP BY departmentBlocked operations
Section titled “Blocked operations”-- Data modificationsINSERT INTO users VALUES (1, 'test') -- BlockedUPDATE users SET name = 'new' WHERE id = 1 -- BlockedDELETE FROM users WHERE id = 1 -- Blocked
-- DDLCREATE TABLE temp (id INT) -- BlockedDROP TABLE users -- BlockedALTER TABLE users ADD col INT -- Blocked
-- Dangerous code executionEXEC xp_cmdshell 'dir' -- Always blockedEXEC sp_executesql '...' -- Always blockedEXEC sp_configure ... -- Always blockedAllowed administrative and schema reads
Section titled “Allowed administrative and schema reads”Even in read-only mode, a small set of administrative and schema introspection operations are permitted because they are inherently read-only. This makes database discovery much more practical for tools and AI assistants:
-- Safe system procedures for schema explorationEXEC sp_help 'dbo.Users' -- Table structureEXEC sp_helptext 'dbo.MyProcedure' -- Source code of an objectEXEC sp_spaceused 'dbo.Orders' -- Space usage informationEXEC sp_columns @table_name = 'Customers'EXEC sp_fkeys 'Orders'These procedures are explicitly allowed because they do not modify data or server configuration. Any other system procedure (or dynamic SQL via EXEC) remains blocked.
For most schema discovery use cases we recommend the dedicated explore and inspect tools instead of raw queries.
Query validation
Section titled “Query validation”Validation uses regular expressions with word boundaries (\bINSERT\b, \bUPDATE\b, etc.) to avoid false positives. For example:
-- Allowed (does not contain INSERT as an operation)SELECT created_at FROM transactions
-- Allowed (update_count is a column name, not an operation)SELECT update_count FROM statistics
-- Blocked (contains the UPDATE operation)UPDATE users SET status = 'active'Combining with whitelist
Section titled “Combining with whitelist”To allow modifications only on specific tables, combine with MSSQL_WHITELIST_TABLES:
MSSQL_READ_ONLY=trueMSSQL_WHITELIST_TABLES=temp_ai,v_temp_iaSee the Table Whitelist section for more details.