DB MCP Server
Allows querying and managing PostgreSQL databases, including listing tables, describing table structures, executing read-only SELECT queries, and executing DML/DDL statements.
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., "@DB MCP Serverlist tables in Oracle"
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.
DB MCP Server
English | 中文
一个基于 TypeScript 实现的 Model Context Protocol 服务,让 Claude Code 可以直接查询 Oracle、PostgreSQL 和 MySQL 数据库。
支持的数据库
Oracle(通过
oracledb驱动,默认 thin 模式)PostgreSQL(通过
pg驱动)MySQL(通过
mysql2驱动)
Related MCP server: MCP Database Server
提供的工具
list_tables:列出指定 schema / 数据库下的表describe_table:查看表结构、字段类型和约束execute_query:执行只读的SELECT查询execute_dml:执行INSERT/UPDATE/DELETE/DDL语句
每个工具都支持可选参数 dataSource("oracle"、"postgres" 或 "mysql")。如果只配置了一种数据库,会默认使用该数据库。
环境要求
Node.js 20+
至少配置一个数据库的环境变量
安装
本项目强制使用 pnpm 管理依赖。
cd C:\Users\ASUS\db-mcp-server
pnpm install
pnpm run build如果你用 npm install 或 yarn install,preinstall 脚本会报错并阻止安装。
配置
1. 环境变量 / .env 文件
支持两种配置方式,优先级如下:
系统环境变量(最高优先级)
项目根目录下的
.env文件
示例 .env:
# Oracle 配置
ORACLE_USER=your_user
ORACLE_PASSWORD=your_password
ORACLE_DSN=localhost:1521/ORCLPDB1
# PostgreSQL 配置
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=your_user
POSTGRES_PASSWORD=your_password
POSTGRES_DATABASE=your_db
# MySQL 配置
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=your_user
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=your_db也可以在启动 Claude Code 前用 PowerShell 设置:
$env:ORACLE_USER = "your_user"
$env:ORACLE_PASSWORD = "your_password"
$env:ORACLE_DSN = "localhost:1521/ORCLPDB1"
$env:POSTGRES_HOST = "localhost"
$env:POSTGRES_PORT = "5432"
$env:POSTGRES_USER = "your_user"
$env:POSTGRES_PASSWORD = "your_password"
$env:POSTGRES_DATABASE = "your_db"
$env:MYSQL_HOST = "localhost"
$env:MYSQL_PORT = "3306"
$env:MYSQL_USER = "your_user"
$env:MYSQL_PASSWORD = "your_password"
$env:MYSQL_DATABASE = "your_db"
claude2. 在 Claude Code 中注册 MCP Server
在 C:\Users\ASUS\.mcp.json 中添加:
{
"mcpServers": {
"db-mcp-server": {
"command": "cmd",
"args": [
"/c",
"cd /d C:\\Users\\ASUS\\db-mcp-server && node dist\\index.js"
]
}
}
}在 C:\Users\ASUS\.claude\settings.local.json 中启用:
{
"enabledMcpjsonServers": [
"db-mcp-server"
]
}修改环境变量、.mcp.json 或重新构建后,请重启 Claude Code 使配置生效。
构建与运行
pnpm run build
node dist/index.js开发调试
无需编译,直接使用 tsx 运行:
pnpm tsx src/index.tsOracle Thick 模式
如果数据库需要使用 thick 模式,请设置:
$env:ORACLE_THICK_MODE = "1"
$env:ORACLE_LIB_DIR = "C:\Users\ASUS\Desktop\instantclient_19_28"验证
重启 Claude Code 后,可以尝试:
"列出 Oracle 的表"
"列出 PostgreSQL 的表"
"列出 MySQL 的表"
"描述 postgres 中的 users 表"
"描述 mysql 中的 users 表"
"在 oracle 上执行 SELECT * FROM employees"
"在 mysql 上执行 SELECT * FROM users"
This server cannot be deployed
Maintenance
Related MCP Connectors
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
- dataOAuthco.thinair
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Query your Postgres from ChatGPT or Claude without exposing the database or handing over credentials. Run npx boltschema connect next to your database and it dials out over HTTPS — no inbound firewall rule, no open port, works with localhost and VPC-private databases. Read-only is enforced by a SQL guard, a Postgres READ ONLY transaction, and a scoped role generated for you.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides Claude with direct access to databases including SQLite, SQL Server, PostgreSQL, and MySQL, enabling execution of SQL queries and table management through natural language.676 npm1MIT
- AlicenseNot gradedqualityDmaintenanceEnables Claude to connect to and interact with SQLite, SQL Server, PostgreSQL, and MySQL databases through natural language. Supports executing queries, managing tables, exporting data, and storing business insights with authentication options including AWS IAM.676 npmMIT
- AlicenseNot gradedqualityFmaintenanceEnables connecting to any SQL database, exploring schemas, running queries, and visualizing results with interactive charts from Claude Desktop.MIT
- AlicenseNot gradedqualityCmaintenanceEnables Claude to query and manage databases (SQLite, SQL Server, PostgreSQL, MySQL) through natural language, supporting read/write operations and schema management.676 npmMIT