MCP Server for database operations with PostgreSQL, MySQL/MariaDB, and SQLite - SQL injection protection, prepared statements, and comprehensive database management
- Update version badge to 2.0.0 - Add security features section - Update feature descriptions with pagination - Emphasize SQL injection protection 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .forgejo/workflows | ||
| src | ||
| .gitignore | ||
| CHANGELOG.md | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| vitest.config.ts | ||
🗄️ db-mcp
MCP Server for database operations with PostgreSQL, MySQL/MariaDB, and SQLite support - featuring SQL injection protection, prepared statements, pagination, and comprehensive database management.
Features
🔒 Security
- SQL Injection Protection - Validation for dangerous patterns
- Prepared Statements - All queries use parameterized statements
- SQL Validation - Warnings for potentially dangerous patterns
Query Execution
- 🔍
run_query- Execute SQL query with pagination support - 📄 Pagination -
limitandoffsetparameters - 🔐 Uses prepared statements for security
Schema Operations
- 📋
list_tables- List all tables - 🗂️
get_table_schema- Get table structure - 📊
get_table_info- Get table statistics (rows, size) - 🔍
describe_table- Detailed table information
Database Management
- 🗄️
list_databases- List all databases (PostgreSQL, MySQL)
Advanced Features
- 📈
explain_query- Analyze query execution plan
Supported Databases
- PostgreSQL 9.6+
- MySQL/MariaDB 5.7+
- SQLite 3.x
Installation
npm install
npm run build
Configuration
Set environment variables based on your database type:
PostgreSQL
export DB_TYPE=postgres
export DB_HOST=localhost
export DB_PORT=5432
export DB_USER=myuser
export DB_PASSWORD=mypassword
export DB_NAME=mydatabase
MySQL/MariaDB
export DB_TYPE=mysql
export DB_HOST=localhost
export DB_PORT=3306
export DB_USER=myuser
export DB_PASSWORD=mypassword
export DB_NAME=mydatabase
SQLite
export DB_TYPE=sqlite
export DB_PATH=/path/to/database.sqlite
Usage
npm start
What's New in v2.0.0
🎉 Major release with comprehensive improvements:
- 🏗️ Complete refactor - Modular architecture (205 lines → 102 lines, -50%)
- 🔒 SQL injection protection - Validation and prepared statements
- 🔒 100% type safety - Proper TypeScript throughout
- 📝 Complete JSDoc - All public APIs documented
- 📄 Pagination support -
limitandoffsetfor queries - 📦 Updated dependencies - MCP SDK 1.20.0 (latest)
See CHANGELOG.md for full details.
Security
⚠️ Important:
- Always use prepared statements (automatically done)
- SQL validation warns about dangerous patterns
- Never expose database credentials in logs
- Use read-only users when possible
- Limit query execution time
License
MIT