Skip to content

feat: Add --autocommit flag to support database proxies#165

Open
jwee0330 wants to merge 1 commit into
crystaldba:mainfrom
jwee0330:feat/autocommit-mode
Open

feat: Add --autocommit flag to support database proxies#165
jwee0330 wants to merge 1 commit into
crystaldba:mainfrom
jwee0330:feat/autocommit-mode

Conversation

@jwee0330
Copy link
Copy Markdown

@jwee0330 jwee0330 commented Apr 3, 2026

Some database proxies (e.g. QueryPie, PgBouncer in transaction mode) block explicit transaction control statements (BEGIN/COMMIT/ROLLBACK). This makes it impossible to connect via postgres-mcp since psycopg's connection pool implicitly wraps queries in transactions.

The --autocommit flag enables psycopg's autocommit mode on the connection pool, so each statement executes independently without implicit BEGIN. Can also be set via DATABASE_AUTOCOMMIT env var.

Changes:

  • Add --autocommit CLI flag and DATABASE_AUTOCOMMIT env var to server.py
  • Add autocommit parameter to DbConnPool.pool_connect()
  • Skip BEGIN/COMMIT/ROLLBACK in SqlDriver._execute_with_connection() when connection is in autocommit mode
  • Add unit tests for autocommit behavior
  • Update README with configuration example

Some database proxies (e.g. QueryPie, PgBouncer in transaction mode)
block explicit transaction control statements (BEGIN/COMMIT/ROLLBACK).
This makes it impossible to connect via postgres-mcp since psycopg's
connection pool implicitly wraps queries in transactions.

The --autocommit flag enables psycopg's autocommit mode on the
connection pool, so each statement executes independently without
implicit BEGIN. Can also be set via DATABASE_AUTOCOMMIT env var.

Changes:
- Add --autocommit CLI flag and DATABASE_AUTOCOMMIT env var to server.py
- Add autocommit parameter to DbConnPool.pool_connect()
- Skip BEGIN/COMMIT/ROLLBACK in SqlDriver._execute_with_connection()
  when connection is in autocommit mode
- Add unit tests for autocommit behavior
- Update README with configuration example
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.

1 participant