Reverse engineer anything with agents, from app behavior down to native binaries.
Apisql MCP
一个 MCP Server 连接你的所有数据库,数据库 MCP Server 的瑞士军刀。One MCP Server for all your databases. The Swiss Army Knife of Database MCP Servers.
Install: claude mcp add apisql-mcp --scope user -- npx apisql-mcp
Works with Claude Code · 41 GitHub stars
Install
One-click install
Runs locallyclaude mcp add apisql-mcp -- npx -y apisql-mcpButtons open the app on your computer and ask you to confirm before anything is added.
claude mcp add apisql-mcp --scope user -- npx apisql-mcp{
"mcpServers": {
"apisql-mcp": {
"command": "npx",
"args": [
"-y",
"apisql-mcp"
]
}
}
}Install command taken from the project's README or registry entry. Always review code before running it.
README excerpt
Read full README on GitHub →apiSQL-MCP
一个 MCP Server 连接所有数据库,数据库 MCP Server 的瑞士军刀。
✨ 功能特性
- 一个 MCP,连接多种数据库 —— 支持 MySQL、PostgreSQL、SQL Server、Oracle、SQLite、StarRocks、达梦、DuckDB、OceanBase、Trino、Presto 以及任何兼容 JDBC 的数据库
- 动态数据源切换 —— 无需重启 MCP 服务器,即可在运行时切换不同数据库
- 随时随地可访问 —— 通过apiSQL网关,轻松从互联网访问到内网数据库,需无内网穿透,无需公网IP、端口映射等繁杂配置
- 完整 SQL 支持 —— 支持 DDL 和 DML操作,执行存储过程和函数UDF。
- 安全和可观测性 —— 通过 apiSQL 平台提供APIkey授权、内置日志记录和审记。
- 多种传输模式 —— 支持 STDIO 和 Streamable HTTP 传输方式
🏗️ 整体架构说明
graph LR
%% 定义节点
A["🤖 MCP 客户端(Claude 等)"]
B["🔌 apiSQL-mcp(本工具)"]
C["☁️ apiSQL 平台(API 接口)"]
%% 定义内网区域
subgraph Internal["🔒 用户内网环境"]
direction LR
D["🛡️ apiSQL 网关(内网)"]
E[("🗄️ 数据库(内网)")]
end
%% 定义连线
A <-->|MCP 协议| B
B <-->|HTTPS| C
C <-->|MQTT| D
D <-->|TCP| E
%% 样式美化 (可选)
style Internal fill:#f4f6f8,stroke:#d0d7de,stroke-width:2px,stroke-dasharray: 5 5
🗄️ 支持的数据库
| 数据库 | 类型 | 说明 |
|---|---|---|
| MySQL / MariaDB | OLTP | 完整支持,包括存储过程 |
| PostgreSQL | OLTP | 完整支持,包括 JSON 操作 |
| SQL Server | OLTP | 支持 T-SQL |
| Oracle | OLTP | 支持 11g、12c、19c、20c+ |
| SQLite | 嵌入式 | 文件型数据库 |
| StarRocks | OLAP | 高性能分析型数据库 |
| Apache Doris | OLAP | 实时分析型数据库 |
| TiDB | 分布式 | MySQL 兼容的分布式 SQL |
| DuckDB | 分析型 | 进程内分析型数据库 |
| OceanBase | 分布式 | 分布式关系型数据库 |
| Trino / Presto | 查询引擎 | 联邦查询支持 |
| Dameng | 国产信创 | 达梦数据库 |
| 自定义 JDBC | 多种 | 任何 JDBC 兼容的数据库 |
⚠️ 安全提醒
apiSQL-mcp 提供完整的数据库访问权限,包括结构修改和数据操作。请务必遵循以下安全准则:
最小权限原则:
- 创建具有最小所需权限的专用数据库用户
- 生产环境使用只读访问权限
- 通过视图限制对特定数据库/表的访问
推荐配置:
- 从测试环境开始
- 启用 apiSQL平台 的访问控制策略(IP 白名单、API Key)
🚀 快速开始
一分钟上手
1、以ChatBox配置为例: 设置 -> MCP
2、复制以下内容
{
"mcpServers": {
"apisql-mcp": {
"command": "npx",
"args": ["-y", "apisql-mcp"],
"env": {
"APISQL_MCP_API_URL": "https://open.apisql.cn/api/mytest/$sudb",
"APISQL_MCP_API_KEY": "Bearer sk-7dd9b66d38f8aff81f091ecfcf259f70",
"APISQL_MCP_DS": "mysql"
}
}
}
}
3、选择 从剪贴板中的josn导入,即可完成配置
4、启用刚配置的MCP
5、可以向默认的mysql数据库提问
你帮看一下有没有DW开头的表?
6、测试基于3张数据库,写个数据分析报告,运行中
你是数据分析师,你来分析一下这3张表,写一个简单的数据分析报告。
7、切换一个 oracle11g 操作
8、顺便解释一下,这里的oracle数据源是一个临时内网数据库,后续公开演示只有 mysql 和 postgresql 两个数据源)
9、切换至postgresql进行sql操作
再切换到 postgresql 数据库,看一下都有什么表?
10、可以正常查询postgresql数据库
11、以及在apiSQL后台可以查看日志
这样一个MCP Server,可以查询N个数据库。 在最佳实践中一般将数据源名称写入提示词,
接入自有数据库前提条件
- Node.js >= 18.0.0
- apiSQL 账号(在 open.apisql.cn 注册)和 安装 apiSQL网关 连接数据库
运行
# 全局安装(可选)
npm install -g apisql-mcp
# 或直接通过 npx 运行
npx -y apisql-mcp
配置
环境变量
| 变量名 | 是否必需 | 说明 | 可测试的示例 |
|---|---|---|---|
APISQL_MCP_API_URL |
是 | apiSQL API 端点地址 | https://open.apisql.cn/api/mytest/$sudb |
APISQL_MCP_API_KEY |
是 | API 认证密钥(Bearer token) | Bearer sk-7dd9b66d38f8aff81f091ecfcf259f70 |
APISQL_MCP_DS |
否 | 默认数据源名称 | mysql |
获取 API 凭证
- 在 open.apisql.cn 注册账号
- 创建项目并安装数据网关
- 将你的数据库添加为数据源
- 在项目设置中启用 SUDB 功能
- 创建访问控制策略,选择API Key 分配权限可访问SUDB
- 从策略页面复制 API URL 和 Key
🔧 MCP 客户端配置示例
Claude Desktop / Claude Code
将以下内容添加到 Claude Desktop 配置文件(macOS: ~/Library/Application Support/Claude/claude_desktop_config.json,Windows: %APPDATA%/Claude/claude_desktop_config.json):
Similar plugs
The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype…
User-friendly AI Interface (Supports Ollama, OpenAI API, ...)
A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io