Works with the AI Agents you already use

    remote postgres mcp

    by Rabindra Maharjan

    0

    Deploy a PHP PostgreSQL MCP tunnel and connect Cursor or Claude Code to a remote database over HTTPS.

    $10

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    remote postgres mcp

    remote postgres mcp

    Example session with this skill installed

    I need to connect Cursor to my remote Postgres database on a shared HostGator server. It only supports PHP. The URL will be https://myapp.com/db-bridge/.

    • Read your context and instructions
    • Compiled the remote postgres mcp

    I will help you deploy the PHP tunnel and configure Cursor to access your remote PostgreSQL database.

    Status

    • Done: Identified environment (Shared Hosting/PHP)
    • Blocked: Pending file upload and config
    • Next: Upload tunnel files and create config.php

    PHP Tunnel Configuration

    First, upload pg_mcp_tunnel.php to your server. Then, create a config.php file in the same directory with the following content. I have generated a secure 32-character token for you.

    <?php
    // config.php - Keep this file private
    return [
        'token' => 'b7f9a2e3c5d8e1f4a0b2c4d6e8f0a2b4',
        'db' => [
            'host' => '127.0.0.1',
            'port' => 5432,
            'dbname' => 'your_database_name',
            'user' => 'your_username',
            'password' => 'your_password',
        ],
        'access_mode' => 'readonly', // Options: readonly, readwrite, full
        'max_rows' => 1000,
        'statement_timeout_ms' => 10000,
    ];
    

    Cursor MCP Setup

    Once the files are uploaded, open your Cursor settings, go to the MCP section, and add a new server with these settings:

    {
      "mcpServers": {
        "remote-postgres": {
          "command": "npx",
          "args": ["-y", "pg-mcp-bridge"],
          "env": {
            "PG_MCP_TUNNEL_URL": "https://myapp.com/db-bridge/pg_mcp_tunnel.php",
            "PG_MCP_TOKEN": "b7f9a2e3c5d8e1f4a0b2c4d6e8f0a2b4"
          }
        }
      }
    }
    

    Next steps

    1. Upload the PHP files and .htaccess to your server.
    2. Run a connectivity test using: curl -X POST https://myapp.com/db-bridge/pg_mcp_tunnel.php -H "Authorization: Bearer b7f9a2e3c5d8e1f4a0b2c4d6e8f0a2b4" -d '{"action":"ping"}'
    3. Restart Cursor and run the list_tables tool to verify access.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Connecting an AI agent to a remote database often fails due to firewall restrictions or lack of Node.js support on shared hosting. This skill provides a secure bridge between Cursor or Claude Code and PostgreSQL using a PHP-based HTTP tunnel.

    What it does

    • Deploy tunnel architecture by setting up the pg-mcp-bridge PHP component on any Apache/PHP server to act as a secure gateway.
    • Configure access levels by defining granular readonly, readwrite, or full permissions to protect your data.
    • Automate client setup by generating the precise JSON or CLI configurations for Cursor and Claude Code.
    • Verify connectivity using built-in ping and diagnostic tools to ensure the HTTPS bridge and bearer auth are functional.
    • Enforce security hardening with .htaccess rules and token-based authentication to prevent unauthorized database access.

    How it works

    1. Environment Check: The skill verifies your server has the pgsql extension and HTTPS enabled.
    2. Tunnel Deployment: You receive the necessary pg_mcp_tunnel.php and config.php templates for your server.
    3. Verification: A Python or curl-based ping test validates the tunnel is active and the token is valid.
    4. Client Integration: The skill provides the npx command and environment variables for your specific IDE or CLI tool.

    Frameworks & tools

    This skill utilizes PHP and Apache for the server-side tunnel. It integrates with the pg-mcp-bridge NPM package and is compatible with PostgreSQL databases. It supports Cursor and Claude Code via the Model Context Protocol (MCP).

    Why this beats prompting it yourself

    Manual setup often leads to broken environment variables or insecure configuration files. This skill follows a strict security checklist and architecture pattern that ensures your database credentials never leak into your git history or chat logs.

    Use cases

    • Querying a production or staging database directly from your AI code editor.
    • Connecting AI agents to databases hosted on PHP-only shared hosting environments.
    • Developing database-driven features with real-time schema awareness in Claude Code.
    • Securely exposing a remote Postgres instance to local MCP clients over HTTPS.

    Known limitations

    The tunnel enforces a limit of one SQL statement per query call. You must have the PHP pgsql extension installed on your hosting provider.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Frequently Asked Questions

    This skill allows AI agents to interact with PostgreSQL databases behind firewalls or on shared hosting where Node.js isn't available, using a PHP-based bridge to bypass traditional connection hurdles.

    The skill is specifically designed for Cursor and Claude Code, utilizing the Model Context Protocol (MCP) to provide these tools with real-time schema awareness and query capabilities.

    It requires a remote server running Apache/PHP with the `pgsql` extension enabled and an active HTTPS certificate to ensure secure data transmission.

    Security is managed through token-based bearer authentication and server-side `.htaccess` hardening to ensure only authorized MCP clients can access your database.

    You receive the PHP tunnel and configuration templates, step-by-step deployment instructions, and the precise JSON/CLI configurations needed to link your AI tools to the bridge.

    While powerful for schema exploration and data manipulation, the tunnel is restricted to one SQL statement per call to maintain security and stability.

    New in LLM Ops

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for LLM Ops.