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
Copy file name to clipboardExpand all lines: README.md
+58-52Lines changed: 58 additions & 52 deletions
Original file line number
Diff line number
Diff line change
@@ -241,40 +241,46 @@ The server includes AI-optimized database tools that provide rich context and ca
241
241
DB MCP Server supports connecting to multiple databases simultaneously, allowing AI agents to work across different database systems in a unified way. Each database connection is identified by a unique ID that can be referenced when using database tools.
242
242
243
243
#### Configuring Multiple Databases
244
-
245
-
Configure multiple database connections in your `.env` file or environment variables:
244
+
In your .env file
245
+
```
246
+
# Multi-Database Configuration
247
+
DB_CONFIG_FILE=config/databases.json
248
+
```
249
+
Configure multiple database connections in your `db-mcp-server/config/databases.json` file or environment variables:
246
250
247
251
```
248
252
# Multiple Database Configuration
249
-
DB_CONNECTIONS=[
250
-
{
251
-
"id": "mysql1",
252
-
"type": "mysql",
253
-
"host": "localhost",
254
-
"port": 3306,
255
-
"user": "user1",
256
-
"password": "password1",
257
-
"database": "db1"
258
-
},
259
-
{
260
-
"id": "postgres1",
261
-
"type": "postgres",
262
-
"host": "localhost",
263
-
"port": 5432,
264
-
"user": "user2",
265
-
"password": "password2",
266
-
"database": "db2"
267
-
},
268
-
{
269
-
"id": "mysql2",
270
-
"type": "mysql",
271
-
"host": "localhost",
272
-
"port": 3307,
273
-
"user": "user3",
274
-
"password": "password3",
275
-
"database": "db3"
276
-
}
277
-
]
253
+
{
254
+
"connections": [
255
+
{
256
+
"id": "mysql1",
257
+
"type": "mysql",
258
+
"host": "localhost",
259
+
"port": 13306,
260
+
"user": "user1",
261
+
"password": "password1",
262
+
"name": "db1"
263
+
},
264
+
{
265
+
"id": "mysql2",
266
+
"type": "mysql",
267
+
"host": "localhost",
268
+
"port": 13307,
269
+
"user": "user3",
270
+
"password": "password3",
271
+
"name": "db3"
272
+
},
273
+
{
274
+
"id": "postgres1",
275
+
"type": "postgres",
276
+
"host": "localhost",
277
+
"port": 15432,
278
+
"user": "user2",
279
+
"password": "password2",
280
+
"name": "db2"
281
+
}
282
+
]
283
+
}
278
284
```
279
285
280
286
#### Viewing Connected Databases
@@ -315,14 +321,14 @@ Example response:
315
321
316
322
#### Specifying Database for Operations
317
323
318
-
When using database tools, you must specify which database to use with the `databaseId` parameter (not `database`):
324
+
When using database tools, you must specify which database to use with the `database` parameter:
319
325
320
326
```json
321
327
// Query a specific database by ID
322
328
{
323
329
"name": "dbQuery",
324
330
"arguments": {
325
-
"databaseId": "postgres1",
331
+
"database": "postgres1",
326
332
"query": "SELECT * FROM users LIMIT 10"
327
333
}
328
334
}
@@ -331,7 +337,7 @@ When using database tools, you must specify which database to use with the `data
331
337
{
332
338
"name": "dbExecute",
333
339
"arguments": {
334
-
"databaseId": "mysql2",
340
+
"database": "mysql2",
335
341
"statement": "UPDATE products SET stock = stock - 1 WHERE id = 5"
336
342
}
337
343
}
@@ -340,13 +346,13 @@ When using database tools, you must specify which database to use with the `data
340
346
{
341
347
"name": "dbSchema",
342
348
"arguments": {
343
-
"databaseId": "mysql1",
349
+
"database": "mysql1",
344
350
"component": "tables"
345
351
}
346
352
}
347
353
```
348
354
349
-
> **⚠️ IMPORTANT**: Always use `databaseId` (not `database`) as the parameter name when specifying which database to use. This is required for all database operation tools.
355
+
> **Note**: Always use `database` as the parameter name when specifying which database to use. This is required for all database operation tools.
350
356
351
357
If your configuration has only one database connection, you must still provide the database ID that matches the ID in your configuration.
352
358
@@ -359,7 +365,7 @@ The MCP Server includes an AI-aware Database Schema Explorer tool (`dbSchema`) t
359
365
{
360
366
"name": "dbSchema",
361
367
"arguments": {
362
-
"databaseId": "mysql1",
368
+
"database": "mysql1",
363
369
"component": "tables"
364
370
}
365
371
}
@@ -368,7 +374,7 @@ The MCP Server includes an AI-aware Database Schema Explorer tool (`dbSchema`) t
368
374
{
369
375
"name": "dbSchema",
370
376
"arguments": {
371
-
"databaseId": "postgres1",
377
+
"database": "postgres1",
372
378
"component": "columns",
373
379
"table": "users"
374
380
}
@@ -378,7 +384,7 @@ The MCP Server includes an AI-aware Database Schema Explorer tool (`dbSchema`) t
378
384
{
379
385
"name": "dbSchema",
380
386
"arguments": {
381
-
"databaseId": "mysql1",
387
+
"database": "mysql1",
382
388
"component": "relationships",
383
389
"table": "orders"
384
390
}
@@ -388,7 +394,7 @@ The MCP Server includes an AI-aware Database Schema Explorer tool (`dbSchema`) t
388
394
{
389
395
"name": "dbSchema",
390
396
"arguments": {
391
-
"databaseId": "postgres1",
397
+
"database": "postgres1",
392
398
"component": "full"
393
399
}
394
400
}
@@ -405,7 +411,7 @@ The MCP Server includes a powerful Visual Query Builder tool (`dbQueryBuilder`)
405
411
{
406
412
"name": "dbQueryBuilder",
407
413
"arguments": {
408
-
"databaseId": "mysql1",
414
+
"database": "mysql1",
409
415
"action": "validate",
410
416
"query": "SELECT * FROM users WHERE status = 'active'"
411
417
}
@@ -415,7 +421,7 @@ The MCP Server includes a powerful Visual Query Builder tool (`dbQueryBuilder`)
415
421
{
416
422
"name": "dbQueryBuilder",
417
423
"arguments": {
418
-
"databaseId": "postgres1",
424
+
"database": "postgres1",
419
425
"action": "build",
420
426
"components": {
421
427
"select": ["id", "name", "email"],
@@ -442,7 +448,7 @@ The MCP Server includes a powerful Visual Query Builder tool (`dbQueryBuilder`)
442
448
{
443
449
"name": "dbQueryBuilder",
444
450
"arguments": {
445
-
"databaseId": "mysql1",
451
+
"database": "mysql1",
446
452
"action": "analyze",
447
453
"query": "SELECT u.*, o.* FROM users u JOIN orders o ON u.id = o.user_id WHERE u.status = 'active' AND o.created_at > '2023-01-01'"
448
454
}
@@ -494,7 +500,7 @@ The MCP Server includes a powerful Performance Analyzer tool (`dbPerformanceAnal
494
500
{
495
501
"name": "dbPerformanceAnalyzer",
496
502
"arguments": {
497
-
"databaseId": "mysql1",
503
+
"database": "mysql1",
498
504
"action": "getSlowQueries",
499
505
"limit": 5
500
506
}
@@ -504,7 +510,7 @@ The MCP Server includes a powerful Performance Analyzer tool (`dbPerformanceAnal
504
510
{
505
511
"name": "dbPerformanceAnalyzer",
506
512
"arguments": {
507
-
"databaseId": "postgres1",
513
+
"database": "postgres1",
508
514
"action": "getMetrics",
509
515
"limit": 10
510
516
}
@@ -514,7 +520,7 @@ The MCP Server includes a powerful Performance Analyzer tool (`dbPerformanceAnal
514
520
{
515
521
"name": "dbPerformanceAnalyzer",
516
522
"arguments": {
517
-
"databaseId": "mysql1",
523
+
"database": "mysql1",
518
524
"action": "analyzeQuery",
519
525
"query": "SELECT * FROM orders JOIN users ON orders.user_id = users.id WHERE orders.status = 'pending'"
520
526
}
@@ -524,7 +530,7 @@ The MCP Server includes a powerful Performance Analyzer tool (`dbPerformanceAnal
524
530
{
525
531
"name": "dbPerformanceAnalyzer",
526
532
"arguments": {
527
-
"databaseId": "postgres1",
533
+
"database": "postgres1",
528
534
"action": "reset"
529
535
}
530
536
}
@@ -533,7 +539,7 @@ The MCP Server includes a powerful Performance Analyzer tool (`dbPerformanceAnal
533
539
{
534
540
"name": "dbPerformanceAnalyzer",
535
541
"arguments": {
536
-
"databaseId": "mysql1",
542
+
"database": "mysql1",
537
543
"action": "setThreshold",
538
544
"threshold": 300
539
545
}
@@ -599,7 +605,7 @@ For operations that require transaction support, use the `dbTransaction` tool:
599
605
{
600
606
"name": "dbTransaction",
601
607
"arguments": {
602
-
"databaseId": "mysql1",
608
+
"database": "mysql1",
603
609
"action": "begin",
604
610
"readOnly": false
605
611
}
@@ -609,7 +615,7 @@ For operations that require transaction support, use the `dbTransaction` tool:
609
615
{
610
616
"name": "dbTransaction",
611
617
"arguments": {
612
-
"databaseId": "mysql1",
618
+
"database": "mysql1",
613
619
"action": "execute",
614
620
"transactionId": "tx-1684785421293", // ID returned from the begin operation
615
621
"statement": "INSERT INTO orders (customer_id, amount) VALUES (?, ?)",
@@ -621,7 +627,7 @@ For operations that require transaction support, use the `dbTransaction` tool:
621
627
{
622
628
"name": "dbTransaction",
623
629
"arguments": {
624
-
"databaseId": "mysql1",
630
+
"database": "mysql1",
625
631
"action": "commit",
626
632
"transactionId": "tx-1684785421293"
627
633
}
@@ -631,7 +637,7 @@ For operations that require transaction support, use the `dbTransaction` tool:
0 commit comments