mcp-postgres-query-server

mcp-postgres-query-server

0

The MCP Postgres Query Server is a Model Context Protocol server that facilitates secure read-only access to a PostgreSQL database. It integrates with Claude Desktop, supports query validation to ensure only SELECT queries are executed, and includes timeout protection to enhance security.

MCP Postgres Query Server

This project implements a Model Context Protocol (MCP) server that provides:

  • A secure, read-only interface to a PostgreSQL database
  • Integration with Claude Desktop through the MCP protocol
  • SQL query validation to ensure only SELECT queries are executed
  • Query timeout protection (10 seconds)

Features

  • Read-Only Database Access: Only SELECT queries are permitted for security
  • Query Validation: Prevents potentially harmful SQL operations
  • Timeout Protection: Queries running longer than 10 seconds are automatically terminated
  • MCP Protocol Support: Complete implementation of the Model Context Protocol
  • JSON Response Formatting: Query results are returned in structured JSON format

API

Tools

query-postgres

Executes a read-only SQL query against the configured PostgreSQL database.

Parameters:

  • query (string): A SQL SELECT query to execute

Response:

  • JSON object containing:
    • rows: The result set rows
    • rowCount: Number of rows returned
    • fields: Column metadata