Claude Database Tools MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone https://github.com/cyronius/claude-database-tools.git
cd claude-database-tools
npm install
npm run build
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add -e "SQL_SERVER=${SQL_SERVER}" -e "SQL_DATABASE=${SQL_DATABASE}" -e "SQL_USER=${SQL_USER}" -e "SQL_PASSWORD=${SQL_PASSWORD}" claude-database-tools -- node "<FULL_PATH_TO_CLAUDE_DATABASE_TOOLS>/dist/index.js"

Replace <FULL_PATH_TO_CLAUDE_DATABASE_TOOLS>/dist/index.js with the actual folder you prepared in step 1.

Required:SQL_SERVERSQL_DATABASESQL_USERSQL_PASSWORD+ 2 optional
README.md

SQL Server CLI and MCP server for Claude Code

claude-database-tools

SQL Server CLI and MCP server for Claude Code.

Why This Tool?

This project is an alternative to Microsoft's official mssql MCP server with some key advantages:

  • SQL Server Authentication: Supports SQL Server authentication (username/password), not just Windows/Entra authentication. Ideal for development environments, Docker containers, or scenarios where integrated auth isn't available.

  • CLI-First Design: The CLI tools can be used directly from a Claude Code skill, giving you database access without requiring MCP server setup. This is useful when you want simpler configuration or need to work in environments where MCP servers are problematic.

  • MCP Server Included: Also provides an MCP server if you prefer that integration approach.

Features

  • CLI Tool: Command-line interface for SQL Server operations
  • MCP Server: Model Context Protocol server for Claude integration (experimental)
  • Security: Built-in SQL injection prevention and query validation
  • Operations: List tables, describe schemas, query data, insert/update/delete records, DDL generation

Installation

git clone https://github.com/cyronius/claude-database-tools.git
cd claude-database-tools
npm install
npm run build

Configuration

Copy .env.example to .env and configure your database connection:

cp .env.example .env

Edit .env with your SQL Server credentials:

SQL_SERVER=localhost
SQL_DATABASE=your_database
SQL_USER=your_username
SQL_PASSWORD=your_password
SQL_PORT=1433
SQL_ENCRYPT=false
SQL_TRUST_SERVER_CERTIFICATE=true

CLI Usage

After building, run commands with:

node dist/cli/index.js <command> [options]

Or install globally:

npm install -g .
sql-cli <command> [options]

Commands

Command Description
list-tables [schemas...] List tables, optionally filtered by schema
describe-table <tableName> Get table schema (columns, indexes, foreign keys)
read-data <query> Execute a SELECT query
insert-data <tableName> <jsonData> Insert records
update-data <tableName> <updates> <whereClause> Update records
delete-data <tableName> <whereClause> --confirm Delete records
exec-proc [params] Execute stored procedure
create-table <tableName> <columns> Create a new table
drop-table <tableName> Drop a table
create-index <tableName> <indexName> <columns> Create an index
get-ddl <tableName> Generate CREATE TABLE DDL
get-alter-ddl <tableName> Generate ALTER TABLE DDL

Examples

# List all tables
sql-cli list-tables

# List tables in specific schemas
sql-cli list-tables dbo sales

# Describe a table
sql-cli describe-table dbo.Users

# Query data
sql-cli read-data "SELECT TOP 10 * FROM dbo.Users"

# Insert data
sql-cli insert-data dbo.Users '{"name": "John", "email": "john@example.com"}'

# Update data
sql-cli update-data dbo.Users '{"name": "Jane"}' "id = 1"

# Delete data (requires --confirm flag)
sql-cli delete-data dbo.Users "id = 1" --confirm

# Get table DDL
sql-cli get-ddl dbo.Users

MCP Server (Experimental)

Note: The MCP server integration has not been fully tested. Use at your own risk.

The MCP server allows Claude Code to interact with your SQL Server database directly.

Setup

Add to your ~/.claude/mcp.json:

{
  "mcpServers": {
    "mssql": {
      "command": "node",
      "args": ["/path/to/claude-database-tools/dist/index.js"],
      "env": {
        "SQL_SERVER": "your-server",
        "SQL_DATABASE": "your-database",
        "SQL_USER": "your-username",
        "SQL_PASSWORD": "your-password",
        "SQL_ENCRYPT": "true",
        "READONLY": "true"
      }
    }
  }
}

Restart Claude Code to load the MCP server.

Available MCP Tools

Read-Only (available when READONLY=true):

  • list_tables - List tables
  • describe_table - Get table schema
  • read_data - Execute SELECT queries
  • get_table_ddl - Generate CREATE TABLE DDL
  • get_table_alter_ddl - Generate ALTER TABLE DDL

Write (requires READONLY=false):

  • insert_data - Insert records
  • update_data - Update records
  • delete_data - Delete records
  • create_table - Create tables
  • create_index - Create indexes
  • drop_table - Drop tables
  • execute_stored_proc - Execute stored procedures

Security

  • SQL Injection Prevention: SELECT queries are validated against dangerous keywords and patterns
  • Parameterized Queries: All INSERT/UPDATE/DELETE operations use parameterized queries
  • WHERE Clause Required: UPDATE and DELETE operations require WHERE clauses
  • Query Limits: Maximum query length of 10,000 characters, result sets limited to 10,000 records
  • Read-Only Mode: Set READONLY=true to disable write operations

Tools (12)

list_tablesList tables in the database
describe_tableGet table schema including columns, indexes, and foreign keys
read_dataExecute a SELECT query
insert_dataInsert records into a table
update_dataUpdate records in a table
delete_dataDelete records from a table
execute_stored_procExecute a stored procedure
create_tableCreate a new table
create_indexCreate an index on a table
drop_tableDrop a table from the database
get_table_ddlGenerate CREATE TABLE DDL
get_table_alter_ddlGenerate ALTER TABLE DDL

Environment Variables

SQL_SERVERrequiredThe hostname or IP of the SQL Server
SQL_DATABASErequiredThe name of the database
SQL_USERrequiredUsername for SQL Server authentication
SQL_PASSWORDrequiredPassword for SQL Server authentication
SQL_ENCRYPTWhether to use encryption for the connection
READONLYSet to true to disable write operations

Configuration

claude_desktop_config.json
{"mcpServers": {"mssql": {"command": "node", "args": ["/path/to/claude-database-tools/dist/index.js"], "env": {"SQL_SERVER": "your-server", "SQL_DATABASE": "your-database", "SQL_USER": "your-username", "SQL_PASSWORD": "your-password", "SQL_ENCRYPT": "true", "READONLY": "true"}}}}

Try it

List all tables in the current database to get an overview of the schema.
Describe the structure of the 'Users' table including its columns and indexes.
Query the top 10 records from the 'Orders' table.
Generate the CREATE TABLE DDL for the 'Products' table.
Insert a new record into the 'Logs' table with the provided JSON data.

Frequently Asked Questions

What are the key features of Claude Database Tools?

Supports SQL Server authentication (username/password). Provides both a CLI tool and an MCP server. Built-in SQL injection prevention and query validation. Supports schema exploration and DDL generation. Includes a read-only mode for secure database access.

What can I use Claude Database Tools for?

Managing database records directly from the Claude Code interface. Exploring database schemas in development environments without integrated auth. Generating DDL scripts for table modifications via natural language. Executing ad-hoc queries and stored procedures during development.

How do I install Claude Database Tools?

Install Claude Database Tools by running: git clone https://github.com/cyronius/claude-database-tools.git && cd claude-database-tools && npm install && npm run build

What MCP clients work with Claude Database Tools?

Claude Database Tools 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 Claude Database Tools 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