mcp-database-server

mcp-database-server

Enables AI agents to interact with PostgreSQL or MySQL databases using natural language. Supports SQL queries, schema discovery, and pre-built aggregations without writing SQL.

Category
Visit Server

README

MCP Database Server

Give any AI agent (Claude Desktop, Cursor, OpenClaw, etc.) direct, natural language access to your PostgreSQL or MySQL database.

Instead of writing SQL, your agent asks questions like "show me the top 10 customers by revenue" — and gets the answer instantly.

What it does

Tool Description
query Run raw SQL (parameterized, injection-safe). Supports SELECT, INSERT, UPDATE, DELETE.
schema Discover all tables, columns, data types, primary/foreign keys. Agent uses this to understand your data.
analyze Pre-built aggregations (count, sum, avg, top-N, group-by) without writing SQL.

Quick start

Option A: Docker Compose (recommended)

# 1. Clone
git clone https://github.com/Lucasyao1985/mcp-database-server.git
cd mcp-database-server

# 2. Start Postgres + MCP server
docker compose up

# Done — the MCP server is running.

Option B: Standalone

git clone https://github.com/Lucasyao1985/mcp-database-server.git
cd mcp-database-server
npm install
cp .env.example .env
# Edit .env → add your DATABASE_URL
npm run build && npm start

Connect to Claude Desktop

Add this to your claude_desktop_config.json:

{
  "mcpServers": {
    "database": {
      "command": "docker",
      "args": [
        "exec", "-i",
        "mcp-database-server-mcp-database-1",
        "node", "dist/index.js"
      ]
    }
  }
}

For non-Docker setups, use "command": "node" and "args": ["/absolute/path/to/dist/index.js"].

Example conversation

You: What tables are in my database?

Agent: [calls schema] — Found 4 tables: customers, orders, products, order_items.

You: Show me the top 5 customers by total spend.

Agent: [calls analyze] — 1. Acme Corp: $48,200, 2. Globex: $31,500, ...

Security

  • SQL injection protection: All queries use parameterized $1, $2, ... placeholders. Never interpolate user input directly.
  • Read-only mode: Set READ_ONLY=true in .env to block INSERT/UPDATE/DELETE.
  • No data leaves your infrastructure: Everything runs locally. No telemetry.

Tech stack

  • MCP SDK — Model Context Protocol
  • Node.js / TypeScript
  • PostgreSQL (primary) / MySQL (supported)
  • Docker Compose for one-command deployment

Demo (video coming soon)

See the server in action: connect to Claude Desktop → ask a question → get live database results.


Built on the Model Context Protocol.

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
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
Qdrant Server

Qdrant Server

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

Official
Featured