Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
6,000+ web scrapers for your AI agent, start free logo6,000+ web scrapers for your AI agent, start free

Apify gives your agent live web data: 6,000+ prebuilt scrapers and actors, MCP-ready. Sign up free with $5 in usage credits.

Try Apify free
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 48,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

Enables Claude Code to execute read-only queries and DML operations on Oracle and PostgreSQL databases, and to list or describe database tables.

README.md

DB MCP Server

English | 中文

一个基于 TypeScript 实现的 Model Context Protocol 服务,让 Claude Code 可以直接查询 OraclePostgreSQLMySQL 数据库。

支持的数据库

  • Oracle(通过 oracledb 驱动,默认 thin 模式)
  • PostgreSQL(通过 pg 驱动)
  • MySQL(通过 mysql2 驱动)

提供的工具

  • 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 installyarn installpreinstall 脚本会报错并阻止安装。

配置

1. 环境变量 / .env 文件

支持两种配置方式,优先级如下:

  1. 系统环境变量(最高优先级)
  2. 项目根目录下的 .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"

claude

2. 在 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.ts

Oracle 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"

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Databases servers.