@berthojoris/mcp-mysql-server 1.20.0 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,23 @@ All notable changes to the MySQL MCP Server will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.22.0] - 2025-12-17
9
+
10
+ ### Changed
11
+ - Updated tool count from 150 to 144 to reflect current actual number of available tools
12
+ - Updated documentation timestamps and version references across all documentation files
13
+
14
+ ## [1.21.0] - 2025-12-17
15
+
16
+ ### Added
17
+ - New tool `get_all_tables_relationships` for bulk foreign key relationship analysis across all tables in a single call
18
+ - Enhanced relationship discovery with in-memory processing for improved performance
19
+ - Added comprehensive validation schema for the new bulk relationships tool
20
+
21
+ ### Changed
22
+ - Updated documentation to include the new `get_all_tables_relationships` tool
23
+ - Extended query logging support to cover the new bulk relationships functionality
24
+
8
25
  ## [1.20.0] - 2025-12-17
9
26
 
10
27
  ### Changed
package/DOCUMENTATIONS.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MySQL MCP Server - Detailed Documentation
2
2
 
3
- **Last Updated:** 2025-12-17 00:00:00
3
+ **Last Updated:** 2025-12-17 15:30:00
4
4
 
5
5
  This file contains detailed documentation for all features of the MySQL MCP Server. For quick start and basic information, see [README.md](README.md).
6
6
 
@@ -9,7 +9,7 @@ This file contains detailed documentation for all features of the MySQL MCP Serv
9
9
  ## Table of Contents
10
10
 
