Skip to main content

Connect AI to Your PostgreSQL Database in 2 Minutes

· 6 min read
MCPBundles

You've got PostgreSQL databases you query all the time. Maybe it's your local dev database running on your laptop. Maybe it's your production database on a remote server. You used to hook them up to a BI tool or write SQL queries manually.

Now you want to query them with AI instead. Ask questions in plain English, get answers back.

But Claude can't access localhost. ChatGPT can't connect to remote databases with username/password auth. They're stuck in their own environments.

Install mcpbundles-proxy. Problem solved.

Cartoon illustration of developer connecting AI assistant to local and production PostgreSQL databases through secure proxy
Connect AI to your local dev database or remote PostgreSQL in under 2 minutes. No cloud dependencies.

Two Common Scenarios

Local dev database: You're building a feature, testing migrations, debugging issues. Your PostgreSQL database is running on your machine at localhost:5432. AI can't reach localhost, so you need the proxy to connect it.

Remote production database: Your production database lives on a server somewhere. You've got username/password credentials. You used to connect with a BI tool or psql. Now you want AI to query it. You connect directly—no proxy needed since it's already accessible over the network.

mcpbundles-proxy is only for the local case. Remote databases connect directly through MCPBundles.

Install It (Literally 30 Seconds)

pip install mcpbundles-proxy

That's it. Or use pipx install mcpbundles-proxy if you prefer isolated installs.

Connect to Your Local Dev Database

Got PostgreSQL running on your machine? Here's how to query it.

Start the Proxy

mcpbundles-proxy login

Opens your browser. Authorize the connection. Done.

mcpbundles-proxy start

The proxy auto-discovers PostgreSQL running on localhost:5432. Also finds Redis, MySQL, whatever else you've got running.

Check it worked:

mcpbundles-proxy status

You should see:

✓ Connected to MCPBundles
✓ Last seen: Just now

Discovered Services:
- PostgreSQL (localhost:5432)

If PostgreSQL doesn't show up, make sure it's actually running. Try psql -h localhost -U postgres to test.

Set Up PostgreSQL Credentials

Go to MCPBundles Dashboard and enable the PostgreSQL bundle.

When adding credentials, check the box for "Connect via Local Proxy".

Enter your database details:

  • Host: localhost
  • Port: 5432
  • Database name: dev_db (or whatever yours is called)
  • Username and password

Your credentials get encrypted and stored. They're only used when AI makes a request through your local proxy.

Query Your Dev Database

Open Claude Desktop or any MCP client. Ask questions:

"Show me all tables in my dev database"
"What's the schema for the users table?"
"List the test users I created"
"Did my migration add the email_verified column?"

The AI routes these through your proxy → your local database → returns results. Your credentials never leave your machine.

These are dev database questions. You're checking schema, verifying migrations, looking at test data. Not production analytics.

Connecting to Remote Production Database (No Proxy Needed)

Got a remote database? Don't use the proxy. Connect directly.

Go to MCPBundles Dashboard and enable the PostgreSQL bundle.

When adding credentials, do NOT check "Connect via Local Proxy". Leave it unchecked.

Enter your remote database details:

  • Host: db.example.com (your actual database server)
  • Port: 5432 or whatever you use
  • Database, username, password for production

That's it. MCPBundles connects directly to your remote database. No proxy involved.

Now you can ask production questions:

"Show me total revenue from last 30 days"
"Find active subscriptions renewing this week"
"What's the average order value for the last 7 days?"

The proxy is only for localhost. Remote databases connect directly.

What Gets Sent Where?

People ask about security. Here's what happens with the proxy (localhost only):

On your machine:

  • Proxy auth token at ~/.mcpbundles/proxy.token

Stored at MCPBundles:

  • Database host (localhost), port, database name
  • Username and password (encrypted)

Sent when you query your local database:

  • Your SQL query or question
  • Which database to use
  • Results

The proxy creates a secure tunnel between your machine and MCPBundles. When AI queries your local database, the request goes through this tunnel. Your proxy connects to localhost, runs the query, sends back results.

For remote databases (no proxy): MCPBundles connects directly using the credentials you provided. No tunnel, no proxy, just standard database connection.

Real Use Cases

Local Dev Database

"Did my migration create the right indexes?"
"Show me the test users I seeded"
"What foreign keys exist on the orders table?"
"List all tables that reference the users table"

Production Database

"Compare this week's signups to last week"
"Show me failed payment attempts from yesterday"
"Find customers whose subscriptions expire this month"
"What's the average order value for the last 30 days?"

Schema Questions (Works for Both)

"Explain how users, orders, and products tables relate"
"Show me all columns with NULL values in the users table"
"Find duplicate email addresses"

All through natural language. AI picks the right tools, writes the queries, formats results.

Multiple Databases

You can connect multiple databases at once:

  • dev_db on localhost:5432 - Your local development database (uses proxy)
  • prod_db on prod.example.com:5432 - Production (direct connection)

Only check "Connect via Local Proxy" for localhost databases. Remote databases connect directly.

Then specify which database in conversation:

"Connect to dev_db and show me the users table schema"
"Connect to prod_db and show revenue from last 30 days"

Managing the Proxy

Check Status

mcpbundles-proxy status

Shows connection status and discovered services.

Stop It

mcpbundles-proxy stop

Your local databases become inaccessible to AI until you start it again.

Logout

mcpbundles-proxy logout

Removes your auth token. You'll need to login again to reconnect.

Security Tips

Use Read-Only Users for Production

Create a user that can only SELECT:

CREATE USER ai_readonly WITH PASSWORD 'secure_password';
GRANT CONNECT ON DATABASE your_db TO ai_readonly;
GRANT USAGE ON SCHEMA public TO ai_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO ai_readonly;

AI can query but can't modify anything.

Run Proxy Only When Needed

Don't leave it running 24/7. Start when you need it:

mcpbundles-proxy start

Stop when done:

mcpbundles-proxy stop

Different Credentials Per Environment

Don't reuse the same database user across dev, staging, and production. Create separate users with appropriate permissions.

What This Gets You

  • Query databases without writing SQL
  • Debug issues faster
  • Analyze data in seconds
  • Understand schema instantly
  • Work across dev and production
  • Keep credentials secure

All through conversation with AI. No custom code. No complicated setup.

Get Started

For local databases:

Install:

pip install mcpbundles-proxy

Authenticate:

mcpbundles-proxy login
mcpbundles-proxy start

Enable PostgreSQL bundle, check "Connect via Local Proxy", add your localhost credentials.

For remote databases:

Just enable PostgreSQL bundle, leave "Connect via Local Proxy" unchecked, add your remote credentials.

Then start asking questions:

"Show me all tables"
"Find recent orders"
"Explain the schema"

Local uses the proxy. Remote connects directly. Both work with AI.