
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@naganpm/mysql-mcp-server
Advanced tools
step1: Configure this in .claude.json globally.
"mcpServers": {
"mysql-mcp": {
"command": "npx",
"args": [
"-y",
"@naganpm/mysql-mcp-server"
]
}
}
step2: Add mysql-config.json under config folder - under the directory you are working on.
sample
mysql-config.json(You can change this config to any host and credentials and restart claude){ "host": "localhost", "port": 3306, "user": "johndoe", "password": "j8dka72047", "database": "master" }
A Model Context Protocol (MCP) server for accessing local MySQL databases. This server provides read and write capabilities for MySQL databases through standardized MCP tools.
For package consumers:
npm install @naganpm/mysql-mcp-server
For development:
npm install
Create a config directory in your project root and add a mysql-config.json file:
mkdir -p config
Create config/mysql-config.json with your MySQL connection details:
{
"host": "localhost",
"port": 3306,
"user": "your_username",
"password": "your_password",
"database": "your_database",
"connectionLimit": 10,
"acquireTimeout": 60000,
"timeout": 60000
}
If you have access to the package source, you can run the interactive configuration wizard:
npm run setup
The setup wizard will prompt you for:
The configuration will be saved to config/mysql-config.json in your project root directory.
As an alternative to the interactive setup, you can configure the server using environment variables. This is especially useful for MCP integrations where file-based configuration may cause startup delays.
| Variable | Alternative | Default | Description |
|---|---|---|---|
MYSQL_HOST | DB_HOST | localhost | MySQL server hostname |
MYSQL_PORT | DB_PORT | 3306 | MySQL server port |
MYSQL_USER | DB_USER | root | MySQL username |
MYSQL_PASSWORD | DB_PASSWORD | "" | MySQL password |
MYSQL_DATABASE | DB_DATABASE, MYSQL_DB, DB_NAME | "" | Database name |
MYSQL_CONNECTION_LIMIT | - | 10 | Maximum number of connections in pool |
MYSQL_ACQUIRE_TIMEOUT | - | 60000 | Connection acquire timeout (ms) |
MYSQL_TIMEOUT | - | 60000 | Query timeout (ms) |
The server loads configuration in this order:
config/mysql-config.json in your project root) as fallbackIf any MySQL environment variable is set, the server will use environment-based configuration exclusively.
npm start
Or for development with auto-restart:
npm run dev
mysql_queryExecute SELECT queries to read data from the database.
Parameters:
query (string, required): The SQL SELECT queryparams (array, optional): Parameters for prepared statementsExample:
SELECT * FROM users WHERE age > ?
Parameters: ["25"]
mysql_insertExecute INSERT statements to add new data.
Parameters:
query (string, required): The SQL INSERT statementparams (array, optional): Parameters for prepared statementsExample:
INSERT INTO users (name, email, age) VALUES (?, ?, ?)
Parameters: ["John Doe", "john@example.com", "30"]
mysql_updateExecute UPDATE statements to modify existing data.
Parameters:
query (string, required): The SQL UPDATE statementparams (array, optional): Parameters for prepared statementsExample:
UPDATE users SET email = ? WHERE id = ?
Parameters: ["newemail@example.com", "1"]
mysql_deleteExecute DELETE statements to remove data.
Parameters:
query (string, required): The SQL DELETE statementparams (array, optional): Parameters for prepared statementsExample:
DELETE FROM users WHERE id = ?
Parameters: ["1"]
mysql_show_tablesList all tables in the current database.
Parameters: None
mysql_describe_tableShow the structure of a specific table.
Parameters:
table_name (string, required): Name of the table to describemysql_show_databasesList all available databases.
Parameters: None
mysql_test_connectionTest the database connection status.
Parameters: None
The configuration is stored in config/mysql-config.json in your project root directory with the following structure:
{
"host": "localhost",
"port": 3306,
"user": "your_username",
"password": "your_password",
"database": "your_database",
"connectionLimit": 10,
"acquireTimeout": 60000,
"timeout": 60000
}
"No database configuration found"
config/mysql-config.json file in your project root directory with your MySQL connection details"Failed to connect to MySQL"
"Database does not exist"
Ensure your MySQL user has the following permissions:
SELECT for read operationsINSERT for adding dataUPDATE for modifying dataDELETE for removing dataSHOW DATABASES for listing databasesSHOW TABLES for listing tablesGrant permissions example:
GRANT SELECT, INSERT, UPDATE, DELETE ON your_database.* TO 'your_user'@'localhost';
FLUSH PRIVILEGES;
The server is built using:
mysql-mcp/
├── src/
│ ├── index.js # Main MCP server implementation
│ ├── database.js # Database connection and query management
│ ├── config.js # Configuration management
│ └── setup.js # Interactive setup wizard
├── package.json
├── config/
│ └── mysql-config.json # Generated after setup (in consumer's project)
└── README.md
mysql-config.json only for database configurationsConfigure the server using environment variables in your Claude settings. This method is faster and avoids potential timeout issues during MCP initialization.
.claude/settings.json or project configuration:
{
"mcpServers": {
"mysql-local-mcp-server": {
"command": "npx",
"args": ["@naganpm/mysql-mcp-server"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "",
"MYSQL_DATABASE": "your_database_name"
}
}
}
}
Benefits of environment variable configuration:
If you prefer file-based configuration, first run the setup wizard, then configure Claude to use the server:
Setup the configuration:
npm run setup
Claude configuration:
{
"mcpServers": {
"mysql-local-mcp-server": {
"command": "node",
"args": ["/path/to/your/mysql-mcp/src/stdio-server.js"]
}
}
}
Note: Replace /path/to/your/mysql-mcp/ with the actual path to your project directory.
Here's a complete example of setting up the MySQL MCP server in your project:
Install the package:
npm install @naganpm/mysql-mcp-server
Create your configuration:
mkdir -p config
cat > config/mysql-config.json << EOF
{
"host": "localhost",
"port": 3306,
"user": "root",
"password": "your_password",
"database": "your_database"
}
EOF
Use in your MCP configuration:
{
"mcpServers": {
"mysql-local": {
"command": "npx",
"args": ["@naganpm/mysql-mcp-server"]
}
}
}
The server will automatically detect and use the config/mysql-config.json file from your project root.
MIT License
FAQs
MCP server for local MySQL database access
We found that @naganpm/mysql-mcp-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.