Get the FREE Ultimate OpenClaw Setup Guide →

db

MCP server from zerogon1203/db-mcp-server

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio zerogon1203-db-mcp-server /path/to/venv/bin/python /path/to/db-mcp-server/main.py \
  --env DB_HOST="localhost" \
  --env DB_NAME="your_db_name" \
  --env DB_TYPE="postgresql"

How to use

This MCP Database Server provides a security-enhanced analytics and visualization layer for MySQL/MariaDB and PostgreSQL databases, with basic support for SQLite planned. It enforces read-only operation, prevents SQL injection, validates identifiers, and requires parameter binding for safe query execution. Tools are organized into schema utilities, analysis utilities, and visualization utilities, enabling you to inspect schemas, stats, sample data, and query plans, as well as generate visual diagrams and reports. Use the Cursor IDE integration or the MCP transport mechanisms to connect your client or editor to the server and run the available commands to explore and analyze your databases.

Key capabilities include: get_schema, get_table_stats, get_sample_data, get_column_stats for schema and data insights; execute_query, explain_query, optimize_query, get_db_status, get_table_size, get_index_usage, analyze_performance, suggest_indexes, and optimize_tables for in-depth analysis and optimization suggestions; and generate_schema_mermaid, generate_tables_summary, and generate_performance_report for visualization and reporting. These tools help you understand database structure, assess performance bottlenecks, and produce documentation-like outputs (ERDs, markdown tables, ASCII charts) that you can share with your team.

How to install

Prerequisites:

  • Python 3.8+ installed on your system
  • Git installed
  • Access to a PostgreSQL/MySQL/MariaDB server for testing

Installation steps:

  1. Clone the repository git clone <this-repo-url> cd db-mcp-server

  2. Create and activate a virtual environment python -m venv venv source venv/bin/activate # macOS/Linux venv\Scripts\activate # Windows

  3. Install dependencies pip install -r requirements.txt

  4. Configure environment variables

    • Create a .env file or use an env var setup to provide DB connection details as described in README (DB_TYPE, DB_HOST, DB_USER, DB_PASSWORD, DB_NAME, etc.).
  5. Run the server (example) python main.py

  6. Connect via MCP client using the provided mcp_config example (adjust paths and env values to your setup).

Additional notes

Tips and considerations:

  • Ensure the read-only and security-related settings are applied in production to prevent unauthorized data modification.
  • Use a dedicated read-only database user for the MCP server (as shown in the README examples).
  • If using Cursor IDE, configure the MCP server entry with transport=stdio and provide the path to your Python executable and main.py. Ensure the environment variables (DB_TYPE, DB_NAME, DB_HOST, etc.) are correctly set for your target database.
  • Keep your dependencies up to date and monitor for SQL injection prevention updates in the tooling.
  • For SQLite, expect basic support and consider migrating to MySQL/PostgreSQL for full feature sets.

Related MCP Servers

Sponsor this space

Reach thousands of developers