| Crates.io | sqlx-mcp |
| lib.rs | sqlx-mcp |
| version | 0.1.0 |
| created_at | 2026-01-09 01:10:53.810387+00 |
| updated_at | 2026-01-09 01:10:53.810387+00 |
| description | SQLx MCP Server - Secure multi-database CRUD operations via Model Context Protocol |
| homepage | https://github.com/epicsagas/sqlx-mcp |
| repository | https://github.com/epicsagas/sqlx-mcp |
| max_upload_size | |
| id | 2031364 |
| size | 187,397 |
A Rust-based MCP (Model Context Protocol) server providing secure multi-database operations for MCP clients.
.databases.json--init wizard for agent configurationcargo install sqlx-mcp
Or build from source:
git clone https://github.com/epicsagas/sqlx-mcp.git
cd sqlx-mcp
cargo build --release
cp target/release/sqlx-mcp ~/.local/bin/
# Interactive setup
sqlx-mcp --init
# Or configure specific agent
sqlx-mcp --init cursor
sqlx-mcp --init claude-code
sqlx-mcp --init claude-desktop
sqlx-mcp --status
Restart Claude Desktop, Claude Code, or Cursor to load the MCP server.
Note: For Claude Code, a skill is automatically installed at
~/.claude/skills/sqlx/SKILL.md
.databases.json)Create a .databases.json file in your project directory or ~/.config/sqlx-mcp/:
{
"version": "1.0",
"databases": [
{
"name": "mysql_main",
"engine": "mysql",
"host": "localhost",
"port": 3306,
"username": "root",
"password": "secret",
"database": "myapp"
},
{
"name": "postgres_analytics",
"engine": "postgres",
"host": "localhost",
"port": 5432,
"username": "postgres",
"password": "secret",
"database": "analytics"
},
{
"name": "sqlite_cache",
"engine": "sqlite",
"path": "/var/data/cache.db"
}
],
"default_connection": "mysql_main"
}
See .databases.json.example for a complete configuration example.
| Tool | Description |
|---|---|
db_list_connections |
List all configured database connections |
db_query |
Execute SELECT queries, returns JSON array |
db_insert |
Execute INSERT, returns last_insert_id |
db_update |
Execute UPDATE, returns rows_affected |
db_delete |
Execute DELETE, returns rows_affected |
db_list_tables |
List all tables in database |
db_describe_table |
Get table structure |
db_health_check |
Check database connectivity |
The Claude Code skill allows you to use natural language to query databases:
| Request | Description |
|---|---|
| "Get active users from mysql_main" | Query active users from mysql_main |
| "Show recent 10 orders from postgres" | Get recent 10 orders from postgres |
| "List tables in sqlite_cache" | List all tables in sqlite_cache |
| "Describe users table structure in mydb" | Get users table schema |
| "Add new user John to mysql_main" | Insert new user John into mysql_main |
| "Delete record with id 5 from postgres" | Delete record with id 5 from postgres |
{}
{
"query": "SELECT * FROM users WHERE status = ?",
"params": ["active"],
"connection": "mysql_main"
}
{
"query": "SELECT * FROM orders WHERE user_id = ?",
"params": [123]
}
{
"query": "INSERT INTO users (name, email) VALUES (?, ?)",
"params": ["John", "john@example.com"],
"connection": "postgres_analytics"
}
{
"query": "UPDATE users SET status = ? WHERE id = ?",
"params": ["inactive", 5]
}
{
"query": "DELETE FROM users WHERE id = ?",
"params": [10]
}
{
"connection": "sqlite_cache"
}
{
"table": "users",
"connection": "mysql_main"
}
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/claude/claude_desktop_config.json
{
"mcpServers": {
"sqlx": {
"command": "sqlx-mcp",
"env": {
"SQLX_MCP_CONFIG": "/path/to/.databases.json",
"RUST_LOG": "info"
}
}
}
}
Path: ~/.claude.json
{
"mcpServers": {
"sqlx": {
"command": "sqlx-mcp",
"env": {
"SQLX_MCP_CONFIG": "/path/to/.databases.json",
"RUST_LOG": "info"
}
}
}
}
Note: Project-level config can also be placed in
.mcp.jsonin the project root.
Path: ~/.cursor/mcp.json
{
"mcpServers": {
"sqlx": {
"command": "sqlx-mcp",
"env": {
"SQLX_MCP_CONFIG": "/path/to/.databases.json",
"RUST_LOG": "info"
}
}
}
}
? placeholders (auto-converted to $1,$2,... for PostgreSQL).databases.json is hidden by default for security-- Good: Use parameterized queries
SELECT * FROM users WHERE id = ?
-- Bad: Never concatenate values (blocked by design)
SELECT * FROM users WHERE id = 1; DROP TABLE users;
# Check database is running
mysql -u your_user -p -h localhost your_database
psql -U your_user -h localhost your_database
# Verify configuration
sqlx-mcp --status
which sqlx-mcp.databases.json file exists and is validApache-2.0 License - see LICENSE for details.
If you find this project useful, consider supporting: