PostgreSQL MCP Server: Connect, Query, Control Access
A PostgreSQL MCP server turns a Postgres database into a set of callable tools — query, list_schemas, list_tables, describe_table — that an AI agent calls over the Model Context Protocol instead of getting raw SQL access. MCPifex hosts one, listed in the marketplace: save your database credentials once in the portal, pick which tools are enabled, and point any MCP client at the gateway.
What it does
Under the hood it runs mcp-postgres-server, the open-source package that speaks Postgres, behind MCPifex's own gateway at https://mcpifex.com/mcp. Each client session gets its own isolated server process, so one agent's queries never share connection state with another's, and every call is logged to the instance so you can see what an agent actually did.
Tools
The portal shows all five tools per instance and lets you flip any of them off; write access is off by default so a fresh instance is read-only until you decide otherwise.
| Tool | What it does | Default |
|---|---|---|
query | Run a read-only SELECT statement. | On |
list_schemas | List schemas in the connected database. | On |
list_tables | List tables in the connected schema. | On |
describe_table | Return column types, indexes and constraints. | On |
execute | Run INSERT/UPDATE/DELETE statements. | Off |
One tool is missing from that list on purpose: mcp-postgres-server also ships a connect_db tool that takes host/user/password/database as call arguments, which would let a client repoint the connection at an entirely different database. MCPifex never adds it to the catalog, so tools/call for connect_db is always refused — an agent can only ever reach the one database you configured for that instance.
Credentials it needs
You fill these in once, in the portal, when you create the instance — see the quickstart for the full account-to-first-call flow:
- Host — hostname or IP of the Postgres instance.
- Port — the port Postgres is listening on (default 5432).
- Database — the database name to connect to.
- Username / Password — the application role MCPifex connects as.
- SSL mode — Disable, Require, Require with no cert verification (the default), or Verify full with a CA bundle.
Credentials are encrypted in transit and shown masked in the portal UI after you save them.
Connect from each client
Every client points at the same gateway URL and the same API key (starts mcpx_), generated from the portal after you create a free account and finish setting up the instance. Swap <YOUR_MCPX_KEY> for your own key in each snippet below.
Claude Code
Run once from any shell with the claude CLI on PATH:
#!/bin/sh
# MCPifex — Claude Code CLI snippet.
# Replace <YOUR_MCPX_KEY> with your MCPifex API key (starts "mcpx_"), from
# the portal's API key page, then run this once from any shell that has the
# `claude` CLI on PATH.
claude mcp add mcpifex --transport http https://mcpifex.com/mcp \
--header "Authorization: Bearer <YOUR_MCPX_KEY>"
Claude Desktop
Use Claude’s remote custom connector where available. For a local-config alternative, this mcp-remote bridge requires Node.js and npx. Merge the mcpifex entry into the top-level mcpServers object in claude_desktop_config.json, then restart Desktop. Keep the credential private.
{
"mcpServers": {
"mcpifex": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://mcpifex.com/mcp",
"--header",
"Authorization:${MCPIFEX_AUTH_HEADER}"
],
"env": {
"MCPIFEX_AUTH_HEADER": "Bearer <YOUR_MCPX_KEY>"
}
}
}
}
Cursor
Merge this into .cursor/mcp.json (project) or Cursor's global mcp.json, then reload Cursor:
{
"mcpServers": {
"mcpifex": {
"type": "http",
"url": "https://mcpifex.com/mcp",
"headers": {
"Authorization": "Bearer <YOUR_MCPX_KEY>"
}
}
}
}
ChatGPT
ChatGPT's custom-connector form can't send a header, so the key rides in the URL path instead — the gateway accepts both forms:
- On ChatGPT web, open Settings → Security and login → Developer mode and enable it if your account and workspace allow it.
- Open ChatGPT Plugins, use the plus button, and create a developer-mode app named MCPifex with a short description.
- Set the MCP server URL to
https://mcpifex.com/mcp/<YOUR_MCPX_KEY>. - Choose No Authentication (or None): the MCPifex key in the URL authenticates the gateway request.
- Create the connection and review the discovered tools.
- In a conversation, use the plus menu → Developer mode, select the app, and test one named read-only tool.
These steps follow the OpenAI developer-mode documentation, checked in September 2026. Availability depends on your plan and workspace policy.
Treat this URL like a password: anyone who has it can call every tool enabled on that key.
Raw MCP handshake (curl)
For debugging or a non-SDK client, this runs initialize and a filtered tools/list directly against the gateway:
#!/bin/sh
# MCPifex — raw MCP handshake over curl (initialize + tools/list).
# Replace <YOUR_MCPX_KEY> with your MCPifex API key (starts "mcpx_"), from
# the portal's API key page. Requires curl only.
set -e
GATEWAY_URL="https://mcpifex.com/mcp"
MCPX_KEY="<YOUR_MCPX_KEY>"
# 1. initialize — the gateway replies with an Mcp-Session-Id response header
# that every later request on this session must echo back.
INIT_HEADERS=$(mktemp)
INIT_BODY=$(mktemp)
curl -sS -D "$INIT_HEADERS" -o "$INIT_BODY" \
-X POST "$GATEWAY_URL" \
-H "Authorization: Bearer $MCPX_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2025-06-18",
"capabilities": {},
"clientInfo": { "name": "mcpifex-curl-example", "version": "1.0.0" }
}
}'
SESSION_ID=$(grep -i '^mcp-session-id:' "$INIT_HEADERS" | tr -d '\r' | cut -d' ' -f2-)
echo "Mcp-Session-Id: $SESSION_ID"
cat "$INIT_BODY"
echo
rm -f "$INIT_HEADERS" "$INIT_BODY"
# 2. tools/list — filtered to the tools enabled for this API key.
curl -sS -X POST "$GATEWAY_URL" \
-H "Authorization: Bearer $MCPX_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Mcp-Session-Id: $SESSION_ID" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list",
"params": {}
}'
echo
Limits
Each client session gets one isolated mcp-postgres-server process, which MCPifex ends when the session closes or after it sits idle — a client just opens a new session and keeps going. Revoking an API key from the portal stops new calls on it within about a minute; a session that's already connected is cut off on its next tool call. Every call is logged per instance, with daily usage counts visible in the portal, and "Test connection" during setup calls list_schemas before you finish — a bad password fails immediately instead of surfacing later inside an agent's session.
As of September 2026, PostgreSQL is one of three servers MCPifex has hosted end to end (alongside Google Trends and Google Search Console); MySQL and Filesystem are in the catalog but not yet launchable. Instance count is capped by plan — see plan limits — but tool calls themselves are unlimited on every plan.
Frequently asked questions
- Can an AI agent write to my database through the PostgreSQL MCP server?
- Not unless you turn it on. The execute tool, which runs INSERT/UPDATE/DELETE, is off by default on every instance. query, list_schemas, list_tables and describe_table are on by default and are all read-only.
- Can a client repoint the connection at a different database?
- No. mcp-postgres-server's own connect_db tool takes host/user/password/database as call arguments, but MCPifex never adds it to the catalog, so tools/call for connect_db is always refused regardless of which tools you've enabled.
- What happens if I revoke the API key?
- New calls on that key are rejected within about a minute. A client that already has a live session is cut off on its next tool call rather than waiting for the session to end on its own.
- Which MCP clients can connect to the hosted PostgreSQL server?
- Any client that speaks MCP over Streamable HTTP, including Claude Code, Claude Desktop, Cursor and ChatGPT's custom connectors — see the snippets above. Clients that can't send custom headers use the API key as the first path segment of the gateway URL instead.
- Does MCPifex see or store my query results?
- Every call is logged per instance — which tool was called, when, and its outcome — and that log is visible in the portal. Your saved database credentials are shown masked in the portal UI.
Sources
Run this server through MCPifex
Host any MCP server behind one endpoint and control exactly what your agents can reach.