Provides a structured MCP server to query and manage MySQL databases with secure, multi-database access and schema discovery.
Configuration
View docs{
"mcpServers": {
"keleshteri-mcp-mysql-server": {
"command": "node",
"args": [
"/full/path/to/mcp-mysql-server/dist/index.js"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"ENABLE_LOGGING": "true",
"MYSQL_DATABASE": "your_database",
"MYSQL_PASSWORD": "your_password"
}
}
}
}This MCP server lets you interact with MySQL databases through a secure, perfomance‑oriented interface. It supports multiple databases, schema discovery, query validation, and optional detailed logging, making it easier to build reliable data integrations with Claude Desktop.
You use the MCP server by connecting a Claude Desktop client to the local MCP instance. Start the server locally and configure Claude Desktop to load the MCP server so you can run queries, switch databases, and explore schemas from the same interface.
git clone <your-repo-url>
cd mcp-mysql-server
npm install
```
```bash
cp .env.example .env
# Edit .env with your MySQL credentials
```
```bash
npm run build
```
```json
{
"mcpServers": {
"mysql-server": {
"command": "node",
"args": ["/full/path/to/mcp-mysql-server/dist/index.js"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database",
"ENABLE_LOGGING": "true"
}
}
}
}Configure the MCP server using environment variables to control how it connects to MySQL, what databases are visible, and how verbose the logs should be. The following options affect how you connect and secure access to your data.
Leave the target database empty to enable multi-database mode. In this mode you can query any database your MySQL user can access. Use fully qualified table names when needed and switch databases as required.
Follow these practices to keep your data safe: start with read‑only operations by default, create dedicated MySQL users with restricted permissions, limit access to only the databases you need, back up data before enabling write operations, and keep query logs enabled to monitor activity.
The codebase is organized to separate concerns: configuration management, database connections, request handling, type definitions, and utilities. This structure helps you navigate the server, add features, and maintain security checks.
# Development mode with auto-reload
npm run dev
# Watch mode for building
npm run watch
# Run tests
npm test
# Lint code
npm run lintExecutes validated SQL queries with security checks and schema awareness to prevent unsafe operations.
Automatically discovers available databases, tables, and column metadata to aid query construction.
Manages a pool of database connections for efficient query processing.
Applies SQL validation to prevent injection and unsafe statements before execution.
Provides optional detailed logging to help diagnose issues and monitor activity.