- Home
- MCP servers
- PostgreSQL
PostgreSQL
- python
1
GitHub Stars
python
Language
6 months ago
First Indexed
2 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": {
"logesh-001-postgresmcp": {
"command": "python",
"args": [
"server.py",
"--mode",
"stdio"
]
}
}
}You deploy a lightweight MCP server that lets any MCP client run SQL queries directly against a PostgreSQL database and receive structured results. It supports both HTTP REST API access and local stdio integration, making it easy to query, modify, or inspect data from AI models and automation tools.
How to use
To use the PostgreSQL MCP Server, run it in the mode that fits your workflow and connect with an MCP client. In stdio mode, you can integrate the server as a tool within your automation pipelines. In HTTP mode, you expose a REST API endpoint that MCP clients can query over the network to run SQL against PostgreSQL and receive results.
Typical workflow after starting in stdio mode is to send SQL statements to the server and receive JSON-formatted results. The server supports both read operations, like SELECT, and data-changing statements such as INSERT, UPDATE, DELETE, and CREATE. Remember that the server is designed for educational and hackable use, not hardened for production environments.
Starting in stdio mode is straightforward. Use the following command to launch the server locally and enable stdio integration with your tooling:
python server.py --mode stdio```
From your MCP client, send SQL statements to the running process and parse the JSON responses returned on stdout.
## How to install
Prerequisites you need before installing the PostgreSQL MCP Server:
- Python 3.9 or newer
- A running PostgreSQL database
- Access to install Python dependencies
Next, follow these steps to set up and run the server locally.
Install and manage dependencies with the package manager used for this project
uv sync
Start the server in stdio mode (for tool integration)
python server.py --mode stdio
Optional: start the server in HTTP mode when you want a REST API
Ensure port availability and required network permissions
python server.py --mode http --port 9000
## Additional notes and tips
The server is written in Python and uses psycopg2 to communicate with PostgreSQL, with loguru for structured logging. It is intended for educational and experimental use. Adjust your deployment and security posture accordingly before using in any sensitive environments.
If you plan to expose the HTTP API, ensure proper authentication, network security, and least-privilege database access. For local development, stdio mode is often the simplest integration path.