Skip to main content
Glama
foxter-io

PostgreSQL MCP Server

by foxter-io

Execute Multiple Statements in a Transaction

pg_transaction
Destructive

Execute multiple SQL statements atomically, rolling back all changes if any statement fails. Ideal for ensuring consistency in multi-step operations.

Instructions

Execute multiple SQL statements atomically in a single transaction.

All statements succeed or all are rolled back. Ideal for multi-step operations that must be atomic (e.g., insert + update, schema migrations).

Args:

  • statements: Array of SQL statements to execute in order (required)

  • confirm_destructive: Required if any statement is DROP/TRUNCATE/DELETE-without-WHERE

Returns: JSON: { results: [{command, rows_affected}], total_duration_ms, rolled_back: false } On error: { error, rolled_back: true, failed_at_index: number }

Examples: statements: ["INSERT INTO orders ...", "UPDATE inventory SET qty = qty - 1 WHERE ..."]

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
statementsYesSQL statements to execute in order within a transaction
confirm_destructiveNoSet true if any statement is destructive (DROP/TRUNCATE/DELETE without WHERE)
timeout_msNoPer-statement timeout in milliseconds
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Description details atomic rollback behavior, confirms destructive hint from annotations, explains error response with rolled_back and failed_at_index, adding significant context beyond annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Description is concise with clear sections: purpose, behavior, parameters, return format, and example. All sentences are essential without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers all key aspects: atomicity, parameters, return format, error handling, and destructive confirmation. Appropriate for a transaction tool with no missing information despite lack of output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, but description adds value by explaining statements as required array, clarifying confirm_destructive as mandatory for destructive operations, and providing usage examples.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description explicitly states 'Execute multiple SQL statements atomically in a single transaction' with a specific verb and resource, clearly distinguishing it from siblings like pg_execute which executes individual statements without transaction guarantees.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Description indicates ideal use for atomic multi-step operations and provides examples, but does not explicitly state when not to use or contrast with non-transactional execution alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/foxter-io/mcp-postgresql'

If you have feedback or need assistance with the MCP directory API, please join our Discord server