PostgreSQL MCP Server logo

PostgreSQL MCP Server

by divyanshu-vashu

A Model Context Protocol server providing read-only access to PostgreSQL databases. It enables LLMs to inspect database schemas and execute read-only queries.

View on GitHub

Last updated: N/A

What is PostgreSQL MCP Server?

This is a Model Context Protocol (MCP) server designed to provide read-only access to PostgreSQL databases. It allows Large Language Models (LLMs) to interact with and understand the structure and data within a PostgreSQL database without the risk of data modification.

How to use PostgreSQL MCP Server?

The server can be used with tools like Claude Desktop by configuring the 'mcpServers' section in the claude_desktop_config.json file. You can run the server using either Docker or NPX, providing the necessary PostgreSQL connection string. The server exposes table schemas and allows executing read-only SQL queries.

Key features of PostgreSQL MCP Server

  • Read-only access to PostgreSQL databases

  • Automatic schema discovery

  • JSON schema information for each table

  • Execution of read-only SQL queries within a READ ONLY transaction

Use cases of PostgreSQL MCP Server

  • Allowing LLMs to understand database structure for better context

  • Enabling LLMs to query data for information retrieval

  • Building applications that require read-only access to PostgreSQL data

  • Integrating PostgreSQL databases with LLM-powered tools

FAQ from PostgreSQL MCP Server

What is the purpose of this server?

To provide read-only access to PostgreSQL databases for LLMs and other applications that need to understand and query database data without modifying it.

How do I connect to my PostgreSQL database?

You need to provide a valid PostgreSQL connection string, including the host, port, database name, and optionally username and password.

What kind of queries can I execute?

Only read-only SQL queries are allowed. The server enforces a READ ONLY transaction to prevent any data modification.

How do I get the schema information for a table?

The server provides schema information as JSON for each table, accessible via a specific URL pattern (e.g., postgres://<host>/<table>/schema).

What license is this server under?

This server is licensed under the MIT License, allowing you to use, modify, and distribute the software freely, subject to the terms and conditions of the license.