- Home
- MCP servers
- PostgreSQL
PostgreSQL
- javascript
0
GitHub Stars
javascript
Language
7 months ago
First Indexed
3 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"jamesg31-mcp-server-postgres": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"mcp/postgres",
"postgresql://host.docker.internal:5432/mydb"
]
}
}
}You run a Model Context Protocol (MCP) server that provides read-only access to PostgreSQL databases. It lets language models inspect database schemas and execute safe, read-only queries, enabling powerful data-informed reasoning without modifying data.
How to use
Use this MCP server with your MCP client to view PostgreSQL table structures and run read-only queries. You can connect via two common methods: running the server through Docker or invoking it with NPX. When connected, you can request table schemas and execute SELECT-style queries inside a read-only transaction to safely explore data.
How to install
Prerequisites: you need Docker or Node.js with NPX available on your system. Ensure Docker is installed if you plan to run the server via the Docker workflow. Ensure Node.js is installed if you plan to use NPX to invoke the MCP server.
# Docker-based setup requires no Node installation for the MCP itself
# Build step is shown for completeness if you want to build a local image
# Build the Docker image (if you prefer building locally)
docker build -t mcp/postgres -f src/postgres/Dockerfile .
# Run with Docker (example for macOS users; host.docker.internal helps reach localhost)
docker run -i --rm mcp/postgres postgresql://host.docker.internal:5432/mydb
# NPX-based setup to run the MCP server directly without building a Docker image
npx -y @modelcontextprotocol/server-postgres postgresql://localhost/mydb
Replace /mydb with your actual database name in both approaches.
## Additional sections
Note: The server exposes a tool to run read-only SQL queries and returns schema information for each table. The main capabilities include querying data in read-only mode and obtaining JSON schemas for table structures. Use the following endpoints or commands in your MCP client to interact with the server.
Configure the MCP client with either of the provided connection methods to ensure secure, read-only access to your PostgreSQL data.
## Available tools
### query
Execute read-only SQL queries against the connected database within a READ ONLY transaction, enabling safe data exploration and extraction of results.