execute_queryLABSCO SUMMARY
Exploration and querying over one connection string.
Discovery, schema and query are separate tools, so an assistant can find its footing in an unfamiliar database before writing SQL against it. The statistics tool answers the other question people open a client for — what is big in here.
What it is
A PostgreSQL MCP server for database exploration and querying: it connects with a standard connection string and exposes discovery, schema, filtering and statistics as tools.
What you get
- Every table in the connected database listed
- Detailed schema information for any table you name
- Custom SELECT queries executed, with results returned in structured form
- Simple equality filtering over records, for the common case that does not need SQL written at all
- Database statistics — size, table count and the largest tables
Requirements
Python 3.7+ with the packages in requirements.txt (mcp, pg8000, sqlalchemy). The database is addressed by a standard PostgreSQL connection string passed on the command line, which means the credentials live in your client config.
Setup effort
Follow the published steps — pip install -r requirements.txt
USE CASES
Getting oriented in a database you did not design
List the tables and read the schemas that matter before anything is queried, so the SQL matches the real columns.
Answering a data question without opening a client
Run the SELECT and get structured results back in the conversation where the question was asked.
Pulling records that match one value
Filter on a simple equality condition instead of composing a query for a lookup that does not need one.
Finding out what is consuming the space
Read database size, table count and the largest tables — the first numbers you want when storage is climbing.
Checking a column exists before you build on it
Read one table's schema on its own, so an assumption in a migration or a report is confirmed rather than carried.
5 tools
Listed in project docs. Your client may show a different list.
list_tablesget_table_schemafilter_instancesget_database_statsBEFORE YOU INSTALL
What to know first
Tools you get
5 tools named in the project's documentation.
Requires
Python 3.7+
Where it runs
The documented client runs the server on your machine.
INSTALLATION
Connect your client
Server setup
git clone https://github.com/aadarshjain/postgres-mcp-server
cd postgres-mcp-server
pip install -r requirements.txtMCP Clients
Claude Desktop
{
"mcpServers": {
"postgres": {
"command": "python",
"args": [
"<YOUR_PATH_TO_POSTGRES_MCP_SERVER>/server.py",
"postgresql://<YOUR_DB_USER>:<YOUR_DB_PASSWORD>@<YOUR_DB_HOST>:<YOUR_DB_PORT>/<YOUR_DB_NAME>"
]
}
}
}<YOUR_PATH_TO_POSTGRES_MCP_SERVER> is the full path of the folder the git clone above created, and postgresql://<YOUR_DB_USER>:<YOUR_DB_PASSWORD>@<YOUR_DB_HOST>:<YOUR_DB_PORT>/<YOUR_DB_NAME> is the shape of your database's connection string. If Claude Desktop cannot find python, give its full path instead (which python, or where python on Windows), as the README advises.