Skip to main content
Glama
Jorge-240

Universal Database MCP

by Jorge-240

Universal Database MCP

适用于 Google ADK 和其他 MCP 客户端的远程 MCP。可通过 URL 动态连接 MySQL、MariaDB 和 PostgreSQL,并管理数据库、表和记录。

1. 要求

  • 建议使用 Python 3.13。

  • 一个可从运行 MCP 的计算机访问的 MySQL/MariaDB/PostgreSQL 数据库。

  • 对于 Render:数据库必须接受来自互联网或授权网络的连接。

Related MCP server: Read-only Database MCP

2. 本地运行

Windows PowerShell:

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

编辑 .env,将 MCP_API_KEY 改为一个长密钥。

运行:

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

健康检查:

http://127.0.0.1:8000/health

MCP:

http://127.0.0.1:8000/mcp

3. 使用 MCP Inspector 进行测试

在另一个终端中:

npx -y @modelcontextprotocol/inspector

连接到:

http://127.0.0.1:8000/mcp

在客户端中,添加请求头:

Authorization: Bearer TU_MCP_API_KEY

4. 首次连接

使用工具 crear_conexion,例如发送:

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

服务器会返回一个 connection_id。在所有其他工具中使用该 ID。

5. 关于本地 MySQL 的重要说明

部署在 Render 上的 MCP 不能使用 127.0.0.1localhost 来连接你电脑上的 MySQL。在 Render 中,localhost 指的是 Render 服务器本身。

对于本地数据库,你需要运行一个本地连接器作为安全桥梁。当前这个第一版已经准备好了远程 API;Local Connector 是项目的第二个组件。

6. Google ADK

配置:

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

并以 examples/adk_agent.py 为基础。

7. Render

你可以将此仓库作为 Web Service 连接到 Render。

构建:

pip install -r requirements.txt

启动:

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

变量:

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

端点将是:

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

8. 安全性

此版本使用静态 bearer token 来保护远程端点。数据库 URL 仅保存在进程内存中,并在响应中以脱敏形式显示。

数据库凭据实际上决定了可以执行哪些操作。ejecutar_sql_admin 可以使用该账户的权限执行任意 SQL,因此要求 confirmar=true

对于多用户/多智能体的生产环境,建议用 OAuth 2.1/JWT 取代全局 token,并按用户身份隔离连接。

Maintenance

ActivityMaintained
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

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
    19
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables read-only access to PostgreSQL and MySQL/MariaDB databases through MCP tools for listing tables, previewing data, and running SELECT queries with a built-in UI for managing database configurations.
    83
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables MCP-compatible clients to interact with PostgreSQL databases with multi-database support and connection pooling.
    13
    1
    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.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Jorge-240/universal-database-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server