Back to Home
ShivankarMehta icon

DB_MCP_SERVER

Verified Safe

by ShivankarMehta

Overview

Provides a read-only interface to a MySQL database, allowing external agents to execute safe SELECT, SHOW, DESCRIBE, or EXPLAIN queries via the Model Context Protocol.

Installation

Run Command
node index.js

Environment Variables

  • MYSQL_DATABASE
  • MYSQL_HOST
  • MYSQL_PORT
  • MYSQL_USER
  • MYSQL_PASSWORD

Security Notes

The server includes a robust 'isReadOnlyQuery' function that whitelists allowed SQL commands (SELECT, SHOW, DESCRIBE, EXPLAIN) and blacklists dangerous keywords (INSERT, UPDATE, DELETE, DROP, CREATE, ALTER, TRUNCATE, REPLACE, INTO OUTFILE, INTO DUMPFILE, LOAD_FILE). This significantly mitigates SQL injection risks for write/schema modification operations. The keyword check uses `includes()`, which can sometimes be overzealous and block legitimate read-only queries if a blacklisted keyword appears within a string literal (e.g., `SELECT 'insert'`), but this is a strict safeguard rather than a vulnerability. Environment variables are used for database credentials, preventing hardcoded secrets. The server uses StdioServerTransport, limiting direct network exposure for this specific component.

Similar Servers

Stats

Interest Score0
Security Score8
Cost ClassMedium
Avg Tokens750
Stars0
Forks0
Last Update2025-11-27

Tags

MySQLDatabaseRead-OnlyAPIMCP