mcp-db-universal

mcp-db-universal

A database-agnostic MCP server that enables natural language queries to your database through Claude or Copilot, automatically writing and executing SQL.

Category
访问服务器

README

mcp-db-universal

A database-agnostic MCP (Model Context Protocol) server that lets you chat with your database through Claude or GitHub Copilot. Ask questions in plain English and the AI will write and execute the SQL for you.

Supported Databases

Database Driver Install
PostgreSQL pg npm install pg
MySQL mysql2 npm install mysql2
SQL Server mssql npm install mssql
SQLite better-sqlite3 npm install better-sqlite3
Oracle oracledb npm install oracledb

Quick Start

0. Prerequisites — Install Node.js

This tool runs on Node.js. If you don't have it installed, do that first:

  1. Go to nodejs.org and download the LTS version (recommended for most users)
  2. Run the installer and follow the prompts
  3. Once installed, open a terminal (Command Prompt / PowerShell on Windows, Terminal on macOS/Linux) and verify it worked:
node --version   # should print something like v20.x.x
npm --version    # should print something like 10.x.x

If both commands return version numbers, you're good to go

1. Install globally

npm install -g fm-db-mcp-universal

# Then install your DB driver:
npm install -g pg           # PostgreSQL
npm install -g mysql2       # MySQL
npm install -g mssql tedious # SQL Server
npm install -g better-sqlite3  # SQLite
npm install -g oracledb     # Oracle

2. Connect to Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or C:\Users\<username>\AppData\Roaming\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "my-db": {
      "command": "npx",
      "args": ["fm-db-mcp-universal"],
      "env": {
        "DB_CLIENT":   "oracle",
        "DB_HOST":     "localhost",
        "DB_PORT":     "1521",
        "DB_NAME":     "orcl",
        "DB_USER":     "xxx",
        "DB_PASSWORD": "xxx"
      }
    }
  }
}

3. Connect to VS Code (GitHub Copilot Agent mode)

Create .vscode/mcp.json in your workspace:

{
  "servers": {
    "oracle-db": {
      "command": "npx",
      "args": [
        "fm-db-mcp-universal"
      ],
      "env": {
        "DB_CLIENT": "oracle",
        "DB_HOST": "localhost",
        "DB_PORT": "1521",
        "DB_NAME": "orcl",
        "DB_USER": "FMCPROD1",
        "DB_PASSWORD": "FMCPROD1"
      }
    },
    "postgres-db": {
      "command": "npx",
      "args": [
        "fm-db-mcp-universal"
      ],
      "env": {
        "DB_CLIENT": "postgres",
        "DB_HOST": "localhost",
        "DB_PORT": "5432",
        "DB_USER": "postgres",
        "DB_PASSWORD": "password",
        "DB_NAME": "postgres"
      }
    },
    "mssql-db": {
      "command": "npx",
      "args": [
        "fm-db-mcp-universal"
      ],
      "env": {
        "DB_CLIENT": "mssql",
        "DB_HOST": "localhost",
        "DB_PORT": "1433",
        "DB_USER": "sa",
        "DB_PASSWORD": "sadmin",
        "DB_NAME": "ALLMERGE"
      }
    },
  }
}

Configuration

All configuration is via environment variables:

Variable Description Default
DB_CLIENT Database type: postgres, mysql, mssql, sqlite, oracle postgres
DB_HOST Database host localhost
DB_PORT Database port (auto-detected if not set) per DB
DB_USER Username —
DB_PASSWORD Password —
DB_NAME Database name —
DB_FILENAME File path (SQLite only) —
DB_CONNECTION_STRING Full connection string (overrides above) —
DB_READONLY Set true to disable writes/DDL false
DB_POOL_MIN Connection pool minimum 1
DB_POOL_MAX Connection pool maximum 5

Using a Connection String

{
  "env": {
    "DB_CLIENT": "postgres",
    "DB_CONNECTION_STRING": "postgresql://user:pass@localhost:5432/mydb"
  }
}

Database-Specific Examples

PostgreSQL

{
  "DB_CLIENT": "postgres",
  "DB_HOST": "localhost",
  "DB_USER": "postgres",
  "DB_PASSWORD": "secret",
  "DB_NAME": "myapp"
}

MySQL / MariaDB

{
  "DB_CLIENT": "mysql",
  "DB_HOST": "localhost",
  "DB_USER": "root",
  "DB_PASSWORD": "secret",
  "DB_NAME": "myapp"
}

SQL Server (MSSQL)

{
  "DB_CLIENT": "mssql",
  "DB_HOST": "localhost",
  "DB_PORT": "1433",
  "DB_USER": "sa",
  "DB_PASSWORD": "YourPassword123!",
  "DB_NAME": "Northwind"
}

SQLite

{
  "DB_CLIENT": "sqlite",
  "DB_FILENAME": "/path/to/database.db"
}

Oracle

{
  "DB_CLIENT": "oracle",
  "DB_HOST": "localhost",
  "DB_PORT": "1521",
  "DB_USER": "myuser",
  "DB_PASSWORD": "mypassword",
  "DB_NAME": "ORCL"
}

Available MCP Tools

Tool Description
db_ping Test connection and confirm it's working
db_query Run a SELECT query (read-only, auto-limited to 100 rows)
db_execute Run INSERT/UPDATE/DELETE/DDL (disabled in read-only mode)
db_list_tables List all tables and views
db_describe_table Get columns, types, nullability for a table
db_table_indexes Get index information for a table
db_foreign_keys Get foreign key relationships for a table
db_schema_snapshot Full schema dump of all tables at once

Example Chat Interactions

Once connected, just talk naturally:

"What tables do I have?" → Calls db_list_tables

"Show me all users who signed up in the last 30 days" → Writes and executes a SELECT with date filter

"How many orders are in 'pending' status?" → COUNT query

"What's the schema of the orders table?" → Calls db_describe_table

"Add an index on users.email" → Calls db_execute with CREATE INDEX statement

"Give me a summary of sales by region this year" → GROUP BY query with aggregation


Read-Only Mode

To protect production databases, enable read-only mode:

{
  "env": {
    "DB_READONLY": "true",
    ...
  }
}

In read-only mode, db_execute is disabled — only SELECT queries are allowed.


Running from Source

git clone https://github.com/yourname/mcp-db-universal
cd mcp-db-universal
npm install
npm install better-sqlite3  # or your DB driver
npm run build

Then configure Claude/Copilot to use:

{
  "command": "node",
  "args": ["/path/to/mcp-db-universal/dist/index.js"],
  "env": { ... }
}

Or run directly in dev mode:

DB_CLIENT=sqlite DB_FILENAME=./test.db npm run dev

Publishing to npm

npm run build
npm publish

Users can then use npx:

{
  "command": "npx",
  "args": ["mcp-db-universal"],
  "env": { ... }
}

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选