Local Agent Tunnel / private PostgreSQL

Connect private PostgreSQL.
Keep port 5432 closed.

Run the official @datamcp/agent beside PostgreSQL on EC2, a VPS, or Docker. It connects outbound and turns that private database into a scoped hosted MCP link. The password stays on your machine. SQL and results pass through datamcp cloud.

PostgreSQL onlyOutbound agent connectionNo separate tunnel fee
New on YouTubeWatch the private Docker setupLocal Agent starts at 09:44
production-db-01 Agent online
AWS
Private PostgreSQLEC2 · private subnet · eu-west-1
5432 closed
$npx @datamcp/agent ro "$DATABASE_URL" \\
›--connection-id "conn_••••••"

Connected to datamcp cloud

PostgreSQL schema synchronized

Read-only ceiling enabled

OUTBOUND SESSIONwss://api.datamcp.apphealthy
Database passwordStays on this machine
Remote accessOne scoped HTTPS MCP link

The actual boundary

The database stays private.
The work still travels.

Local Agent changes how datamcp reaches PostgreSQL. It does not turn the hosted service into an on-premises data plane.

Stays on your machine

The credential and the private database route

  • PostgreSQL password and connection string
  • Local socket or private database endpoint
  • The agent's read-only or read-write ceiling
Passes through datamcp

Approved requests and returned results

  • SQL generated by the connected AI client
  • Rows returned by PostgreSQL
  • MCP authentication, policy, and routing metadata
No public PostgreSQL ruleThe agent needs outbound access to datamcp and private access to PostgreSQL.

Run it where PostgreSQL already lives

EC2, a VPS, or Docker.
Same hosted MCP link.

The agent only needs two routes: one to PostgreSQL and one outbound connection to datamcp.

AWS

Private EC2

Run the agent on the application or database host, or on another instance that can reach PostgreSQL through the VPC.

Private subnet + outbound HTTPS
DigitalOcean

Linux VPS

Keep PostgreSQL bound to localhost or a private interface while the agent maintains the remote datamcp session.

localhost:5432 + system service
Docker

Docker host

Run the public npm package in a small container beside PostgreSQL and provide its connection settings through environment variables.

Host network or private Docker network

From private database to MCP link

Three steps.
No network surgery.

  1. 01
    Create a Local Agent source

    Choose Local Agent in the datamcp dashboard and save the generated connection ID and one-time token.

  2. 02
    Run the agent beside PostgreSQL

    Start the public npm package on EC2, a VPS, or Docker with a local database URL and the generated credentials.

  3. 03
    Sync and publish the MCP link

    Wait for the agent to come online, sync the schema, then create a scoped hosted MCP link for the client.

Open the complete setup guide →
TerminalGenerated by the dashboard
DATAMCP_AGENT_TOKEN="••••••••" npx @datamcp/agent ro \
  "$DATABASE_URL" \
  --connection-id "conn_••••••"

agent connected

schema ready

MCP link available

Start safelyUse ro and a SELECT-only PostgreSQL role. Add write access only when every permission layer is ready.

Choose the ceiling

Read-only by habit.
Write access by decision.

A database write succeeds only when the local agent, the MCP link, the datamcp user, and PostgreSQL all allow it.

Explicitly enabled

Controlled writes

Remove the local read-only ceiling only when the database role and link policy are restricted to the exact operations the workflow needs.

  • Narrow PostgreSQL grants
  • Write-enabled MCP link
  • Verify before retrying a timed-out write
AgentLocal read-only ceiling
MCP linkAllowed tools and tables
datamcp userWorkspace permission
PostgreSQLDatabase grants

Choose the right connection path

Local Agent or direct connection?

Both produce a hosted HTTPS MCP link. The difference is how datamcp reaches PostgreSQL and where the database password is stored.

Direct hosted connection

For a database endpoint datamcp cloud can already reach.

Network
Cloud connects to PostgreSQL
Password
Stored encrypted in datamcp
Best for
Public or allowlisted endpoints

In both paths, SQL requests and query results pass through datamcp cloud.

Before you install

Clear answers about the tunnel.

No vague private-cloud promises. These are the boundaries that matter before PostgreSQL handles a remote AI request.

01

What is the datamcp Local Agent Tunnel?

Local Agent Tunnel connects a private PostgreSQL database to the hosted datamcp service. You create a Local Agent connection, run @datamcp/agent on a machine that can reach PostgreSQL, sync the schema, and create a normal hosted MCP link for compatible AI clients.

02

Do I need to expose PostgreSQL to the internet?

No. The agent initiates the connection outbound to datamcp, so the database does not need a public IP or an inbound internet rule. The agent machine must be able to reach PostgreSQL and make outbound HTTPS connections.

03

Does my database data stay entirely inside my private network?

No. The PostgreSQL password stays on the agent machine, but SQL requests and query results pass through the datamcp cloud so the hosted MCP endpoint can serve the connected AI client.

04

Does Local Agent Tunnel support MySQL or OpenAPI?

No. The current tunnel supports PostgreSQL only. Use the standard hosted connection paths for MySQL and OpenAPI sources.

05

Can the Local Agent connection be read-only?

Yes. Run the agent in read-only mode and use a PostgreSQL role with SELECT-only grants. For a write to succeed, the agent mode, MCP-link policy, datamcp user permissions, and PostgreSQL role must all allow it.

06

Where can I run @datamcp/agent?

Run it on a machine that can reach the database, including an EC2 instance, Linux VPS, or Docker host. Private EC2 can connect outbound through a NAT gateway or approved proxy without a public IP.

07

Does the tunnel cost extra?

There is no separate tunnel add-on fee. Local Agent is available on Starter, Pro, and Enterprise. Its connection uses one normal source slot, and its MCP link uses one normal MCP-link slot.

Start with one link

Connect private PostgreSQL without opening inbound access

Local Agent is available on Starter, Pro, and Enterprise. It uses the standard source and MCP-link capacity in your plan, with no separate tunnel add-on fee.