Provides comprehensive database management tools including table listing, structure inspection, DDL export, and executing read-only and write queries on MySQL databases with engine-specific features.
Provides comprehensive database management tools including table listing, structure inspection, DDL export, and executing read-only and write queries on PostgreSQL databases.
Provides comprehensive database management tools including table listing, structure inspection, DDL export, and executing read-only and write queries on SQLite embedded databases.
SQLx MCP Server
A Model Context Protocol (MCP) server implementation in Rust that provides comprehensive database management tools using SQLx.
π Features
This server provides 6 powerful MCP tools for database management:
π get_database_info - Get basic database information
π list_tables - List all tables with metadata (comments, row counts, etc.)
ποΈ get_table_structure - Get detailed table structure information
π get_table_ddl - Export table DDL (CREATE TABLE statements)
ποΈ execute_readonly_query - Execute read-only SQL queries safely
βοΈ execute_write_query - Execute write SQL operations
π― Smart Configuration Management
Auto-Configuration Detection: Server automatically detects and reports database configuration at startup
Client Notification: Clients receive configuration status via MCP protocol initialization
Flexible URL Management: Optional database URL parameters when server is pre-configured
Secure Display: Database credentials are automatically masked for security
ποΈ Supported Databases
PostgreSQL - Full support with native features
MySQL - Complete functionality including engine-specific features
SQLite - Comprehensive support for embedded database operations
π§ Installation
Option 1: NPM (Recommended)
Install globally via npm:
Or use directly with npx (no installation needed):
Option 2: Build from Source
Prerequisites
Rust 1.70 or later
Git
Build Steps
π Quick Start
1. Run as Standalone Server
Using NPM/npx (Recommended):
Using Built Binary:
2. Integrate with Claude Desktop
Add to your Claude Desktop configuration. The server will automatically notify Claude about the current database configuration status.
Using NPM Package (Recommended):
With Environment Variable (Recommended):
With Command Line Argument:
Without Pre-configuration (require database_url in each tool call):
Using Built Binary:
Windows (
macOS/Linux:
π Database Configuration
The server provides intelligent database configuration management with automatic detection and client notification.
Configuration Priority
The server resolves database connections with the following priority:
Tool Parameter (highest) -
database_urlparameter in individual tool callsCommand Line -
--database-urlargument at server startupEnvironment Variable (lowest) -
DATABASE_URLenvironment variable
Auto-Detection & Client Notification
When clients connect to the MCP server, they automatically receive configuration information:
Configuration Status: Whether a database is pre-configured
Connection Source: How the database was configured (command line, environment, or none)
Masked URL: Database connection string with credentials safely hidden
Usage Guidance: Whether
database_urlparameter is required in tool calls
Example Client Notifications:
No Configuration:
Environment Variable Configuration:
Command Line Configuration:
Flexible Usage Patterns
Pre-configured Server (Recommended)
Then use tools without database_url parameter:
Per-Tool Database URLs
This allows flexible connection management for multiple databases.
π οΈ Tool Usage Examples
Get Database Information
List Tables with Metadata
Export Table DDL
Execute Safe Read-Only Queries
Supports SELECT, WITH (CTE), SHOW, DESCRIBE, EXPLAIN:
Note: When the server is pre-configured with a database (via command line or environment variable), the database_url parameter becomes optional in all tool calls. The server will notify clients about the current configuration status during MCP initialization.
π Security Features
Query Validation: Strict read-only query enforcement for safe operations
SQL Injection Protection: Parameterized queries where possible
Connection Security: Supports SSL/TLS encrypted connections
Access Control: Respects database user permissions
Credential Protection: Database passwords automatically masked in logs and client notifications
Secure Configuration Display: Connection strings shown with sensitive information hidden
ποΈ Architecture
Built with modern Rust ecosystem:
rmcp - Rust MCP SDK for protocol compliance
SQLx - Async SQL toolkit with compile-time checked queries
Tokio - Async runtime for high performance
Serde - Serialization framework for JSON handling
Tracing - Structured logging and debugging
π Documentation
π§ Development & Release
This project includes an advanced automated release system powered by AI:
Environment Setup
For Windows PowerShell users who want to use the automated release features:
For detailed PowerShell environment setup, see PowerShell Environment Setup Guide.
Release Management
The project includes a comprehensive release script with AI-powered commit message generation:
Features:
π€ AI-powered commit message generation using OpenRouter
π¦ Automatic version management
π Multi-file synchronization (Cargo.toml β package.json)
π Git automation (commit, tag, push)
π₯οΈ Cross-platform support (Windows, macOS, Linux)
π€ Contributing
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add some amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
Model Context Protocol for the protocol specification
SQLx for the excellent SQL toolkit
rmcp for the Rust MCP SDK
π Support
Create an Issue for bug reports
Start a Discussion for questions
Check the Documentation for detailed guides
Made with β€οΈ and π¦ (Rust)