Skip to main content
Glama
Teja-sudo

postgres-mcp-server

by Teja-sudo

execute_sql_file

Execute SQL files for database migrations, schema changes, or data imports. Supports atomic transactions, validation preview, and pattern stripping for compatibility.

Instructions

Execute a .sql file from the filesystem. Useful for running migration scripts, schema changes, or data imports. Supports transaction mode for atomic execution. Max file size: 50MB. Use validateOnly=true to preview without executing. Use stripPatterns to remove delimiters like '/' (Liquibase) or 'GO' (SQL Server). Optionally use server/database/schema params for one-time execution on a different server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsolute or relative path to the .sql file to execute
useTransactionNoWrap execution in a transaction (default: true). If any statement fails, all changes are rolled back.
stopOnErrorNoStop execution on first error (default: true). If false, continues with remaining statements.
stripPatternsNoPatterns to strip from SQL before execution. E.g., ['/'] for Liquibase, ['GO'] for SQL Server. By default, patterns are matched as literal strings on their own line.
stripAsRegexNoIf true, stripPatterns are treated as regex patterns (default: false). Use for complex patterns like '^\\s*/\\s*$'.
validateOnlyNoIf true, parse and preview the file without executing (default: false). Returns statement count and types.
serverNoOne-time server override. Execute on this server without changing main connection.
databaseNoOne-time database override. Uses this database for execution.
schemaNoOne-time schema override. Sets search_path for this execution only.
Behavior4/5

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

No annotations provided, so description carries full burden. Discloses file size limit, transaction mode, validateOnly, stripPatterns, and server/database/schema overrides. Missing details on permissions or exact return format.

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?

Concise multi-sentence description with front-loaded main action and succint additional details. No wasted words.

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

Completeness4/5

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

Given no output schema, description covers key aspects (size limit, transaction, preview, stripping, overrides). Lacks return value explanation but sufficient for most agents.

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 100%, but description adds value with examples for stripPatterns ('/','GO') and clarifies validateOnly and server/database/schema usage. Baseline 3, bonus for extra context.

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?

Clearly states 'Execute a .sql file from the filesystem' with specific use cases (migration scripts, schema changes, data imports). Distinguishes from siblings like dry_run_sql_file and preview_sql_file.

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?

Describes when to use (migration scripts, etc.) and mentions one-time overrides. Lacks explicit contrast with execute_sql for inline SQL, but still clear.

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/Teja-sudo/postgres-mcp-server'

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