11
11
  1. [Setup & Configuration (Extended)](#setup--configuration-extended) - Permissions + Categories
12
- 2. [🔧 Complete Tools Reference](#🔧-complete-tools-reference) - All 150 tools organized by category
12
+ 2. [🔧 Complete Tools Reference](#🔧-complete-tools-reference) - All 144 tools organized by category
13
13
  3. [DDL Operations](#🏗️-ddl-operations)
14
14
  4. [Data Export Tools](#📤-data-export-tools)
15
15
  5. [Data Import Tools](#📥-data-import-tools)
@@ -201,7 +201,7 @@ Add 'bulk_operations' to the categories argument.
201
201
 
202
202
  ## 🔧 Complete Tools Reference
203
203
 
204
- This section provides a comprehensive reference of all 150 available tools organized by category.
204
+ This section provides a comprehensive reference of all 144 available tools organized by category.
205
205
 
206
206
  ### Database Discovery
207
207
 
@@ -211,6 +211,7 @@ This section provides a comprehensive reference of all 150 available tools organ
211
211
  | `list_tables` | Lists all tables in the current/specified database |
212
212
  | `read_table_schema` | Gets detailed schema (columns, types, keys, indexes) |
213
213
  | `get_table_relationships` | Discovers foreign key relationships |
214
+ | `get_all_tables_relationships` | Gets foreign key relationships for ALL tables in a single call with in-memory processing |
214
215
 
215
216
  ### Data Operations - CRUD
216
217
 
@@ -3657,7 +3658,7 @@ Parameters:
3657
3658
 
3658
3659
  Query logs are now included in responses from **ALL 30 tools**:
3659
3660
 
3660
- ✅ **Database Discovery** - `list_databases`, `list_tables`, `read_table_schema`, `get_table_relationships`
3661
+ ✅ **Database Discovery** - `list_databases`, `list_tables`, `read_table_schema`, `get_table_relationships`, `get_all_tables_relationships`
3661
3662
  ✅ **Data Operations** - `create_record`, `read_records`, `update_record`, `delete_record`
3662
3663
  ✅ **Bulk Operations** - `bulk_insert`, `bulk_update`, `bulk_delete`
3663
3664
  ✅ **Custom Queries** - `run_query`, `execute_sql`
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  **A production-ready Model Context Protocol (MCP) server for MySQL database integration with AI agents**
6
6
 
7
- **Last Updated:** 2025-12-17 00:00:00
7
+ **Last Updated:** 2025-12-17 15:30:00
8
8
 
9
9
  [![npm version](https://img.shields.io/npm/v/@berthojoris/mcp-mysql-server)](https://www.npmjs.com/package/@berthojoris/mysql-mcp)
10
10
  [![npm downloads](https://img.shields.io/npm/dm/@berthojoris/mysql-mcp)](https://www.npmjs.com/package/@berthojoris/mysql-mcp)
@@ -300,7 +300,7 @@ Common configuration examples are documented in **[DOCUMENTATIONS.md → Categor
300
300
 
301
301
  ## Available Tools
302
302
 
303
- The server exposes **150 tools** organized into categories (CRUD, schema, backups, migrations, perf/monitoring, and AI enhancement).
303
+ The server exposes **144 tools** organized into categories (CRUD, schema, backups, migrations, perf/monitoring, and AI enhancement).
304
304
 
305
305
  - Complete list of tools: **[DOCUMENTATIONS.md → Complete Tools Reference](DOCUMENTATIONS.md#🔧-complete-tools-reference)**
306
306
  - AI enhancement tools overview: **[DOCUMENTATIONS.md → AI Enhancement Tools](DOCUMENTATIONS.md#🤖-ai-enhancement-tools)**
@@ -89,6 +89,7 @@ exports.toolCategoryMap = {
89
89
  describeConnection: ToolCategory.UTILITY,
90
90
  testConnection: ToolCategory.UTILITY,
91
91
  getTableRelationships: ToolCategory.UTILITY,
92
+ getAllTablesRelationships: ToolCategory.UTILITY,
92
93
  exportTableToCSV: ToolCategory.UTILITY,
93
94
  exportQueryToCSV: ToolCategory.UTILITY,
94
95
  safe_export_table: ToolCategory.UTILITY,
@@ -225,6 +226,7 @@ exports.toolDocCategoryMap = {
225
226
  listTables: DocCategory.DATABASE_DISCOVERY,
226
227
  readTableSchema: DocCategory.DATABASE_DISCOVERY,
227
228
  getTableRelationships: DocCategory.DATABASE_DISCOVERY,
229
+ getAllTablesRelationships: DocCategory.DATABASE_DISCOVERY,
228
230
  // CRUD Operations
229
231
  createRecord: DocCategory.CRUD_OPERATIONS,
230
232
  readRecords: DocCategory.CRUD_OPERATIONS,
package/dist/index.d.ts CHANGED
@@ -200,6 +200,13 @@ export declare class MySQLMCP {
200
200
  data?: any;
201
201
  error?: string;
202
202
  }>;
203
+ getAllTablesRelationships(params?: {
204
+ database?: string;
205
+ }): Promise<{
206
+ status: string;
207
+ data?: any;
208
+ error?: string;
209
+ }>;
203
210
  readChangelog(params?: {
204
211
  version?: string;
205
212
  limit?: number;
package/dist/index.js CHANGED
@@ -254,6 +254,13 @@ class MySQLMCP {
254
254
  }
255
255
  return await this.utilityTools.getTableRelationships(params);
256
256
  }
257
+ async getAllTablesRelationships(params) {
258
+ const check = this.checkToolEnabled("getAllTablesRelationships");
259
+ if (!check.enabled) {
260
+ return { status: "error", error: check.error };
261
+ }
262
+ return await this.utilityTools.getAllTablesRelationships(params);
263
+ }
257
264
  async readChangelog(params) {
258
265
  const check = this.checkToolEnabled("read_changelog");
259
266
  if (!check.enabled) {
@@ -697,6 +697,19 @@ const TOOLS = [
697
697
  required: ["table_name"],
698
698
  },
699
699
  },
700
+ {
701
+ name: "get_all_tables_relationships",
702
+ description: "Gets foreign key relationships for ALL tables in a single call. Processes relationships in memory to avoid multiple queries.",
703
+ inputSchema: {
704
+ type: "object",
705
+ properties: {
706
+ database: {
707
+ type: "string",
708
+ description: "Optional: specific database name",
709
+ },
710
+ },
711
+ },
712
+ },
700
713
  // Transaction Tools
701
714
  {
702
715
  name: "begin_transaction",
@@ -3417,6 +3430,9 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
3417
3430
  case "get_table_relationships":
3418
3431
  result = await mysqlMCP.getTableRelationships((args || {}));
3419
3432
  break;
3433
+ case "get_all_tables_relationships":
3434
+ result = await mysqlMCP.getAllTablesRelationships((args || {}));
3435
+ break;
3420
3436
  // Transaction Tools
3421
3437
  case "begin_transaction":
3422
3438
  result = await mysqlMCP.beginTransaction((args || {}));
@@ -27,6 +27,17 @@ export declare class UtilityTools {
27
27
  data?: any;
28
28
  error?: string;
29
29
  }>;
30
+ /**
31
+ * Gets foreign key relationships for ALL tables in a single call
32
+ * Processes relationships in memory to avoid multiple queries
33
+ */
34
+ getAllTablesRelationships(params?: {
35
+ database?: string;
36
+ }): Promise<{
37
+ status: string;
38
+ data?: any;
39
+ error?: string;
40
+ }>;
30
41
  /**
31
42
  * Reads the CHANGELOG.md file from the project root
32
43
  */
@@ -210,6 +210,88 @@ class UtilityTools {
210
210
  };
211
211
  }
212
212
  }
213
+ /**
214
+ * Gets foreign key relationships for ALL tables in a single call
215
+ * Processes relationships in memory to avoid multiple queries
216
+ */
217
+ async getAllTablesRelationships(params) {
218
+ try {
219
+ const databaseName = params?.database || this.db.pool.pool.config.connectionConfig.database;
220
+ // Get all tables in the database
221
+ const tablesQuery = `
222
+ SELECT TABLE_NAME as table_name
223
+ FROM INFORMATION_SCHEMA.TABLES
224
+ WHERE TABLE_SCHEMA = ?
225
+ AND TABLE_TYPE = 'BASE TABLE'
226
+ ORDER BY TABLE_NAME
227
+ `;
228
+ const tablesResult = await this.db.query(tablesQuery, [databaseName]);
229
+ const tableNames = tablesResult.map(row => row.table_name);
230
+ // Get ALL foreign key relationships in a single query
231
+ const relationshipsQuery = `
232
+ SELECT
233
+ TABLE_NAME as child_table,
234
+ COLUMN_NAME as child_column,
235
+ REFERENCED_TABLE_NAME as parent_table,
236
+ REFERENCED_COLUMN_NAME as parent_column,
237
+ CONSTRAINT_NAME as constraint_name
238
+ FROM
239
+ INFORMATION_SCHEMA.KEY_COLUMN_USAGE
240
+ WHERE
241
+ TABLE_SCHEMA = ?
242
+ AND REFERENCED_TABLE_NAME IS NOT NULL
243
+ ORDER BY
244
+ REFERENCED_TABLE_NAME, TABLE_NAME
245
+ `;
246
+ const allRelationships = await this.db.query(relationshipsQuery, [databaseName]);
247
+ // Initialize result object with all tables having empty relationships
248
+ const result = {};
249
+ tableNames.forEach(tableName => {
250
+ result[tableName] = {
251
+ as_parent: [],
252
+ as_child: []
253
+ };
254
+ });
255
+ // Process relationships in memory
256
+ allRelationships.forEach(relationship => {
257
+ const { child_table, parent_table } = relationship;
258
+ // Add to parent table's "as_parent" array
259
+ if (result[parent_table]) {
260
+ result[parent_table].as_parent.push({
261
+ child_table: relationship.child_table,
262
+ child_column: relationship.child_column,
263
+ parent_table: relationship.parent_table,
264
+ parent_column: relationship.parent_column,
265
+ constraint_name: relationship.constraint_name
266
+ });
267
+ }
268
+ // Add to child table's "as_child" array
269
+ if (result[child_table]) {
270
+ result[child_table].as_child.push({
271
+ child_table: relationship.child_table,
272
+ child_column: relationship.child_column,
273
+ parent_table: relationship.parent_table,
274
+ parent_column: relationship.parent_column,
275
+ constraint_name: relationship.constraint_name
276
+ });
277
+ }
278
+ });
279
+ return {
280
+ status: "success",
281
+ data: {
282
+ total_tables: tableNames.length,
283
+ total_relationships: allRelationships.length,
284
+ relationships: result
285
+ }
286
+ };
287
+ }
288
+ catch (error) {
289
+ return {
290
+ status: "error",
291
+ error: error.message,
292
+ };
293
+ }
294
+ }
213
295
  /**
214
296
  * Reads the CHANGELOG.md file from the project root
215
297
  */
@@ -343,6 +343,16 @@ export declare const getTableRelationshipsSchema: {
343
343
  };
344
344
  additionalProperties: boolean;
345
345
  };
346
+ export declare const getAllTablesRelationshipsSchema: {
347
+ type: string;
348
+ required: never[];
349
+ properties: {
350
+ database: {
351
+ type: string;
352
+ };
353
+ };
354
+ additionalProperties: boolean;
355
+ };
346
356
  export declare const beginTransactionSchema: {
347
357
  type: string;
348
358
  properties: {
@@ -677,6 +687,7 @@ export declare const validateStoredProcedureCreation: import("ajv").ValidateFunc
677
687
  export declare const validateGetTableRelationships: import("ajv").ValidateFunction<{
678
688
  [x: string]: {};
679
689
  }>;
690
+ export declare const validateGetAllTablesRelationships: import("ajv").ValidateFunction<unknown>;
680
691
  export declare const validateExportTableToCsv: import("ajv").ValidateFunction<{
681
692
  [x: string]: {};
682
693
  }>;
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateDropStoredProcedure = exports.validateCreateStoredProcedure = exports.validateExecuteStoredProcedure = exports.validateGetStoredProcedureInfo = exports.validateListStoredProcedures = exports.validateExecuteInTransaction = exports.validateRollbackTransaction = exports.validateCommitTransaction = exports.validateBeginTransaction = exports.validateExecuteDdl = exports.validateDropTable = exports.validateAlterTable = exports.validateCreateTable = exports.validateExecuteSql = exports.validateRunQuery = exports.validateBulkDelete = exports.validateBulkUpdate = exports.validateBulkInsert = exports.validateDeleteRecord = exports.validateUpdateRecord = exports.validateReadRecords = exports.validateCreateRecord = exports.validateReadTableSchema = exports.validateListTables = exports.exportQueryToCsvSchema = exports.exportTableToCsvSchema = exports.showCreateProcedureSchema = exports.dropStoredProcedureSchema = exports.createStoredProcedureSchema = exports.executeStoredProcedureSchema = exports.getStoredProcedureInfoSchema = exports.listStoredProceduresSchema = exports.executeInTransactionSchema = exports.getTransactionStatusSchema = exports.rollbackTransactionSchema = exports.commitTransactionSchema = exports.beginTransactionSchema = exports.getTableRelationshipsSchema = exports.executeDdlSchema = exports.dropTableSchema = exports.alterTableSchema = exports.createTableSchema = exports.executeSqlSchema = exports.runQuerySchema = exports.deleteRecordSchema = exports.updateRecordSchema = exports.readRecordsSchema = exports.createRecordSchema = exports.readTableSchemaSchema = exports.listTablesSchema = void 0;
7
- exports.validateExportQueryToCsv = exports.validateExportTableToCsv = exports.validateGetTableRelationships = exports.validateStoredProcedureCreation = exports.validateStoredProcedureExecution = exports.validateShowCreateProcedure = void 0;
6
+ exports.validateCreateStoredProcedure = exports.validateExecuteStoredProcedure = exports.validateGetStoredProcedureInfo = exports.validateListStoredProcedures = exports.validateExecuteInTransaction = exports.validateRollbackTransaction = exports.validateCommitTransaction = exports.validateBeginTransaction = exports.validateExecuteDdl = exports.validateDropTable = exports.validateAlterTable = exports.validateCreateTable = exports.validateExecuteSql = exports.validateRunQuery = exports.validateBulkDelete = exports.validateBulkUpdate = exports.validateBulkInsert = exports.validateDeleteRecord = exports.validateUpdateRecord = exports.validateReadRecords = exports.validateCreateRecord = exports.validateReadTableSchema = exports.validateListTables = exports.exportQueryToCsvSchema = exports.exportTableToCsvSchema = exports.showCreateProcedureSchema = exports.dropStoredProcedureSchema = exports.createStoredProcedureSchema = exports.executeStoredProcedureSchema = exports.getStoredProcedureInfoSchema = exports.listStoredProceduresSchema = exports.executeInTransactionSchema = exports.getTransactionStatusSchema = exports.rollbackTransactionSchema = exports.commitTransactionSchema = exports.beginTransactionSchema = exports.getAllTablesRelationshipsSchema = exports.getTableRelationshipsSchema = exports.executeDdlSchema = exports.dropTableSchema = exports.alterTableSchema = exports.createTableSchema = exports.executeSqlSchema = exports.runQuerySchema = exports.deleteRecordSchema = exports.updateRecordSchema = exports.readRecordsSchema = exports.createRecordSchema = exports.readTableSchemaSchema = exports.listTablesSchema = void 0;
7
+ exports.validateExportQueryToCsv = exports.validateExportTableToCsv = exports.validateGetAllTablesRelationships = exports.validateGetTableRelationships = exports.validateStoredProcedureCreation = exports.validateStoredProcedureExecution = exports.validateShowCreateProcedure = exports.validateDropStoredProcedure = void 0;
8
8
  const ajv_1 = __importDefault(require("ajv"));
9
9
  const ajv = new ajv_1.default();
10
10
  // Schema definitions
@@ -258,6 +258,14 @@ exports.getTableRelationshipsSchema = {
258
258
  },
259
259
  additionalProperties: false
260
260
  };
261
+ exports.getAllTablesRelationshipsSchema = {
262
+ type: 'object',
263
+ required: [],
264
+ properties: {
265
+ database: { type: 'string' }
266
+ },
267
+ additionalProperties: false
268
+ };
261
269
  // Transaction Schemas
262
270
  exports.beginTransactionSchema = {
263
271
  type: 'object',
@@ -529,5 +537,6 @@ exports.validateShowCreateProcedure = ajv.compile(exports.showCreateProcedureSch
529
537
  exports.validateStoredProcedureExecution = ajv.compile(exports.executeStoredProcedureSchema);
530
538
  exports.validateStoredProcedureCreation = ajv.compile(exports.createStoredProcedureSchema);
531
539
  exports.validateGetTableRelationships = ajv.compile(exports.getTableRelationshipsSchema);
540
+ exports.validateGetAllTablesRelationships = ajv.compile(exports.getAllTablesRelationshipsSchema);
532
541
  exports.validateExportTableToCsv = ajv.compile(exports.exportTableToCsvSchema);
533
542
  exports.validateExportQueryToCsv = ajv.compile(exports.exportQueryToCsvSchema);
package/manifest.json CHANGED
@@ -402,6 +402,66 @@
402
402
  }
403
403
  }
404
404
  },
405
+ {
406
+ "name": "get_all_tables_relationships",
407
+ "description": "Gets foreign key relationships for ALL tables in a single call. Processes relationships in memory to avoid multiple queries.",
408
+ "input_schema": {
409
+ "type": "object",
410
+ "properties": {
411
+ "database": {
412
+ "type": "string",
413
+ "description": "Optional: specific database name"
414
+ }
415
+ }
416
+ },
417
+ "output_schema": {
418
+ "type": "object",
419
+ "properties": {
420
+ "total_tables": {
421
+ "type": "number"
422
+ },
423
+ "total_relationships": {
424
+ "type": "number"
425
+ },
426
+ "relationships": {
427
+ "type": "object",
428
+ "patternProperties": {
429
+ ".*": {
430
+ "type": "object",
431
+ "properties": {
432
+ "as_parent": {
433
+ "type": "array",
434
+ "items": {
435
+ "type": "object",
436
+ "properties": {
437
+ "child_table": { "type": "string" },
438
+ "child_column": { "type": "string" },
439
+ "parent_table": { "type": "string" },
440
+ "parent_column": { "type": "string" },
441
+ "constraint_name": { "type": "string" }
442
+ }
443
+ }
444
+ },
445
+ "as_child": {
446
+ "type": "array",
447
+ "items": {
448
+ "type": "object",
449
+ "properties": {
450
+ "child_table": { "type": "string" },
451
+ "child_column": { "type": "string" },
452
+ "parent_table": { "type": "string" },
453
+ "parent_column": { "type": "string" },
454
+ "constraint_name": { "type": "string" }
455
+ }
456
+ }
457
+ }
458
+ }
459
+ }
460
+ }
461
+ }
462
+ }
463
+ }
464
+ },
405
465
  {
406
466
  "name": "get_schema_rag_context",
407
467
  "description": "Returns a condensed schema-aware context pack with tables, PK/FK details, and row estimates for RAG prompts.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@berthojoris/mcp-mysql-server",
3
- "version": "1.20.0",
3
+ "version": "1.22.0",
4
4
  "description": "Model Context Protocol server for MySQL database integration with dynamic per-project permissions, backup/restore, data import/export, and data migration capabilities",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",