Get the FREE Ultimate OpenClaw Setup Guide →

db

A Rust-based MCP server that enables AI assistants to interact with SQL databases (SQLite, PostgreSQL, MySQL) safely and efficiently.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio alariczq-db-mcp-server db-mcp-server

How to use

This DB MCP Server is a Rust-based MCP server that lets AI assistants safely interact with SQL databases (SQLite, PostgreSQL, MySQL). It supports both stdio transport for CLI integrations and an HTTP mode with Server-Sent Events for web clients, with Bearer token authentication available for HTTP. The server enforces read-only defaults, protects against dangerous operations, and provides per-database lazy connection pools along with dynamic connection management. Tools are divided into read-only, write, and connection-management categories, enabling you to list connections and tables, describe schemas, run safe reads, modify data with explicit writable permissions, and manage connections at runtime.

To use it, start the server and connect via the transport you prefer. In HTTP mode, supply an auth token if you enable authentication, and use the provided tools to perform queries, explain plans, manage transactions, and inspect server/state information. The server supports mixed environments where you can define multiple databases, either in a single command, via environment variables, or through Claude/Codex/Claude Desktop configurations that map logical names to database URLs. Tools like list_connections, query, list_tables, describe_table, and explain help you retrieve data safely, while begin_transaction, commit, and rollback enable transactional work across multiple calls with transaction IDs.

How to install

Prerequisites:

  • Rust toolchain (stable) with cargo installed
  • Internet access to fetch crates

Option A — Install from source (recommended for development):

  1. Ensure Rust and Cargo are installed. Verify with: rustc --version cargo --version
  2. Clone the repository and navigate to the project root.
  3. Build and install the MCP server: cargo install --path . This installs the binary (db-mcp-server) to your Cargo bin directory.

Option B — Build a release binary locally:

  1. Ensure Rust is installed.
  2. From the project root, build in release mode: cargo build --release
  3. The binary will be at target/release/db-mcp-server. You can run it directly or move it to a location in your PATH.

Option C — Prerequisites for Docker-based workflows (if applicable):

  • Docker installed and running if you choose containerized usage (not required for this Rust build).

Additional notes

Notes and tips:

  • Default behavior is read-only; to perform writes, include ?writable=true in the database connection string.
  • Use server-level connections to connect to a server without selecting a default database.
  • The dangerous operation guard prevents DROP, TRUNCATE, and unqualified DELETE/UPDATE unless skip_sql_check is explicitly set to true.
  • For HTTP mode, provide a Bearer token via an Authorization header: Authorization: Bearer <token>.
  • You can manage connections at runtime with add_connection, update_connection, and delete_connection; be mindful of active transactions when updating or deleting connections.
  • Output formatting options include json, table, and markdown for query results and explain plans.

Related MCP Servers

Sponsor this space

Reach thousands of developers