
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@sqlx-mcp/sqlx-mcp
Advanced tools
A Model Context Protocol (MCP) server implementation in Rust that provides comprehensive database management tools using SQLx.
This server provides 6 powerful MCP tools for database management:
Install globally via npm:
npm install -g @sqlx-mcp/sqlx-mcp
Or use directly with npx (no installation needed):
npx @sqlx-mcp/sqlx-mcp --database-url "postgresql://user:pass@localhost/mydb"
git clone https://github.com/lihongjie0209/sqlx-mcp.git
cd sqlx-mcp
cargo build --release
# Install globally and run
npm install -g @sqlx-mcp/sqlx-mcp
sqlx-mcp --database-url "postgresql://user:pass@localhost/mydb"
# Or run directly with npx (no installation needed)
npx @sqlx-mcp/sqlx-mcp --database-url "postgresql://user:pass@localhost/mydb"
# With environment variable
export DATABASE_URL="postgresql://user:pass@localhost/mydb"
npx @sqlx-mcp/sqlx-mcp
# With environment variable
export DATABASE_URL="postgresql://user:pass@localhost/mydb"
./target/release/sqlx-mcp
# With command line argument
./target/release/sqlx-mcp --database-url "postgresql://user:pass@localhost/mydb"
Add to your Claude Desktop configuration. The server will automatically notify Claude about the current database configuration status.
With Environment Variable (Recommended):
{
"mcpServers": {
"sqlx-mcp": {
"command": "npx",
"args": ["@sqlx-mcp/sqlx-mcp"],
"env": {
"DATABASE_URL": "postgresql://user:pass@localhost/mydb"
}
}
}
}
With Command Line Argument:
{
"mcpServers": {
"sqlx-mcp": {
"command": "npx",
"args": ["@sqlx-mcp/sqlx-mcp", "--database-url", "postgresql://user:pass@localhost/mydb"]
}
}
}
Without Pre-configuration (require database_url in each tool call):
{
"mcpServers": {
"sqlx-mcp": {
"command": "npx",
"args": ["@sqlx-mcp/sqlx-mcp"]
}
}
}
Windows (%APPDATA%\Claude\claude_desktop_config.json):
{
"mcpServers": {
"sqlx-mcp": {
"command": "D:\\path\\to\\sqlx-mcp\\target\\release\\sqlx-mcp.exe",
"args": ["--database-url", "postgresql://user:pass@localhost/mydb"]
}
}
}
macOS/Linux:
{
"mcpServers": {
"sqlx-mcp": {
"command": "/path/to/sqlx-mcp/target/release/sqlx-mcp",
"args": ["--database-url", "postgresql://user:pass@localhost/mydb"]
}
}
}
The server provides intelligent database configuration management with automatic detection and client notification.
The server resolves database connections with the following priority:
database_url parameter in individual tool calls--database-url argument at server startupDATABASE_URL environment variableWhen clients connect to the MCP server, they automatically receive configuration information:
database_url parameter is required in tool callsNo Configuration:
Current database configuration: No database configured. Please provide database_url parameter in tool calls or set DATABASE_URL environment variable.
Environment Variable Configuration:
Current database configuration: Database configured via environment variable: postgresql://user:***@localhost:5432/mydb
If a database is already configured, you can omit the database_url parameter in tool calls.
Command Line Configuration:
Current database configuration: Database configured via command line: mysql://root:***@localhost:3306/testdb
If a database is already configured, you can omit the database_url parameter in tool calls.
# Set up database via environment variable
export DATABASE_URL="postgresql://user:pass@localhost/mydb"
npx @sqlx-mcp/sqlx-mcp
# Or via command line
npx @sqlx-mcp/sqlx-mcp --database-url "postgresql://user:pass@localhost/mydb"
Then use tools without database_url parameter:
{
"name": "list_tables",
"arguments": {}
}
{
"name": "list_tables",
"arguments": {
"database_url": "postgresql://user:pass@different-host/other-db"
}
}
This allows flexible connection management for multiple databases.
{
"name": "get_database_info",
"arguments": {
"database_url": "postgresql://user:pass@localhost/mydb" // Optional if server is pre-configured
}
}
{
"name": "list_tables",
"arguments": {
"database_url": "postgresql://user:pass@localhost/mydb" // Optional if server is pre-configured
}
}
{
"name": "get_table_ddl",
"arguments": {
"database_url": "postgresql://user:pass@localhost/mydb", // Optional if server is pre-configured
"table_name": "users"
}
}
Supports SELECT, WITH (CTE), SHOW, DESCRIBE, EXPLAIN:
{
"name": "execute_readonly_query",
"arguments": {
"database_url": "postgresql://user:pass@localhost/mydb", // Optional if server is pre-configured
"query": "WITH recent_users AS (SELECT * FROM users WHERE created_at > '2024-01-01') SELECT count(*) FROM recent_users"
}
}
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.
Built with modern Rust ecosystem:
This project includes an advanced automated release system powered by AI:
For Windows PowerShell users who want to use the automated release features:
# Quick setup using .env file (recommended)
Copy-Item ".env.template" ".env"
notepad .env # Add your OPENROUTER_API_KEY
# Or set environment variable for current session
$env:OPENROUTER_API_KEY = "your-api-key-here"
For detailed PowerShell environment setup, see PowerShell Environment Setup Guide.
The project includes a comprehensive release script with AI-powered commit message generation:
# Create automated release with AI-generated commit messages
npm run release
# The script will:
# - Bump version numbers
# - Generate intelligent commit messages using AI
# - Update package files
# - Create git commits and tags
# - Push to repository
Features:
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ and 🦀 (Rust)
FAQs
Rust MCP server for SQLx database management
We found that @sqlx-mcp/sqlx-mcp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.