Skip to main content

A Multi-Database MCP Server - enables AI assistants to query and explore PostgreSQL and MySQL databases

Project description

Multi-Database MCP Server (PostgreSQL & MySQL)

A powerful Model Context Protocol (MCP) Server designed for AI-assisted development (e.g., Cursor, Claude Desktop, Antigravity). It enables your AI assistant to safely interact directly with PostgreSQL and MySQL/MariaDB databases.

Key Features

  • Dual Database Support: Supports both PostgreSQL and MySQL out of the box.
  • Ready to Use: Simple pip installation with zero complex setup.
  • Flexible Configuration: Configure via Client Config or Environment Variables (.env).
  • Secure & Controlled: Built-in Read-Only mode, Max Row limits, and strict permission controls.
  • Dual Execution Modes: Supports standard STDIO (Default for Cursor) and HTTP (for Antigravity/Docker).

Installation

Ensure you have Python 3.10 or higher installed.

pip install da2-mcp-multi-db

(Note: The package name is da2-mcp-multi-db)

Quick Start

Once installed, you can launch the servers directly using the following commands:

1. PostgreSQL

# Start PostgreSQL Server
da2-mcp-postgresql

2. MySQL / MariaDB

# Start MySQL Server
da2-mcp-mysql

Configuration Guide

This program relies on environment variables (like DATABASE_URL) to connect to your database. We provide two ways to configure this, please choose the one that fits your workflow:

Method 1: MCP Client Configuration (Recommended)

If you are using Cursor or Claude Desktop, it is recommended to define variables directly in your Client's configuration file for a cleaner setup.

Cursor Example (cursor_mcp_config.json):

{
  "mcpServers": {
    "my-postgres": {
      "command": "da2-mcp-postgresql", 
      "args": [],
      "env": {
        "DATABASE_URL": "postgresql://user:password@localhost:5432/mydb",
        "READ_ONLY": "false",
        "MAX_ROWS": "1000"
      }
    },
    "my-mysql": {
      "command": "da2-mcp-mysql",
      "args": [],
      "env": {
        "MYSQL_DATABASE_URL": "mysql://user:password@localhost:3306/mydb"
      }
    }
  }
}

Method 2: Using .env File (For CLI)

If you are running commands manually in a terminal, the program will automatically look for a .env file in the current working directory.

  1. Create a file named .env in the directory where you run the command.
  2. Add the following content:
# PostgreSQL Connection String
DATABASE_URL=postgresql://user:password@localhost:5432/mydb

# MySQL Connection String
MYSQL_DATABASE_URL=mysql://user:password@localhost:3306/mydb

# --- OR Use Individual Variables (Lowest Priority) ---

# PostgreSQL Config
PG_HOST=localhost
PG_PORT=5432
PG_USER=postgres
PG_PASSWORD=password
PG_DATABASE=postgres

# MySQL Config
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=password
MYSQL_DATABASE=mysql

# Security Settings (Optional)
LOG_LEVEL=INFO
READ_ONLY=false
MAX_ROWS=1000
QUERY_TIMEOUT=30
ALLOW_CREATE_DB=false
ALLOW_DROP_DB=false

Available Tools

Once connected, your AI assistant will have access to the following capabilities:

Tool Name Description
list_databases List all available databases on the server
list_schemas (PostgreSQL Only) List schemas in a database
list_tables Show all tables in a specific database
describe_table Inspect table schema (columns, types, indexes)
execute_query Execute standard SQL queries (SELECT, INSERT, UPDATE...)
create_database Create a new database (requires permission)
drop_database Drop a database (requires permission and confirmation)
get_server_info Get current server version and configuration info

HTTP Mode

If you need to run in HTTP Server mode (e.g., for Docker containers or remote deployment):

# Start on Port 8000
da2-mcp-postgresql --http --port 8000

You can debug this using the MCP Inspector: npx @modelcontextprotocol/inspector http://localhost:8000/mcp


License

MIT License

Copyright (c) 2026 Danny, DA2 Studio (https://da2.35g.tw)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

da2_mcp_multi_db-0.1.1-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file da2_mcp_multi_db-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for da2_mcp_multi_db-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9a5aaf0992bdd759add301e8f39581da6e2ac459f3f4bd26f6794d3681f5175d
MD5 78dfae2311ea731a426cc5d61583c21a
BLAKE2b-256 eb6401c45e7695425476acc83099d1333469775dc51f9be8d0e176f31929bc15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page