Skip to main content
Glama
foxter-io

PostgreSQL MCP Server

by foxter-io

Export Query Results as CSV

pg_copy_csv
Read-only

Export PostgreSQL query results as CSV with headers. Customize delimiter and null representation, with row limit control.

Instructions

Execute a SELECT query and return the results formatted as CSV with headers.

Args:

  • sql: SELECT statement to export (required — must be read-only)

  • limit: Maximum rows to export, 1-5000 (default: 1000)

  • delimiter: CSV field delimiter character (default: ',')

  • null_value: String to use for NULL values in CSV output (default: '')

Returns: CSV text with header row. Suitable for copy-paste into spreadsheets or piping to files.

Errors:

  • Rejected if non-SELECT statement provided

  • Returns error if query fails

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesSELECT query to export as CSV
limitNoMax rows (default: 1000, max: 5000)
delimiterNoCSV delimiter character (default: comma),
null_valueNoValue to use for NULL fields
Behavior5/5

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

Annotations already provide readOnlyHint and destructiveHint. The description goes beyond by detailing the CSV output format, error handling for invalid queries, and parameters like limit, delimiter, and null_value. No contradictions with 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?

The description is structured with clear sections (Args, Returns, Errors), uses bullet points, and is concise—every sentence provides essential information 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?

With no output schema, the description fully covers return value (CSV text), all parameters, constraints (SELECT only, row limit), and error cases. It is complete for a tool of this complexity.

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

Parameters5/5

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

Despite 100% schema coverage, the description adds substantial meaning: sql is required and must be read-only; limit range and default; delimiter default character; null_value default. This enriches the agent's understanding beyond schema constraints.

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?

The description clearly states 'Execute a SELECT query and return the results formatted as CSV with headers,' specifying a concrete verb and resource. The title 'Export Query Results as CSV' distinguishes it from siblings like pg_execute and pg_query, which likely return different formats.

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?

The description includes explicit notes on when to use (SELECT only) and error conditions for non-SELECT. However, it does not explicitly compare against sibling tools like pg_execute or pg_query to guide selection for similar operations.

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