Skip to content

read-only mode should reject write SQL in execute_query #56

@BorisTyshkevich

Description

@BorisTyshkevich

Problem

--read-only / clickhouse.read_only=true is currently documented as read-only mode, but execute_query still executes non-read statements (INSERT/CREATE/ALTER/DELETE/etc.) through Exec.

Why this is risky

Users can reasonably expect this flag to enforce write protection at the MCP layer. Today it only affects connection settings behavior, so write statements may still be executed if DB grants permit them.

Expected behavior

When read_only=true, reject non-read statements before execution and return a clear error.

Proposed fix

  • Add a guard in query execution path to block non-read SQL when read_only=true.
  • Keep read statements allowed (SELECT, WITH, SHOW, DESC, EXISTS, EXPLAIN).
  • Update tests and docs to clarify enforced behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions