DB CLI MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add db-cli-mcp -- npx @mcp/dbcli-server --stdio
README.md

Unified, read-only interface for executing SQL queries via CLI tools.

DB CLI MCP Server

繁體中文版 README

A Model Context Protocol (MCP) Server that provides a unified, safe, AI-friendly interface for executing read-only database queries across multiple databases via CLI tools.


Features

  • Multi-database support — SQL Server, MySQL, MariaDB, PostgreSQL, Oracle
  • Read-only enforcement — Strict SELECT-only query execution with fail-closed validation
  • Zero-config startup — Server starts even without config files or CLI tools installed
  • Auto-detection — Scans project files (.env, appsettings.json, docker-compose.yml, etc.) for DB configs
  • Temporary connections — Ephemeral, in-memory-only connections that never touch disk
  • CLI tool guidance — Detects missing CLI tools and provides installation instructions
  • AI-native — Built for seamless integration with AI IDEs and CLI tools via MCP protocol

Supported Databases

Database CLI Tool Default Port
SQL Server sqlcmd 1433
MySQL mysql 3306
MariaDB mariadb 3306
PostgreSQL psql 5432
Oracle sqlplus 1521

Installation

Prerequisites

  • Node.js 18 or later
  • At least one database CLI tool installed (optional — server works without them)

Install via npm

npm install -g @mcp/dbcli-server

Install from source

git clone https://github.com/your-org/dbcli-mcp-server.git
cd dbcli-mcp-server
npm install
npm run build

Quick Start

1. Run the server

# Via npx (no install needed)
npx @mcp/dbcli-server --stdio

# Or if installed globally
dbcli-mcp-server --stdio

2. Check system status

Use the doctor tool to verify CLI tools and configuration:

{
  "serverVersion": "2.0",
  "cliStatus": [
    { "dbType": "mssql", "cli": "sqlcmd", "installed": true, "version": "17.10" },
    { "dbType": "mysql", "cli": "mysql", "installed": false }
  ],
  "issues": ["mysql not installed"]
}

3. Run a query

// Input
{ "sql": "SELECT * FROM users LIMIT 10" }

// Output
{
  "success": true,
  "columns": ["id", "name", "email"],
  "rows": [
    { "id": "1", "name": "Alice", "email": "alice@example.com" }
  ],
  "rowCount": 1,
  "truncated": false
}

AI IDE & CLI Integration

Claude Code

Claude Code supports MCP servers natively.

Setup

Add the server to your Claude Code MCP configuration:

claude mcp add dbcli -- npx @mcp/dbcli-server --stdio

Or manually edit ~/.claude/claude_desktop_config.json:

{
  "mcpServers": {
    "dbcli": {
      "command": "npx",
      "args": ["@mcp/dbcli-server", "--stdio"]
    }
  }
}
Usage

Once configured, you can ask Claude Code directly:

> Query the users table to show the first 10 records
> Check which database CLI tools are installed on my system
> Create a temporary connection to my local MySQL database
> Scan this project for database configurations

Codex CLI

Codex CLI supports MCP protocol integration.

Setup

Add to your Codex CLI configuration file ~/.codex/config.json:

{
  "mcpServers": {
    "dbcli": {
      "command": "npx",
      "args": ["@mcp/dbcli-server", "--stdio"]
    }
  }
}
Usage
codex "Query the users table in my local SQL Server database"
codex "What database configurations exist in this project?"

Cursor

Cursor supports MCP servers for AI-assisted development.

Setup
  1. Open Cursor Settings: Ctrl+Shift+J (Windows/Linux) or Cmd+Shift+J (macOS)
  2. Navigate to MCP section
  3. Click "Add new MCP server"
  4. Fill in the configuration:
{
  "mcpServers": {
    "dbcli": {
      "command": "npx",
      "args": ["@mcp/dbcli-server", "--stdio"]
    }
  }
}

Or manually edit .cursor/mcp.json in your

Tools (2)

doctorVerifies CLI tools and configuration status
queryExecutes a read-only SQL query against a database

Configuration

claude_desktop_config.json
{"mcpServers": {"dbcli": {"command": "npx", "args": ["@mcp/dbcli-server", "--stdio"]}}}

Try it

Query the users table to show the first 10 records
Check which database CLI tools are installed on my system
Scan this project for database configurations
Create a temporary connection to my local MySQL database and list the tables

Frequently Asked Questions

What are the key features of DB CLI MCP Server?

Multi-database support for SQL Server, MySQL, MariaDB, PostgreSQL, and Oracle. Strict read-only enforcement for safe AI-driven data interactions. Auto-detection of project database configurations from files like .env and docker-compose.yml. Ephemeral, in-memory-only connections that never touch the disk. CLI tool guidance for missing dependencies.

What can I use DB CLI MCP Server for?

Allowing AI agents to inspect database schemas for context-aware code generation. Quickly querying local development databases without leaving the IDE. Verifying database connectivity and configuration status within a project. Safely exploring production-like data in a read-only environment.

How do I install DB CLI MCP Server?

Install DB CLI MCP Server by running: npm install -g @mcp/dbcli-server

What MCP clients work with DB CLI MCP Server?

DB CLI MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep DB CLI MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare