Get the FREE Ultimate OpenClaw Setup Guide →

universal-db

一个通用数据库 MCP服务器,支持连接到各种关系型数据库系统并提供数据库结构信息和执行只读 SQL 查询

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio xiaoshi7915-universal-db-mcp-server python start.sh --db-host localhost --db-user root --db-password password --db-name mydatabase \
  --env DB_TYPE="mysql"

How to use

This universal-db MCP server exposes a read-only, MCP-compliant interface to multiple relational databases. It can connect to MySQL, PostgreSQL, Oracle, SQL Server, and SQLite, providing metadata about tables, columns, keys, and indexes, along with sample data and secure read-only SQL querying. Through the MCP protocol, tools such as large language models can request schema information, generate context-aware queries, and retrieve masked results to protect sensitive data. The server also supports SSE for streaming results, enabling responsive feedback without WebSocket dependencies. To use it, configure the MCP client to point at the server’s host and port and invoke metadata or read-only query methods as needed; you can supply the target DB type and connection details via environment variables or command-line options.

How to install

Prerequisites:

  • Python 3.10 or newer
  • Access to the targeted relational databases (MySQL, PostgreSQL, Oracle, SQL Server, or SQLite)
  • Network access to connect to the database(s)

Installation steps:

  1. Clone the repository: git clone https://github.com/xiaoshi7915/universal-db-mcp-server.git cd universal-db-mcp-server

  2. Create a Python virtual environment (optional but recommended): python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate

  3. Install dependencies: pip install -r requirements.txt

  4. Prepare and run the server (example configuration uses MySQL as the target):

    • Ensure your database is reachable (host, port, user, password, database name).
    • Start the server (the project provides a start.sh script for launching with DB connection details): ./start.sh --db-host localhost --db-user root --db-password password --db-name mydatabase
  5. (Optional) Docker deployment: docker build -t universal-db-mcp-server . docker run -p 8088:8088 -e DB_HOST=localhost -e DB_USER=root -e DB_PASSWORD=password -e DB_NAME=mydatabase universal-db-mcp-server

  6. Verify accessibility:

    • Point your MCP client at http://<server-host>:<port> (default 8088) and perform metadata or read-only queries via the MCP protocol.

Additional notes

Tips and common issues:

  • By default the server exposes 0.0.0.0; restrict access in production using a firewall or reverse proxy.
  • Sensitive information is masked in outputs, but use a database user with only read permissions in production.
  • The server supports only read-only queries; attempting write operations will be blocked for safety.
  • If you switch databases, ensure the appropriate drivers are installed and that network access is configured (host, port, credentials).
  • For Claude integration, provide the DB_TYPE (e.g., mysql, postgres) via env vars in your client configuration to ensure correct metadata handling.

Related MCP Servers

Sponsor this space

Reach thousands of developers