PostgreSQL Server logo

PostgreSQL Server

by modelcontextprotocol

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

View on GitHub

Last updated: N/A

What is PostgreSQL Server?

This is a Model Context Protocol (MCP) server designed to provide Large Language Models (LLMs) with read-only access to PostgreSQL databases. It allows LLMs to understand database schemas and execute SQL queries for information retrieval.

How to use PostgreSQL Server?

To use this server, configure it within your Claude Desktop application using either Docker or NPX. The configuration involves specifying the command and arguments needed to run the server with your PostgreSQL database URL. Replace /mydb with your database name. The server exposes resources that can be accessed via URLs, such as table schemas. The queries are executed in READ ONLY mode, so no writes are allowed. Username and password can be passed in the postgresql url

Key features of PostgreSQL Server

  • Read-only SQL query execution

  • Automatic schema discovery

  • Table schema resource

  • Docker and NPX deployment options

Use cases of PostgreSQL Server

  • Providing LLMs with database context for improved responses

  • Enabling LLMs to answer questions based on database information

  • Allowing LLMs to perform data analysis (read-only)

  • Integrating database information into LLM-powered applications

FAQ from PostgreSQL Server

What kind of queries can I execute?

Only read-only queries are allowed. The server operates in a READ ONLY transaction mode.

How do I specify the database to connect to?

You must provide the PostgreSQL database URL in the configuration, replacing /mydb with your database name.

How do I configure the server for Claude Desktop?

Add the server configuration to the "mcpServers" section of your claude_desktop_config.json file using either Docker or NPX as described in the README.

What kind of authentication does it support?

Username and password can be added to the postgresql url with postgresql://user:password@host:port/db-name

Where can I view schemas?

The server provides schema information for each table in the database via URL postgres://<host>/<table>/schema