mcp-server-rdbms
Provides connectivity to ClickHouse databases via an optional driver extension, allowing schema exploration, read-only analytical SQL queries, and permission-gated data or DDL changes through the same unified tool set.
Enables LLMs to explore, query, and optionally modify MySQL databases through tools for listing tables and views, describing columns and constraints, running read-only SQL queries, viewing EXPLAIN plans, and performing transactional data or schema changes when authorized.
Enables LLMs to explore, query, and optionally modify PostgreSQL databases through tools for inspecting schemas, running safe read-only queries, viewing execution plans, diagnosing running/blocking queries, and executing transactional DML/DDL when explicitly authorized.
Enables LLMs to explore, query, and optionally modify SQLite databases through tools for listing tables/views, describing schemas, running read-only SQL queries with automatic LIMIT truncation, EXPLAIN plans, and permission-gated DML/DDL execution.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-server-rdbmslist all tables and describe the users table schema"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-server-rdbms
通用的关系型数据库模型上下文协议(Model Context Protocol, MCP)服务,基于 Python、SQLAlchemy 2.0 与 FastMCP 构建。专为大语言模型(LLM)提供安全、可控、高内聚的多数据库探查、查询、诊断与变更能力。
🌟 核心特性
🚀 通用多数据库抽象:基于 SQLAlchemy 2.0 底座,默认支持 SQLite、PostgreSQL、MySQL,并可通过驱动扩展无缝接入 Oracle、SQL Server、ClickHouse 及各类符合标准方言的国产数据库。
🛡️ AST 级深度安全守卫:
基于
sqlglot语法树静态分析,只读模式下物理拦截任何 DDL/DML/注入操作;自动为大模型查询注入
LIMIT截断,彻底杜绝全表拉取导致 OOM;DML 操作强制校验
WHERE条件,杜绝无条件全表UPDATE或DELETE误操作。
⚡ 原子事务与安全变更:
sql_dml原生支持单条或多条 SQL 批处理,底层默认运行在独立事务中,出错全量自动回滚;DML 与 DDL 细粒度权限隔离,默认强只读,写权限需通过启动参数显式授权。
🔍 精炼 8 核心工具矩阵:无二义性、零冗余设计,工具按领域命名空间规范组织,模型理解与调用准确率极高。
🌐 多数据库配置中心:支持单库环境变量(
DATABASE_URL)直连,亦支持通过 YAML 配置文件多库路由。
Related MCP server: Universal SQL MCP Server
🛠️ 8 核心工具矩阵
领域前缀 | 工具名称 | 参数契约 | 功能描述 |
|
|
| 获取数据库方言、内核版本、当前 Schema/Database 及当前登录用户 |
|
|
| 获取所有数据表与视图清单、注释及外键拓扑关系图谱 |
|
| 一站式查询指定表的列定义、数据类型、可空性、主外键约束与索引明细 | |
|
|
| 安全只读查询,承担数据预览、样本采样与业务数据分析(支持 CTE |
|
| 执行 | |
|
| 数据增删改。默认原子事务,支持单条或批量,出错全量回滚,禁止无 WHERE 变更 | |
|
| 结构变更(建表、删表、改表)。受独立 | |
|
|
| 查看当前正在运行的长查询与阻塞会话(不支持的库自适应优雅降级) |
📦 安装与快速运行
方式 1:使用 uvx 免安装直接运行(推荐)
无需在本地克隆代码或手动创建虚拟环境,使用现代 Python 包管理器 uv 即可直接拉取并启动:
# 单库直接运行(指定数据库连接串)
uvx mcp-server-rdbms --db-url "postgresql+psycopg://user:password@localhost:5432/mydb"
# 使用多库配置文件启动
uvx mcp-server-rdbms --config ./connections.yaml方式 2:本地源码克隆与运行
# 克隆仓库
git clone https://github.com/atengk/mcp-server-rdbms.git
cd mcp-server-rdbms
# 使用 uv 安装核心依赖
uv sync
# 启动服务
uv run mcp-server-rdbms --db-url "sqlite:///./demo.db"🔌 MCP 客户端接入配置
1. Claude Desktop 配置
在 Claude Desktop 配置文件(Windows: %APPDATA%\Claude\claude_desktop_config.json,macOS: ~/Library/Application Support/Claude/claude_desktop_config.json)中添加:
{
"mcpServers": {
"rdbms": {
"command": "uvx",
"args": [
"mcp-server-rdbms",
"--db-url",
"postgresql+psycopg://user:password@localhost:5432/mydb"
]
}
}
}2. 启用数据变更权限(写模式)
若需允许大模型执行 DML(数据增删改)或 DDL(建表/改表),请显式传入授权参数:
{
"mcpServers": {
"rdbms-write": {
"command": "uvx",
"args": [
"mcp-server-rdbms",
"--config",
"/path/to/connections.yaml",
"--allow-dml",
"--allow-ddl"
]
}
}
}🧩 数据库驱动扩展
mcp-server-rdbms 默认内置了 SQLite、PostgreSQL、MySQL 驱动。若需连接其他数据库:
目标数据库 | 安装扩展命令 | 连接串 Scheme 示例 |
Oracle |
|
|
SQL Server |
|
|
ClickHouse |
|
|
其他方言 |
| 直接配置对应 SQLAlchemy URL 即可动态接入 |
📄 开源许可证
本项目采用 MIT 许可证 开源。
This server cannot be deployed
Maintenance
Related MCP Connectors
- dataOAuthco.thinair
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Astra DB tools for agents: schema, find, vector search, guarded writes, and interactive views.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to query and analyze PostgreSQL databases through a controlled interface. Supports SQL query execution, table schema inspection, and optional write operations with safety controls.206 npm180MIT
- AlicenseNot gradedqualityDmaintenanceEnables secure interaction with multiple SQL database engines (MySQL, PostgreSQL, SQLite, SQL Server) through a standardized interface. Supports schema inspection, safe query execution, and controlled write operations with built-in security restrictions.5MIT
- FlicenseAqualityDmaintenanceEnables LLM agents to perform CRUD operations across multiple databases including PostgreSQL, MySQL, and SQL Server using SQLAlchemy. It features configurable permission management and secure connection handling with automatic password redaction.4-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with relational databases such as MySQL, PostgreSQL, SQLite, SQL Server, and Oracle. Provides tools for querying, data inspection, and schema analysis with optional read-only mode.7 npm1MIT