postgres-mcp

postgres-mcp

Enables Claude to interact with a local PostgreSQL database through SQL queries, schema inspection, and CRUD operations.

Category
Visit Server

README

PostgreSQL MCP Server

A Model Context Protocol (MCP) server that provides PostgreSQL database access to Claude Desktop. This server enables Claude to interact with your local PostgreSQL database through a secure, well-defined interface.

Features

  • Query Execution: Execute custom SQL queries with parameterization for security
  • Schema Inspection: List tables, describe table structures, and get schema overviews
  • CRUD Operations: Create, read, update, and delete records with structured interfaces
  • Security Features: Input validation, parameterized queries, and connection pooling
  • Type Safety: Full TypeScript implementation with Zod validation

Available Tools

  1. postgres_query - Execute custom SQL queries
  2. postgres_list_tables - List all tables in the database
  3. postgres_describe_table - Get detailed table information
  4. postgres_schema_overview - Get complete database schema
  5. postgres_select - Select data with filtering and pagination
  6. postgres_insert - Insert new records
  7. postgres_update - Update existing records
  8. postgres_delete - Delete records

Installation

  1. Clone this repository:

    git clone <repository-url>
    cd postgres-mcp
    
  2. Install dependencies:

    npm install
    
  3. Build the project:

    npm run build
    

Configuration

PostgreSQL Setup

Ensure your PostgreSQL server is running on localhost:5432 with a database named postgres. The default configuration assumes you can connect without username/password (trust authentication).

Claude Desktop Configuration

Add the following to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\\Claude\\claude_desktop_config.json

{
  "mcpServers": {
    "postgres": {
      "command": "node",
      "args": ["/path/to/postgres-mcp/dist/index.js"]
    }
  }
}

Replace /path/to/postgres-mcp with the actual path to your project directory.

Usage

  1. Start Claude Desktop
  2. The PostgreSQL MCP server will automatically connect to your database
  3. Use the available tools through Claude's interface

Example Queries

  • "Show me all tables in the database"
  • "Describe the users table"
  • "Select all users where age > 25"
  • "Insert a new user with name 'John' and email 'john@example.com'"

Security Considerations

  • All queries use parameterized statements to prevent SQL injection
  • Input validation using Zod schemas
  • Connection pooling with timeouts
  • No hardcoded credentials (uses environment/default connection)

Development

# Development mode (watch for changes)
npm run dev

# Build
npm run build

# Lint
npm run lint

# Test
npm test

Troubleshooting

  1. Connection Issues: Ensure PostgreSQL is running and accessible
  2. Permission Errors: Check database user permissions
  3. Tool Not Found: Verify Claude Desktop configuration path

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured