Get the FREE Ultimate OpenClaw Setup Guide →

SmartDB_MCP

Universal database MCP server connecting to MySQL, PostgreSQL, SQL Server, MariaDB,DM8,Oracle,not only provides basic database connection such as OAuth 2.0 authentication , health checks, SQL optimization, and index health detection

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio wenb1n-dev-smartdb_mcp pipx run SmartDB-MCP \
  --env CLIENT_ID="OAuth2 client ID" \
  --env CLIENT_SECRET="OAuth2 client secret" \
  --env OAUTH_USER_NAME="OAuth username" \
  --env TOKEN_SECRET_KEY="Token encryption key" \
  --env OAUTH_USER_PASSWORD="OAuth user password" \
  --env DATABASE_CONFIG_FILE="Path to the database configuration file (JSON) used by SmartDB" \
  --env REFRESH_TOKEN_EXPIRE_DAYS="OAuth2 refresh token expiration in days" \
  --env ACCESS_TOKEN_EXPIRE_MINUTES="OAuth2 access token expiration in minutes"

How to use

SmartDB_MCP is a universal MCP gateway that exposes multiple database connections through a single MCP-compatible interface. It supports OAuth 2.0 authentication, health checks, and SQL optimization features to help clients securely connect to and explore supported databases (MySQL, PostgreSQL, Oracle, SQL Server, and Dameng). The server provides a suite of tools such as execute_sql, get_db_health, get_table_desc, get_table_index, get_table_name, get_db_version, sql_creator, and sql_optimize to manage and inspect database schemas, execute statements, and optimize queries. To run it, install the SmartDB-MCP package and start the service via the smartdb command exposed by the package. You’ll configure environments like the database connections, OAuth credentials, and token settings through environment variables and a JSON configuration file, enabling clients to connect using MCP-compatible requests.

How to install

Prerequisites:

  • Python and pip (recommended) or use a Python environment manager
  • Optional: Docker for containerized deployment
  • Access to a database you want to connect to (MySQL, PostgreSQL, Oracle, SQL Server, or Dameng)

Installation steps:

  1. Install the MCP package globally using pip: pip install SmartDB-MCP

  2. (Optional) If you prefer using a isolated execution via pipx: pipx install SmartDB-MCP

  3. Prepare configuration and environment variables. Create a JSON config for databases (as shown in the README) and set environment variables such as:

    • DATABASE_CONFIG_FILE: path to your database config JSON
    • OAuth-related variables: CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN_EXPIRE_MINUTES, REFRESH_TOKEN_EXPIRE_DAYS, TOKEN_SECRET_KEY
    • OAUTH_USER_NAME, OAUTH_USER_PASSWORD for initial OAuth credentials if needed
  4. Start the MCP server. The README indicates the CLI is exposed as smartdb. Using pipx, you can start it with: smartdb --envfile=/path/to/.env --oauth=true

If you installed via pipx, you can also run: pipx run SmartDB-MCP --envfile=/path/to/.env --oauth=true

Additional notes

Tips and common notes:

  • Ensure the DATABASE_CONFIG_FILE JSON contains a valid default database configuration entry with the required fields (host, port, user, password, database, type, etc.). Additional databases (postgresql, oracle, mssql, etc.) can be added as needed.
  • The OAuth settings enable secured access; keep CLIENT_ID and CLIENT_SECRET confidential and rotate them periodically.
  • The START command references an environment file via --envfile. Use a .env file to centralize environment variables for convenience.
  • If you encounter connectivity issues, verify database listener accessibility from the host running SmartDB-MCP and ensure proper pool_size, timeouts, and credentials.
  • For debugging, check logs produced by the SmartDB-MCP process and ensure the environment variables described above are properly loaded.

Related MCP Servers

Sponsor this space

Reach thousands of developers