top of page

Natural Language Access to Postgres with Claude Desktop and MCP

  • Writer: kyle Hailey
    kyle Hailey
  • 3 days ago
  • 3 min read

Updated: 2 hours ago




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.



🧠 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


 
 
 

1 comentario


blair
3 days ago

Could podman be slotted in instead of docker in the MCP config?

Me gusta

Kyle Hailey

  • Facebook
  • Twitter
  • LinkedIn
  • Instagram

San Franisco, Ca 94131

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

bottom of page