MCP Server for database operations with PostgreSQL, MySQL/MariaDB, and SQLite - SQL injection protection, prepared statements, and comprehensive database management
Find a file
Jonas Hanisch 334cf95769 docs: update README for v2.0.0
- 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>
2025-10-10 10:15:50 +02:00
.forgejo/workflows fix: use direct authentication token in CI workflow (v1.0.5) 2025-10-07 17:09:53 +02:00
src Release v2.0.0: Complete refactor with security improvements 2025-10-10 10:14:00 +02:00
.gitignore fix: registry configuration for scope-based installation (v1.0.1) 2025-10-07 12:33:54 +02:00
CHANGELOG.md Release v2.0.0: Complete refactor with security improvements 2025-10-10 10:14:00 +02:00
package-lock.json Release v2.0.0: Complete refactor with security improvements 2025-10-10 10:14:00 +02:00
package.json Release v2.0.0: Complete refactor with security improvements 2025-10-10 10:14:00 +02:00
README.md docs: update README for v2.0.0 2025-10-10 10:15:50 +02:00
tsconfig.json Initial implementation of db-mcp 2025-10-07 10:54:11 +02:00
vitest.config.ts Release v2.0.0: Complete refactor with security improvements 2025-10-10 10:14:00 +02:00

🗄️ db-mcp

Version CI Status License NPM

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 - limit and offset parameters
  • 🔐 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 - limit and offset for 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