You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Model Context Protocol server that provides access to MySQL databases. This server enables LLMs to inspect database schemas and execute SQL queries.
11
6
@@ -14,6 +9,7 @@ A Model Context Protocol server that provides access to MySQL databases. This se
14
9
-[Installation](#installation)
15
10
-[Smithery](#using-smithery)
16
11
-[Clone to Local Repository](#running-from-local-repository)
12
+
-[Remote mode](#run-in-remote-mode)
17
13
-[Components](#components)
18
14
-[Configuration](#configuration)
19
15
-[Environment Variables](#environment-variables)
@@ -26,7 +22,7 @@ A Model Context Protocol server that provides access to MySQL databases. This se
26
22
27
23
## Requirements
28
24
29
-
- Node.js v18 or higher
25
+
- Node.js v20 or higher
30
26
- MySQL 5.7 or higher (MySQL 8.0+ recommended)
31
27
- MySQL user with appropriate permissions for the operations you need
32
28
- For write operations: MySQL user with INSERT, UPDATE, and/or DELETE privileges
@@ -199,11 +195,11 @@ claude mcp add mcp_server_mysql \
199
195
```bash
200
196
# Find your Node.js path
201
197
which node
202
-
198
+
203
199
# For PATH environment variable
204
200
echo"$(which node)/../"
205
-
206
-
# For NODE_PATH environment variable
201
+
202
+
# For NODE_PATH environment variable
207
203
echo"$(which node)/../../lib/node_modules"
208
204
```
209
205
@@ -295,6 +291,43 @@ If you want to clone and run this MCP server directly from the source code, foll
295
291
296
292
If it connects to MySQL successfully, you're ready to use it with Claude Desktop.
297
293
294
+
### Run in remote mode
295
+
296
+
To run in remote mode, you'll need to provide [environment variables](https://github.com/benborla/mcp-server-mysql?tab=readme-ov-file#environment-variables) to the npx script.
297
+
1. Create env file in preferred directory
298
+
```bash
299
+
# create .env file
300
+
touch .env
301
+
```
302
+
2. Copy-paste [example file](https://github.com/benborla/mcp-server-mysql/blob/main/.env) from this repository
303
+
3. Set the MySQL credentials to match your environment
304
+
4. Set `IS_REMOTE_MCP=true`
305
+
5. Set `REMOTE_SECRET_KEY` to a secure string.
306
+
6. Provide custom `PORT` if needed. Default is 3000.
307
+
7. Load variables in current session:
308
+
```bash
309
+
source .env
310
+
```
311
+
8. Run the server
312
+
```bash
313
+
npx @benborla29/mcp-server-mysql
314
+
```
315
+
9. Configure your agent to connect to the MCP with the next configuration:
316
+
```json
317
+
{
318
+
"mcpServers": {
319
+
"mysql": {
320
+
"url": "http://your-host:3000/mcp",
321
+
"type": "streamableHttp",
322
+
"headers": {
323
+
"Authorization": "Bearer <REMOTE_SECRET_KEY>"
324
+
}
325
+
}
326
+
}
327
+
}
328
+
```
329
+
330
+
298
331
## Components
299
332
300
333
### Tools
@@ -391,22 +424,22 @@ For more control over the MCP server's behavior, you can use these advanced conf
391
424
"MYSQL_PASS": "",
392
425
"MYSQL_DB": "db_name",
393
426
"PATH": "/path/to/node/bin:/usr/bin:/bin",
394
-
427
+
395
428
// Performance settings
396
429
"MYSQL_POOL_SIZE": "10",
397
430
"MYSQL_QUERY_TIMEOUT": "30000",
398
431
"MYSQL_CACHE_TTL": "60000",
399
-
432
+
400
433
// Security settings
401
434
"MYSQL_RATE_LIMIT": "100",
402
435
"MYSQL_MAX_QUERY_COMPLEXITY": "1000",
403
436
"MYSQL_SSL": "true",
404
-
437
+
405
438
// Monitoring settings
406
439
"ENABLE_LOGGING": "true",
407
440
"MYSQL_LOG_LEVEL": "info",
408
441
"MYSQL_METRICS_ENABLED": "true",
409
-
442
+
410
443
// Write operation flags
411
444
"ALLOW_INSERT_OPERATION": "false",
412
445
"ALLOW_UPDATE_OPERATION": "false",
@@ -451,6 +484,11 @@ For more control over the MCP server's behavior, you can use these advanced conf
-`REMOTE_SECRET_KEY`: Secret key for remote MCP authentication (default: ""). If not provided, remote MCP mode will be disabled.
490
+
-`PORT`: Port number for the remote MCP server (default: 3000)
491
+
454
492
## Multi-DB Mode
455
493
456
494
MCP-Server-MySQL supports connecting to multiple databases when no specific database is set. This allows the LLM to query any database the MySQL user has access to. For full details, see [README-MULTI-DB.md](./README-MULTI-DB.md).
@@ -493,7 +531,7 @@ Before running tests, you need to set up the test database and seed it with test
493
531
```sql
494
532
-- Connect as root and create test database
495
533
CREATEDATABASEIF NOT EXISTS mcp_test;
496
-
534
+
497
535
-- Create test user with appropriate permissions
498
536
CREATEUSERIF NOT EXISTS 'mcp_test'@'localhost' IDENTIFIED BY 'mcp_test_password';
499
537
GRANT ALL PRIVILEGES ON mcp_test.* TO 'mcp_test'@'localhost';
@@ -591,12 +629,12 @@ Run the following command to get it:
591
629
592
630
For **PATH**
593
631
```bash
594
-
echo"$(which node)/../"
632
+
echo"$(which node)/../"
595
633
```
596
634
597
635
For **NODE_PATH**
598
636
```bash
599
-
echo"$(which node)/../../lib/node_modules"
637
+
echo"$(which node)/../../lib/node_modules"
600
638
```
601
639
602
640
5.**Claude Desktop Specific Issues**
@@ -652,7 +690,7 @@ Thanks to @lizhuangs
652
690
653
691
## Contributing
654
692
655
-
Contributions are welcome! Please feel free to submit a Pull Request to
693
+
Contributions are welcome! Please feel free to submit a Pull Request to
0 commit comments