top of page

Natural Language Access to Postgres with Claude Desktop and MCP

Writer: kyle Hailey
kyle Hailey
May 5, 2025
3 min read

Updated: Jun 2, 2025




Model Context Protocol (MCP) is generating a lot of buzz right now. While it’s still early days and the ecosystem is evolving, some of the tech is already pretty compelling.


One compelling use cases is connecting an LLM interface (like Claude Desktop) directly to a Postgres database, without needing to write a communication layer using Python or Langchain. It’s remarkably simple.


🔧 What You’ll Need


  • Claude Desktop – A lightweight, downloadable local app.

  • A Postgres database – If you’re here, you probably have one.

  • Docker Desktop – Easily downloadable and runs as a background app.


⚙️ Setting Up MCP in Claude Desktop (macOS)


  1. Open Claude Desktop

  2. From the top menu bar, go to Settings



  1. In the settings window, select Developer

  2. Click Edit Config



copy in the following text and save the config file

 {
  "mcpServers": {
    "postgres": {
      "command": "docker",
      "args": [
        "run", 
        "-i", 
        "--rm", 
        "mcp/postgres", 
        "postgresql://10.9.109.47:5433/yugabyte?user=yugabyte&password=password"]
    }
  }
}

  • 🔲 Replace the connection string ( in Bold Black postgresql://...) with your actual host, port, database name, username, and password.

  • 🐳 The Docker arguments (in red) launch the MCP container, which acts as a middleware between Claude and your Postgres instance.


Once you’ve saved the config:


🚀 Quit and relaunch Claude Desktop.


Claude will now automatically launch the MCP container via Docker and establish a communication layer with your Postgres database.



After relaunching Claude Desktop, I now see "postgres" in the list of tools



🧠 Ask Questions in Natural Language


For example, I loaded the Pagila (DVD rental) sample schema:

You can ask questions like:

"Tell me about the tables in my postgres database. What do the contain and how are they related?"

or

What is my largest table ?

You’ll see the SQL queries Claude generates in response, so you can vet the logic and ensure accuracy.


Nice video where my colleague Yu-Shen Ng shows the power of the MCP in this 4 minute demo video



⚠️ Why SQL Visibility Matters


Some LLM wrappers (e.g., Langchain-based tools) may silently limit context to a subset of tables. That can lead to incorrect answers — for instance, reporting the wrong “largest table” because the correct one wasn’t loaded into context.


Claude Desktop shows you the actual SQL it’s using, so you’re not flying blind. This setup lets you combine LLM power with transparent access to Postgres, skipping the overhead of a custom integration layer.


There is a huge list of MCPs available see: https://modelcontextprotocol.io/examples


Let me know if you’d like a follow-up post on connecting to other databases or writing your own MCP plugins.


Check out this list of some MCPs! Data and file systems

  • Filesystem - Secure file operations with configurable access controls

  • PostgreSQL - Read-only database access with schema inspection capabilities

  • SQLite - Database interaction and business intelligence features

  • Google Drive - File access and search capabilities for Google Drive

Development tools

  • Git - Tools to read, search, and manipulate Git repositories

  • GitHub - Repository management, file operations, and GitHub API integration

  • GitLab - GitLab API integration enabling project management

  • Sentry - Retrieving and analyzing issues from Sentry.io

Web and browser automation

  • Brave Search - Web and local search using Brave’s Search API

  • Fetch - Web content fetching and conversion optimized for LLM usage

  • Puppeteer - Browser automation and web scraping capabilities

Productivity and communication

  • Slack - Channel management and messaging capabilities

  • Google Maps - Location services, directions, and place details

  • Memory - Knowledge graph-based persistent memory system

AI and specialized tools

Official integrations

These MCP servers are maintained by companies for their platforms:

  • Axiom - Query and analyze logs, traces, and event data using natural language

  • Browserbase - Automate browser interactions in the cloud

  • BrowserStack - Access BrowserStack’s Test Platform to debug, write and fix tests, do accessibility testing and more.

  • Cloudflare - Deploy and manage resources on the Cloudflare developer platform

  • E2B - Execute code in secure cloud sandboxes

  • Neon - Interact with the Neon serverless Postgres platform

  • Obsidian Markdown Notes - Read and search through Markdown notes in Obsidian vaults

  • Prisma - Manage and interact with Prisma Postgres databases

  • Qdrant - Implement semantic memory using the Qdrant vector search engine

  • Raygun - Access crash reporting and monitoring data

  • Search1API - Unified API for search, crawling, and sitemaps

  • Stripe - Interact with the Stripe API

  • Tinybird - Interface with the Tinybird serverless ClickHouse platform

  • Weaviate - Enable Agentic RAG through your Weaviate collection(s)

Community highlights

A growing ecosystem of community-developed servers extends MCP’s capabilities:

  • Docker - Manage containers, images, volumes, and networks

  • Kubernetes - Manage pods, deployments, and services

  • Linear - Project management and issue tracking

  • Snowflake - Interact with Snowflake databases

  • Spotify - Control Spotify playback and manage playlists

  • Todoist - Task management integration


 
 
 

11 Comments


Ronnie Garage
Oct 02

I recently found Ronnie’s Garage while exploring options for professional car care in Delhi NCR. The website covers several services, from PPF and ceramic coating to graphene coating, paint correction, and detailed car care. I liked that the site provides information about the different services, making it easier to understand the options before choosing one. It’s worth exploring for anyone researching professional detailing and paint protection for their vehicle.

Like

mickey
Sep 23

Organic search is definitely the most cost-effective channel for long-term growth. When our company decided to scale, we hired specialists for https://estetic-web-design.com.ua/en/seo to overhaul our entire technical structure and metadata. Within three months, our organic traffic doubled, and qualified sales leads began coming in consistently. Just make sure to focus on genuine content rather than quick black-hat shortcuts.

Like

wordcam
Sep 01

Really insightful technical article exploring natural‑language Postgres queries with Claude Desktop and MCP! This is such an exciting integration for anyone working with SQL databases. I appreciate the practical perspective on how this workflow simplifies day‑to‑day data exploration for developers and analysts. Great technical write‑up!  --wordcam

Like

dmwin login
Aug 19

A login guide is easier to understand when it focuses on the things a regular user may actually need. For dm win login, I would expect clear information about the basic access process, required account details, and what to check if the credentials are not accepted. Keeping these points straightforward makes the information more practical without making unnecessary claims about the platform.

Like

Guest
Jul 29

Many business owners find that keeping financial records organized makes daily operations more manageable and helps reduce unnecessary confusion. Choosing bookkeeping services near me can make it easier to track income and expenses, maintain accurate records, and stay prepared for regular financial tasks throughout the year

Like

Kyle Hailey

  • Facebook
  • Twitter
  • LinkedIn
  • Instagram

San Franisco, Ca 94131

415-341-3430  (please text initially before calling)

bottom of page