Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
6,000+ web scrapers for your AI agent, start free logo6,000+ web scrapers for your AI agent, start free

Apify gives your agent live web data: 6,000+ prebuilt scrapers and actors, MCP-ready. Sign up free with $5 in usage credits.

Try Apify free
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 48,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

Enables chat-based interaction with PostgreSQL databases, supporting table listing, queries, write operations, and saved parameterized queries, deployable as a remote MCP server via Cloudflare Workers.

README.md

About

  • MCP SERVER where allow you chat with your database(Postgresql) using AI
  • You can deploy this MCP server as a remote MCP server using Cloudflare Workers

Key features

  • List the tables of your database
  • Query the tables of your database
  • Execute write operations like INSERT/UPDATE/DELETE (privileged users only)
  • Create queries and saved to execute later. PS: you can create queries with parameters

and save the queries to execute later.

  • All operations sent to Cloudflare Workers will check the api-key sent in the header

Folder structure

- src/
  - database/      // Database connection and utils
  - tools/         // Tools implementation
  - repositories/  // Repositories implementation

Transport Protocols

This MCP server supports both modern and legacy transport protocols:

  • /mcp - Streamable HTTP (recommended): Uses a single endpoint with bidirectional communication, automatic connection upgrades, and better resilience for network interruptions
  • /sse - Server-Sent Events (legacy): Uses separate endpoints for requests/responses, maintained for backward compatibility

For new implementations, use the /mcp endpoint as it provides better performance and reliability.

Prerequisites

  • Node.js installed on your machine
  • A Cloudflare account (free tier works)
  • A PostgreSQL database (local or hosted)

Step 1: Install Wrangler CLI

Install Wrangler globally to manage your Cloudflare Workers:

npm install -g wrangler

Step 2: Authenticate with Cloudflare

Log in to your Cloudflare account:

wrangler login

This will open a browser window where you can authenticate with your Cloudflare account.

Step 3: Clone and Install dependencies

Clone the repo directly & install dependencies: pnpm install.

Environment Variables Setup

Before running the MCP server, you need to configure several environment variables for authentication and database access.

Create Environment Variables File

  1. Create your .dev.vars file from the example:
   cp .dev.vars.example .dev.vars
  1. Configure all required environment variables in .dev.vars:
   ACCESS_TOKEN=random_value_to_use_as_api_key
   DATABASE_URL=postgresql://username:password@localhost:5432/database_name

Database setup

  • To save the queries to execute later you will need execute the SQL script on your database. PS: you need to execute the script named instructions.sql only once.

Run the server locally

   wrangler dev

This makes the server available at http://localhost:8792

Production Deployment

Deploy

Deploy the MCP server to make it available on your workers.dev domain

wrangler deploy

Access the remote MCP server from Kilo Code and Vscode

You can access the remote MCP server from Kilo Code and Vscode using the following configuration:

// Kilocode MCP
{
  "mcpServers": {
    "direct-database-mcp-server-prod": {
      "url": "url_cloudflare_workers_generated_after_deployed/sse",
      "headers": {
        "api-key": "Bearer same_value_of_ACCESS_TOKEN"
      }
    }
  }
}
// Vscode MCP
{
  "servers": {
    "direct-database-mcp-server-prod": {
      "url": "https://my-mcp-server.tiagorosadacost.workers.dev/sse",
      "headers": {
        "api-key": "Bearer 701cdccb-e605-423f-a778-66ed0698117f"
      }
    }
  }
}

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Databases servers.