| Crates.io | mcp-dbtools |
| lib.rs | mcp-dbtools |
| version | 0.1.1 |
| created_at | 2025-07-01 20:23:13.584716+00 |
| updated_at | 2025-07-03 10:26:08.768144+00 |
| description | A database management tool for the Model Context Protocol (MCP), providing database operations and AI agent integration. |
| homepage | https://github.com/anggasct/mcp-dbtools |
| repository | https://github.com/anggasct/mcp-dbtools |
| max_upload_size | |
| id | 1733749 |
| size | 76,794 |
A Model Context Protocol (MCP) server that provides secure database access through MCP Server and other MCP-compatible clients.
~/.mcp-dbtools/config.yml${VAR_NAME} syntax for secure credential managementClone the repository:
git clone <repository-url>
cd mcp-dbtools
Build the project:
cargo build --release
Create configuration directory:
mkdir -p ~/.mcp-dbtools
Create ~/.mcp-dbtools/config.yml:
# Configuration for MCP DB Tools
# Use ${VAR_NAME} to load sensitive values from environment variables.
servers:
# Local development database
test_db:
adapter: "postgres"
enabled: true
host: "localhost"
port: 5432
username: "postgres"
password: "postgres" # WARNING: Use env vars for production
dbname: "pocket_db"
read_only: false
# Production database
prod_db:
adapter: "mysql"
enabled: true
host: "prod.example.com"
port: 3306
username: "produser"
password: "${PROD_DB_PASSWORD}"
dbname: "production_db"
read_only: true
Set required environment variables:
export PROD_DB_PASSWORD="your-secure-password"
# Run with specific server configuration
cargo run --bin mcp-dbtools test_db
# Run with default server (test_db)
cargo run --bin mcp-dbtools
# Use release build
./target/release/mcp-dbtools prod_db
Add to your MCP Server settings file:
macOS: ~/Library/Application Support/MCP Server/mcp_server_config.json
Windows: %APPDATA%\MCP Server\mcp_server_config.json
{
"mcpServers": {
"db-tools-pocket": {
"command": "cargo",
"args": ["run", "--bin", "mcp-dbtools", "--", "test_db"],
"cwd": "/path/to/mcp-dbtools",
"env": {}
}
}
}
Or with pre-built binary:
{
"mcpServers": {
"db-tools-pocket": {
"command": "/path/to/mcp-dbtools/target/release/mcp-dbtools",
"args": ["test_db"],
"env": {}
}
}
}
# Test database schema and data
cargo run --bin test_db
# Explore database content
cargo run --bin explore_data
# Test server with YAML config
cargo run --bin mcp-dbtools test_db
| Field | Type | Required | Description |
|---|---|---|---|
adapter |
string | Yes | Database type (e.g., "postgres", "mysql") |
enabled |
boolean | No | Enable/disable this server config |
host |
string | Yes | Database hostname |
port |
number | Yes | Database port |
username |
string | Yes | Database username |
password |
string | No | Database password (use env vars!) |
dbname |
string | Yes | Database name |
read_only |
boolean | No | Restrict to read-only operations |
password: "${DB_PASSWORD}"
chmod 600 ~/.mcp-dbtools/config.yml
Through MCP Server, you can:
"Failed to load YAML config"
~/.mcp-dbtools/config.yml exists"Environment variable not found"
"Failed to connect to database"
"Server 'xyz' not found in config"
servers:Run with verbose output:
RUST_LOG=debug cargo run --bin mcp-dbtools test_db
mcp-dbtools/
โโโ src/
โ โโโ main.rs # MCP server entry point
โ โโโ config.rs # Configuration management
โ โโโ test_db.rs # Database testing utility
โ โโโ explore_data.rs # Data exploration utility
โโโ mcp-rust-sdk/ # MCP SDK dependency
โโโ ~/.mcp-dbtools/ # Configuration directory
โ โโโ config.yml # Database configurations
โโโ README.md
# Development build
cargo build
# Release build
cargo build --release
# Run tests
cargo test
# Check code quality
cargo clippy
cargo fmt
[Add your license information here]
[Add contribution guidelines here]
[Add support contact information here]