Skip to main content
Glama
Jorge-240

Universal Database MCP

by Jorge-240

Universal Database MCP

Remote MCP for Google ADK and other MCP clients. Allows you to dynamically connect MySQL, MariaDB, and PostgreSQL via a URL and manage databases, tables, and records.

1. Requirements

  • Python 3.13 recommended.

  • A MySQL/MariaDB/PostgreSQL database accessible from the machine where the MCP runs.

  • For Render: the database must accept connections from the Internet or from the authorized network.

Related MCP server: database-remote-mcp

2. Run Locally

Windows PowerShell:

py -3.13 -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
Copy-Item .env.example .env

Edit .env and change MCP_API_KEY to a long secret.

Run:

uvicorn server:app --host 0.0.0.0 --port 8000 --reload

Health:

http://127.0.0.1:8000/health

MCP:

http://127.0.0.1:8000/mcp

3. Test with MCP Inspector

In another terminal:

npx -y @modelcontextprotocol/inspector

Connect to:

http://127.0.0.1:8000/mcp

In the client, add the header:

Authorization: Bearer TU_MCP_API_KEY

4. First Connection

With the crear_conexion tool, send for example:

mysql+pymysql://usuario:password@host:3306/Tareas_sena

The server returns a connection_id. Use that ID in all the other tools.

5. Important Notes About Local MySQL

An MCP deployed on Render cannot use 127.0.0.1 or localhost to reach the MySQL on your PC. From Render, localhost means Render's own server.

For a local DB, you need to run a local connector that acts as a secure bridge. This first version sets up the remote API; the Local Connector is a second piece of the project.

6. Google ADK

Configure:

$env:MCP_URL="https://TU-SERVICIO.onrender.com/mcp"
$env:MCP_API_KEY="TU_TOKEN"

And use examples/adk_agent.py as a base.

7. Render

You can connect this repo to Render as a Web Service.

Build:

pip install -r requirements.txt

Start:

uvicorn server:app --host 0.0.0.0 --port $PORT

Variables:

MCP_API_KEY=<tu-secreto>
MCP_REQUIRE_AUTH=true
PYTHON_VERSION=3.13.5

The endpoint will be:

https://TU-SERVICIO.onrender.com/mcp

8. Security

This version uses a static bearer token to protect the remote endpoint. Database URLs are kept only in process memory and are shown redacted in responses.

The DB credentials actually determine which actions are possible. ejecutar_sql_admin can execute arbitrary SQL with that account's permissions and therefore requires confirmar=true.

For production with multiple users/agents, it is recommended to replace the global token with OAuth 2.1/JWT and isolate connections by user identity.

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    Enables connecting to and querying multiple database types (PostgreSQL, MySQL, SQLite) through a unified interface. Supports managing multiple concurrent database connections with connection pooling and SQL query execution through MCP tools.
    5
    23 npm
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables remote database access (RDBMS and MongoDB) through MCP tools, supporting read/write queries, schema management, and more.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables database interaction (MySQL, PostgreSQL, SQL Server) via MCP, supporting SQL queries and command execution.
    11 npm
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    Dynamic MCP service for MySQL and PostgreSQL, allowing runtime database connections and SQL queries via tools.
    -