@berthojoris/mcp-mysql-server 1.26.4 → 1.28.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,45 @@ 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.28.0] - 2025-12-21
9
+
10
+ ### Changed
11
+ - **[BREAKING]** Removed `get_table_relationships` tool - use `get_all_tables_relationships` instead for better performance
12
+ - `get_all_tables_relationships` retrieves ALL table relationships in a single efficient query with in-memory processing
13
+ - Much faster than calling `get_table_relationships` repeatedly for each table
14
+ - **Enhanced tool descriptions** for improved LLM understanding across 40+ critical tools:
15
+ - Added visual indicators (emojis) for tool categories: 🤖 AI-powered, ⚡ Performance, 🔒 Security, 📊 Analytics, etc.
16
+ - Clarified when to use each tool vs similar alternatives
17
+ - Added use-case context and examples in descriptions
18
+ - Highlighted AI-first tools for natural language operations
19
+ - Improved consistency in description length and detail level
20
+ - Updated total tool count from 104 to 103 across all documentation
21
+
22
+ ### Fixed
23
+ - Removed duplicate `get_all_tables_relationships` entry in DOCUMENTATIONS.md
24
+ - Corrected references to deprecated `get_table_relationships` in documentation examples
25
+
26
+ ## [1.27.1] - 2025-12-21
27
+
28
+ ### Removed
29
+ - **Deprecated Tools**: Removed legacy `runQuery` and `executeSql` tools completely
30
+ - These tools were replaced by `run_select_query` and `execute_write_query` in v1.27.0
31
+ - Removed from feature configuration mappings
32
+ - Removed validation schemas
33
+ - Updated all internal references to use new tool names
34
+
35
+ ### Changed
36
+ - Updated transaction tools to use `executeWriteQuery` permission check instead of deprecated `executeSql`
37
+
38
+ ## [1.27.0] - 2025-12-21
39
+
40
+ ### Changed
41
+ - **Renamed Tools for Clarity**:
42
+ - `run_query` -> `run_select_query`
43
+ - `execute_sql` -> `execute_write_query`
44
+ - **Updated Error Messages**: Error messages now explicitly reference the new tool names to guide users/LLMs to the correct tool for the job.
45
+ - **Updated Documentation**: Updated README.md and DOCUMENTATIONS.md to reflect the new tool names and configuration examples.
46
+
8
47
  ## [1.26.2] - 2025-12-19
9
48
 
10
49
  ### Fixed
package/DOCUMENTATIONS.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MySQL MCP Server - Detailed Documentation
2
2
 
3
- **Last Updated:** 2025-12-19 18:45:00
3
+ **Last Updated:** 2025-12-21 17:00: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 145 tools organized by category
12
+ 2. [🔧 Complete Tools Reference](#🔧-complete-tools-reference) - All 103 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)
@@ -131,7 +131,7 @@ Use both 2nd argument (permissions) and 3rd argument (categories):
131
131
  **Layer 1 (Permissions)**: Allows `list`, `read`, `utility` operations
132
132
  **Layer 2 (Categories)**: Further restricts to `database_discovery` and `performance_monitoring` tools
133
133
 
134
- **Enabled tools**: `list_databases`, `list_tables`, `read_table_schema`, `get_table_relationships`, `get_performance_metrics`, `get_slow_queries`, etc.
134
+ **Enabled tools**: `list_databases`, `list_tables`, `read_table_schema`, `get_all_tables_relationships`, `get_performance_metrics`, `get_slow_queries`, etc.
135
135
 
136
136
  **Disabled tools**:
137
137
  - `read_records` - Has `read` permission but category is `crud_operations` (not allowed)
@@ -144,11 +144,11 @@ Use both 2nd argument (permissions) and 3rd argument (categories):
144
144
  | Permission | Operations Allowed | Example Tools |
145
145
  |------------|-------------------|---------------|
146
146
  | `list` | List/discover database objects | `list_databases`, `list_tables`, `list_views` |
147
- | `read` | Read data from tables | `read_records`, `run_query` |
147
+ | `read` | Read data from tables | `read_records`, `run_select_query` |
148
148
  | `create` | Insert new records | `create_record`, `bulk_insert` |
149
149
  | `update` | Update existing records | `update_record`, `bulk_update` |
150
150
  | `delete` | Delete records | `delete_record`, `bulk_delete` |
151
- | `execute` | Execute custom SQL | `execute_sql`, `run_query` |
151
+ | `execute` | Execute custom SQL | `execute_write_query` |
152
152
  | `ddl` | Schema changes | `create_table`, `alter_table`, `drop_table` |
153
153
  | `utility` | Utility operations | `test_connection`, `analyze_table` |
154
154
  | `transaction` | Transaction management | `begin_transaction`, `commit_transaction` |
@@ -210,7 +210,7 @@ This section provides a comprehensive reference of all 145 available tools organ
210
210
  | `list_databases` | Lists all databases on the MySQL server |
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
- | `get_table_relationships` | Discovers foreign key relationships |
213
+ | `get_all_tables_relationships` | Gets all table relationships efficiently in one query |
214
214
  | `get_all_tables_relationships` | Gets foreign key relationships for ALL tables in a single call with in-memory processing |
215
215
 
216
216
  ### Data Operations - CRUD
@@ -234,8 +234,8 @@ This section provides a comprehensive reference of all 145 available tools organ
234
234
 
235
235
  | Tool | Description |
236
236
  |------|-------------|
237
- | `run_query` | Execute read-only SELECT queries |
238
- | `execute_sql` | Execute write operations (INSERT, UPDATE, DELETE, or DDL) |
237
+ | `run_select_query` | Execute read-only SELECT queries |
238
+ | `execute_write_query` | Execute write operations (INSERT, UPDATE, DELETE, or DDL) |
239
239
 
240
240
  ### Schema Management - DDL
241
241
 
@@ -3604,7 +3604,7 @@ Create a business glossary from database column names with auto-generated descri
3604
3604
 
3605
3605
  **User:** *"Show me the total number of orders per user for the last 30 days"*
3606
3606
 
3607
- **AI uses `run_query`:**
3607
+ **AI uses `run_select_query`:**
3608
3608
  - Constructs JOIN query
3609
3609
  - Applies date filter
3610
3610
  - Groups by user
@@ -3891,12 +3891,12 @@ Parameters:
3891
3891
 
3892
3892
  Query logs are now included in responses from **ALL 30 tools**:
3893
3893
 
3894
- ✅ **Database Discovery** - `list_databases`, `list_tables`, `read_table_schema`, `get_table_relationships`, `get_all_tables_relationships`
3894
+ ✅ **Database Discovery** - `list_databases`, `list_tables`, `read_table_schema`, `get_all_tables_relationships`
3895
3895
  ✅ **Data Operations** - `create_record`, `read_records`, `update_record`, `delete_record`
3896
3896
  ✅ **Bulk Operations** - `bulk_insert`, `bulk_update`, `bulk_delete`
3897
- ✅ **Custom Queries** - `run_query`, `execute_sql`
3897
+ ✅ **Custom Queries** - `run_select_query`, `execute_write_query`
3898
3898
  ✅ **Schema Management** - `create_table`, `alter_table`, `drop_table`, `execute_ddl`
3899
- ✅ **Utilities** - `get_table_relationships`
3899
+ ✅ **Utilities** - `get_all_tables_relationships`
3900
3900
  ✅ **Transactions** - `execute_in_transaction`
3901
3901
  ✅ **Stored Procedures** - `list_stored_procedures`, `get_stored_procedure_info`, `execute_stored_procedure`, etc.
3902
3902
  ✅ **Data Export** - `export_table_to_csv`, `export_query_to_csv`
@@ -3920,8 +3920,8 @@ Query logs are valuable for:
3920
3920
  ### Tools with Query Logging
3921
3921
 
3922
3922
  All tools that execute queries include logs:
3923
- - `run_query` - SELECT query execution
3924
- - `executeSql` - Write operations (INSERT, UPDATE, DELETE)
3923
+ - `run_select_query` - SELECT query execution
3924
+ - `execute_write_query` - Write operations (INSERT, UPDATE, DELETE)
3925
3925
  - `create_record` - Single record insertion
3926
3926
  - `read_records` - Record querying with filters
3927
3927
  - `update_record` - Record updates
@@ -4025,7 +4025,7 @@ console.log(`Query log memory usage: ~${estimatedMemory} KB`);
4025
4025
 
4026
4026
  - ✅ **Parameterized Queries** - All queries use prepared statements (SQL injection protection)
4027
4027
  - ✅ **Permission-Based Access** - Fine-grained control over operations
4028
- - ✅ **Read-Only Validation** - `run_query` enforces SELECT-only operations
4028
+ - ✅ **Read-Only Validation** - `run_select_query` enforces SELECT-only operations
4029
4029
  - ✅ **DDL Gating** - Schema changes require explicit `ddl` permission
4030
4030
  - ✅ **Condition Requirements** - DELETE operations must include WHERE conditions
4031
4031
  - ✅ **Input Validation** - All inputs validated with JSON schemas
@@ -4145,7 +4145,7 @@ Returns:
4145
4145
 
4146
4146
  - **SELECT queries only**: Only SELECT queries are cached
4147
4147
  - **Automatic invalidation**: INSERT, UPDATE, DELETE operations automatically invalidate related cache entries
4148
- - **Per-query control**: Use `useCache: false` in `run_query` to bypass cache for specific queries
4148
+ - **Per-query control**: Use `useCache: false` in `run_select_query` to bypass cache for specific queries
4149
4149
 
4150
4150
  ---
4151
4151
 
@@ -4161,11 +4161,11 @@ The MySQL MCP server provides advanced query optimization tools that help you im
4161
4161
 
4162
4162
  ### Using Optimizer Hints
4163
4163
 
4164
- When running queries with `run_query`, you can include optimizer hints:
4164
+ When running queries with `run_select_query`, you can include optimizer hints:
4165
4165
 
4166
4166
  ```json
4167
4167
  {
4168
- "tool": "run_query",
4168
+ "tool": "run_select_query",
4169
4169
  "arguments": {
4170
4170
  "query": "SELECT * FROM orders WHERE customer_id = ?",
4171
4171
  "params": [123],
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-19 19:09:00
7
+ **Last Updated:** 2025-12-21 17:00: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)
@@ -173,7 +173,7 @@ Alternative approach using environment variables instead of connection string:
173
173
  "DB_USER": "root",
174
174
  "DB_PASSWORD": "your_password",
175
175
  "DB_NAME": "your_database",
176
- "MCP_PERMISSIONS": "list,read,utility"
176
+ "MCP_PERMISSIONS": "list,read,utility,create,update,delete"
177
177
  }
178
178
  }
179
179
  }
@@ -194,8 +194,8 @@ Alternative approach using environment variables instead of connection string:
194
194
  "DB_USER": "root",
195
195
  "DB_PASSWORD": "your_password",
196
196
  "DB_NAME": "your_database",
197
- "MCP_PERMISSIONS": "list,read,utility",
198
- "MCP_CATEGORIES": "database_discovery,performance_monitoring"
197
+ "MCP_PERMISSIONS": "list,read,utility,create,update,delete",
198
+ "MCP_CATEGORIES": "database_discovery,performance_monitoring,custom_queries"
199
199
  }
200
200
  }
201
201
  }
@@ -243,7 +243,7 @@ Use documentation categories to fine-tune which tools are exposed (Layer 2):
243
243
  | `database_discovery` | Explore databases, tables, and schema structure | `get_all_tables_relationships, get_table_relationships, list_databases, list_tables, read_table_schema` |
244
244
  | `crud_operations` | Create, read, update, delete operations on data | `create_record, delete_record, read_records, update_record` |
245
245
  | `bulk_operations` | High-performance batch processing operations | `bulk_delete, bulk_insert, bulk_update` |
246
- | `custom_queries` | Execute custom SQL queries and advanced operations | `execute_sql, run_query` |
246
+ | `custom_queries` | Execute custom SQL queries and advanced operations | `execute_write_query, run_select_query` |
247
247
  | `schema_management` | Manage database schema, tables, and structure | `alter_table, create_table, drop_table, execute_ddl` |
248
248
  | `utilities` | Database utilities, diagnostics, and helper functions | `describe_connection, export_query_to_csv, export_table_to_csv, list_all_tools, read_changelog, test_connection` |
249
249
  | `transaction_management` | Handle ACID transactions and rollback operations | `begin_transaction, commit_transaction, execute_in_transaction, get_transaction_status, rollback_transaction` |
@@ -79,8 +79,8 @@ exports.toolCategoryMap = {
79
79
  bulkUpdate: ToolCategory.UPDATE,
80
80
  bulkDelete: ToolCategory.DELETE,
81
81
  // Query tools
82
- runQuery: ToolCategory.READ,
83
- executeSql: ToolCategory.EXECUTE,
82
+ runSelectQuery: ToolCategory.READ,
83
+ executeWriteQuery: ToolCategory.EXECUTE,
84
84
  // DDL tools
85
85
  createTable: ToolCategory.DDL,
86
86
  alterTable: ToolCategory.DDL,
@@ -238,8 +238,8 @@ exports.toolDocCategoryMap = {
238
238
  bulkUpdate: DocCategory.BULK_OPERATIONS,
239
239
  bulkDelete: DocCategory.BULK_OPERATIONS,
240
240
  // Custom Queries
241
- runQuery: DocCategory.CUSTOM_QUERIES,
242
- executeSql: DocCategory.CUSTOM_QUERIES,
241
+ runSelectQuery: DocCategory.CUSTOM_QUERIES,
242
+ executeWriteQuery: DocCategory.CUSTOM_QUERIES,
243
243
  // Schema Management (DDL)
244
244
  createTable: DocCategory.SCHEMA_MANAGEMENT,
245
245
  alterTable: DocCategory.SCHEMA_MANAGEMENT,
package/dist/index.d.ts CHANGED
@@ -119,7 +119,7 @@ export declare class MySQLMCP {
119
119
  };
120
120
  error?: string;
121
121
  }>;
122
- runQuery(params: {
122
+ runSelectQuery(params: {
123
123
  query: string;
124
124
  params?: any[];
125
125
  hints?: any;
@@ -135,7 +135,7 @@ export declare class MySQLMCP {
135
135
  estimated_cost?: string;
136
136
  message?: string;
137
137
  }>;
138
- executeSql(params: {
138
+ executeWriteQuery(params: {
139
139
  query: string;
140
140
  params?: any[];
141
141
  }): Promise<{
package/dist/index.js CHANGED
@@ -159,8 +159,8 @@ class MySQLMCP {
159
159
  return await this.crudTools.deleteRecord(params);
160
160
  }
161
161
  // Query Tools
162
- async runQuery(params) {
163
- const check = this.checkToolEnabled("runQuery");
162
+ async runSelectQuery(params) {
163
+ const check = this.checkToolEnabled("runSelectQuery");
164
164
  if (!check.enabled) {
165
165
  return { status: "error", error: check.error };
166
166
  }
@@ -168,13 +168,13 @@ class MySQLMCP {
168
168
  if (!this.security.isReadOnlyQuery(params.query)) {
169
169
  return {
170
170
  status: "error",
171
- error: "Only SELECT queries are allowed with runQuery. Use executeSql for other operations.",
171
+ error: "Only SELECT queries are allowed with run_select_query. Use execute_write_query for other operations.",
172
172
  };
173
173
  }
174
- return await this.queryTools.runQuery(params);
174
+ return await this.queryTools.runSelectQuery(params);
175
175
  }
176
- async executeSql(params) {
177
- const check = this.checkToolEnabled("executeSql");
176
+ async executeWriteQuery(params) {
177
+ const check = this.checkToolEnabled("executeWriteQuery");
178
178
  if (!check.enabled) {
179
179
  return { status: "error", error: check.error };
180
180
  }
@@ -184,11 +184,11 @@ class MySQLMCP {
184
184
  if (!this.featureConfig.isCategoryEnabled("ddl")) {
185
185
  return {
186
186
  status: "error",
187
- error: 'DDL operations (DROP, TRUNCATE, ALTER, CREATE) require the "ddl" permission. Use executeDdl tool or add "ddl" to permissions.',
187
+ error: 'DDL operations (DROP, TRUNCATE, ALTER, CREATE) require the "ddl" permission. Use execute_ddl tool or add "ddl" to permissions.',
188
188
  };
189
189
  }
190
190
  }
191
- return await this.queryTools.executeSql(params);
191
+ return await this.queryTools.executeWriteQuery(params);
192
192
  }
193
193
  // Analysis Tools
194
194
  async getColumnStatistics(params) {
@@ -307,7 +307,7 @@ class MySQLMCP {
307
307
  return await this.transactionTools.getTransactionStatus();
308
308
  }
309
309
  async executeInTransaction(params) {
310
- const check = this.checkToolEnabled("executeSql"); // Use executeSql permission for transaction queries
310
+ const check = this.checkToolEnabled("executeWriteQuery"); // Use executeWriteQuery permission for transaction queries
311
311
  if (!check.enabled) {
312
312
  return { status: "error", error: check.error };
313
313
  }
@@ -16,7 +16,7 @@ let mysqlMCP;
16
16
  const TOOLS = [
17
17
  {
18
18
  name: "list_databases",
19
- description: "Lists all databases available on the MySQL server.",
19
+ description: "Lists all databases available on the MySQL server. Use this to discover what databases exist before querying them.",
20
20
  inputSchema: {
21
21
  type: "object",
22
22
  properties: {},
@@ -24,7 +24,7 @@ const TOOLS = [
24
24
  },
25
25
  {
26
26
  name: "list_tables",
27
- description: "Lists all tables in the connected MySQL database.",
27
+ description: "Lists all tables in the connected database. Use this as the first step when exploring an unfamiliar database to see available tables.",
28
28
  inputSchema: {
29
29
  type: "object",
30
30
  properties: {
@@ -37,7 +37,7 @@ const TOOLS = [
37
37
  },
38
38
  {
39
39
  name: "get_database_summary",
40
- description: "Get a high-level summary of the database (tables, columns, row counts) optimized for AI context.",
40
+ description: "📊 Returns a high-level overview of the database including all tables, their columns, data types, and row counts. RECOMMENDED: Use this first when exploring a new database to understand its structure quickly. Optimized for AI context with concise formatting.",
41
41
  inputSchema: {
42
42
  type: "object",
43
43
  properties: {
@@ -50,7 +50,7 @@ const TOOLS = [
50
50
  },
51
51
  {
52
52
  name: "get_schema_erd",
53
- description: "Get a Mermaid.js ER diagram string representing the database schema and relationships.",
53
+ description: "📈 Generates a visual Mermaid.js ER diagram showing tables and their relationships. Perfect for visualizing database structure and foreign key connections. Use when users ask to 'visualize' or 'diagram' the database.",
54
54
  inputSchema: {
55
55
  type: "object",
56
56
  properties: {
@@ -63,7 +63,7 @@ const TOOLS = [
63
63
  },
64
64
  {
65
65
  name: "get_schema_rag_context",
66
- description: "Return a compact schema-aware context pack (tables, PK/FK, columns, row estimates) optimized for RAG prompts.",
66
+ description: "🎯 AI-OPTIMIZED: Returns ultra-compact schema information (tables, columns, keys, relationships, row estimates) designed specifically for LLM context windows. Use this when you need schema awareness but want to minimize token usage. Configurable limits for tables/columns.",
67
67
  inputSchema: {
68
68
  type: "object",
69
69
  properties: {
@@ -88,7 +88,7 @@ const TOOLS = [
88
88
  },
89
89
  {
90
90
  name: "get_column_statistics",
91
- description: "Get detailed statistics for a specific column (min, max, avg, distinct counts, nulls).",
91
+ description: "Returns detailed statistics for a specific column: min/max values, average, distinct count, null percentage, and value distribution. Use to understand data quality and ranges in a column before writing queries.",
92
92
  inputSchema: {
93
93
  type: "object",
94
94
  properties: {
@@ -110,7 +110,7 @@ const TOOLS = [
110
110
  },
111
111
  {
112
112
  name: "read_table_schema",
113
- description: "Reads the schema of a specified table, including columns, types, keys, and indexes.",
113
+ description: "Returns complete schema definition for a table: columns, data types, constraints, keys, indexes, and defaults. Use when you need detailed structural information about a specific table.",
114
114
  inputSchema: {
115
115
  type: "object",
116
116
  properties: {
@@ -124,7 +124,7 @@ const TOOLS = [
124
124
  },
125
125
  {
126
126
  name: "create_record",
127
- description: "Creates a new record in the specified table.",
127
+ description: "Inserts a single new record into a table. For inserting multiple records at once, use bulk_insert for better performance.",
128
128
  inputSchema: {
129
129
  type: "object",
130
130
  properties: {
@@ -142,7 +142,7 @@ const TOOLS = [
142
142
  },
143
143
  {
144
144
  name: "read_records",
145
- description: "Reads records from the specified table with optional filtering, pagination, and sorting.",
145
+ description: "Reads records from a table with built-in filtering, pagination, and sorting. Use this for simple data retrieval. For complex queries with JOINs or aggregations, use run_select_query instead.",
146
146
  inputSchema: {
147
147
  type: "object",
148
148
  properties: {
@@ -194,7 +194,7 @@ const TOOLS = [
194
194
  },
195
195
  {
196
196
  name: "update_record",
197
- description: "Updates existing records in the specified table based on conditions.",
197
+ description: "Updates records in a table based on specified conditions. For updating many records with different values, use bulk_update for better performance.",
198
198
  inputSchema: {
199
199
  type: "object",
200
200
  properties: {
@@ -228,7 +228,7 @@ const TOOLS = [
228
228
  },
229
229
  {
230
230
  name: "delete_record",
231
- description: "Deletes records from the specified table based on conditions.",
231
+ description: "Deletes records from a table based on specified conditions. Always requires conditions for safety (no WHERE-less deletes). For deleting multiple record sets, use bulk_delete.",
232
232
  inputSchema: {
233
233
  type: "object",
234
234
  properties: {
@@ -258,7 +258,7 @@ const TOOLS = [
258
258
  },
259
259
  {
260
260
  name: "bulk_insert",
261
- description: "Bulk insert multiple records into the specified table with batch processing for optimal performance.",
261
+ description: " PERFORMANCE: Inserts multiple records efficiently using batch processing. Handles 1000s of rows with automatic batching. Use this instead of create_record when inserting many records at once (10+ rows).",
262
262
  inputSchema: {
263
263
  type: "object",
264
264
  properties: {
@@ -287,7 +287,7 @@ const TOOLS = [
287
287
  },
288
288
  {
289
289
  name: "bulk_update",
290
- description: "Bulk update multiple records with different conditions and data using batch processing.",
290
+ description: " PERFORMANCE: Updates multiple records with different values in batches. Each update can have unique conditions and data. Much faster than calling update_record repeatedly for multiple rows.",
291
291
  inputSchema: {
292
292
  type: "object",
293
293
  properties: {
@@ -349,7 +349,7 @@ const TOOLS = [
349
349
  },
350
350
  {
351
351
  name: "bulk_delete",
352
- description: "Bulk delete records based on multiple condition sets using batch processing.",
352
+ description: " PERFORMANCE: Deletes multiple sets of records efficiently in batches. Each condition set defines a separate delete operation. More efficient than calling delete_record multiple times.",
353
353
  inputSchema: {
354
354
  type: "object",
355
355
  properties: {
@@ -390,8 +390,8 @@ const TOOLS = [
390
390
  },
391
391
  },
392
392
  {
393
- name: "run_query",
394
- description: "⚡ USE THIS FOR SELECT QUERIES. Runs a read-only SQL SELECT query with optional parameters, optimizer hints, and caching support. ONLY SELECT statements are allowed - use execute_sql for INSERT/UPDATE/DELETE, use execute_ddl for CREATE/ALTER/DROP.",
393
+ name: "run_select_query",
394
+ description: "⚡ PRIMARY TOOL FOR SELECT QUERIES. Executes read-only SELECT statements with parameterization, optimizer hints, query caching, and dry-run mode. Supports complex queries with JOINs, subqueries, and aggregations. ⚠️ ONLY for SELECT - use execute_write_query for INSERT/UPDATE/DELETE, use execute_ddl for CREATE/ALTER/DROP.",
395
395
  inputSchema: {
396
396
  type: "object",
397
397
  properties: {
@@ -457,8 +457,8 @@ const TOOLS = [
457
457
  },
458
458
  },
459
459
  {
460
- name: "execute_sql",
461
- description: '⚡ USE THIS FOR INSERT/UPDATE/DELETE. Executes a write SQL operation (INSERT, UPDATE, DELETE) with optional parameters. NOT for SELECT (use run_query), NOT for DDL (use execute_ddl for CREATE/ALTER/DROP/TRUNCATE/RENAME).',
460
+ name: "execute_write_query",
461
+ description: '⚡ PRIMARY TOOL FOR INSERT/UPDATE/DELETE QUERIES. Executes data modification statements with parameterization support. Returns affected row count and execution details. ⚠️ NOT for SELECT (use run_select_query), NOT for DDL (use execute_ddl for CREATE/ALTER/DROP/TRUNCATE/RENAME).',
462
462
  inputSchema: {
463
463
  type: "object",
464
464
  properties: {
@@ -477,7 +477,7 @@ const TOOLS = [
477
477
  },
478
478
  {
479
479
  name: "safe_export_table",
480
- description: "Exports table data to CSV with enforced data masking rules to protect sensitive information.",
480
+ description: "🔒 SECURITY: Exports table data to CSV with automatic PII/sensitive data masking. Redacts emails, credit cards, passwords, etc. Use this instead of export_table_to_csv when handling sensitive data or sharing exports externally.",
481
481
  inputSchema: {
482
482
  type: "object",
483
483
  properties: {
@@ -504,7 +504,7 @@ const TOOLS = [
504
504
  },
505
505
  {
506
506
  name: "repair_query",
507
- description: "Analyzes a SQL query (and optional error) to suggest repairs or optimizations using EXPLAIN and heuristics.",
507
+ description: "🔧 Diagnoses SQL query errors and suggests fixes. Analyzes syntax errors, missing columns/tables, and logic issues. Provide the query and optional error message to get repair recommendations. Use when a query fails or needs debugging.",
508
508
  inputSchema: {
509
509
  type: "object",
510
510
  properties: {
@@ -522,7 +522,7 @@ const TOOLS = [
522
522
  },
523
523
  {
524
524
  name: "create_table",
525
- description: 'Creates a new table with the specified columns and indexes. Requires "ddl" permission.',
525
+ description: '🏗️ Creates a new table with columns, data types, constraints, and indexes. Simplified interface compared to raw DDL. Requires "ddl" permission.',
526
526
  inputSchema: {
527
527
  type: "object",
528
528
  properties: {
@@ -576,7 +576,7 @@ const TOOLS = [
576
576
  },
577
577
  {
578
578
  name: "alter_table",
579
- description: 'Alters an existing table structure (add/drop/modify columns, add/drop indexes). Requires "ddl" permission.',
579
+ description: '🔧 Modifies existing table structure: add/drop/modify/rename columns, add/drop indexes. Supports multiple operations in one call. Requires "ddl" permission.',
580
580
  inputSchema: {
581
581
  type: "object",
582
582
  properties: {
@@ -620,7 +620,7 @@ const TOOLS = [
620
620
  },
621
621
  {
622
622
  name: "drop_table",
623
- description: 'Drops (deletes) a table and all its data. Requires "ddl" permission. WARNING: This is irreversible!',
623
+ description: '🗑️ DESTRUCTIVE: Permanently deletes a table and ALL its data. Cannot be undone! Consider backup_table first. Requires "ddl" permission. ⚠️ WARNING: IRREVERSIBLE!',
624
624
  inputSchema: {
625
625
  type: "object",
626
626
  properties: {
@@ -638,7 +638,7 @@ const TOOLS = [
638
638
  },
639
639
  {
640
640
  name: "execute_ddl",
641
- description: '⚡ USE THIS FOR DDL ONLY (CREATE, ALTER, DROP, TRUNCATE, RENAME). NOT for SELECT (use run_query), NOT for INSERT/UPDATE/DELETE (use execute_sql). Requires "ddl" permission.',
641
+ description: '⚡ PRIMARY TOOL FOR DDL STATEMENTS. Executes schema modification queries: CREATE, ALTER, DROP, TRUNCATE, RENAME. Use for complex DDL that structured tools don\'t cover. ⚠️ NOT for SELECT (use run_select_query), NOT for INSERT/UPDATE/DELETE (use execute_write_query). Requires "ddl" permission.',
642
642
  inputSchema: {
643
643
  type: "object",
644
644
  properties: {
@@ -652,7 +652,7 @@ const TOOLS = [
652
652
  },
653
653
  {
654
654
  name: "describe_connection",
655
- description: "Returns information about the current database connection.",
655
+ description: "Returns current database connection details: host, database name, user, port, and connection status. Use to verify which database you're connected to.",
656
656
  inputSchema: {
657
657
  type: "object",
658
658
  properties: {},
@@ -660,7 +660,7 @@ const TOOLS = [
660
660
  },
661
661
  {
662
662
  name: "read_changelog",
663
- description: "Reads the changelog to see what features are new or changed.",
663
+ description: "Reads the MySQL MCP Server changelog to see version history, new features, bug fixes, and breaking changes. Useful for understanding tool capabilities and recent updates.",
664
664
  inputSchema: {
665
665
  type: "object",
666
666
  properties: {
@@ -677,7 +677,7 @@ const TOOLS = [
677
677
  },
678
678
  {
679
679
  name: "test_connection",
680
- description: "Tests the database connection and returns latency information.",
680
+ description: "Tests database connectivity and measures latency. Returns connection status and response time. Use to troubleshoot connection issues or check database availability.",
681
681
  inputSchema: {
682
682
  type: "object",
683
683
  properties: {},
@@ -685,29 +685,15 @@ const TOOLS = [
685
685
  },
686
686
  {
687
687
  name: "list_all_tools",
688
- description: "Lists all available MCP tools with their definitions and server metadata.",
688
+ description: "📋 Returns complete catalog of all available tools with names, descriptions, parameters, and current permissions. Use to discover tool capabilities or when users ask 'what can you do?'.",
689
689
  inputSchema: {
690
690
  type: "object",
691
691
  properties: {},
692
692
  },
693
693
  },
694
- {
695
- name: "get_table_relationships",
696
- description: "Returns foreign key relationships for a specified table.",
697
- inputSchema: {
698
- type: "object",
699
- properties: {
700
- table_name: {
701
- type: "string",
702
- description: "Name of the table to get relationships for",
703
- },
704
- },
705
- required: ["table_name"],
706
- },
707
- },
708
694
  {
709
695
  name: "get_all_tables_relationships",
710
- description: "Gets all table foreign key relationships in one call with memory-efficient relationship mapping.",
696
+ description: "Gets ALL table foreign key relationships in the entire database in a single efficient query. Returns a comprehensive relationship map showing parent-child connections between all tables. Much faster than querying table-by-table.",
711
697
  inputSchema: {
712
698
  type: "object",
713
699
  properties: {
@@ -721,7 +707,7 @@ const TOOLS = [
721
707
  // Transaction Tools
722
708
  {
723
709
  name: "begin_transaction",
724
- description: "Begins a new database transaction. Returns a transaction ID for subsequent operations.",
710
+ description: "🔄 Starts a new database transaction and returns a transaction ID. Use with commit_transaction or rollback_transaction to group multiple operations atomically. Essential for data consistency when multiple changes must succeed or fail together.",
725
711
  inputSchema: {
726
712
  type: "object",
727
713
  properties: {
@@ -734,7 +720,7 @@ const TOOLS = [
734
720
  },
735
721
  {
736
722
  name: "commit_transaction",
737
- description: "Commits a transaction and makes all changes permanent.",
723
+ description: "Commits an active transaction, making all changes permanent. Use after successful completion of all operations within a transaction started by begin_transaction.",
738
724
  inputSchema: {
739
725
  type: "object",
740
726
  properties: {
@@ -748,7 +734,7 @@ const TOOLS = [
748
734
  },
749
735
  {
750
736
  name: "rollback_transaction",
751
- description: "Rolls back a transaction and undoes all changes made within it.",
737
+ description: "↩️ Rolls back an active transaction, undoing ALL changes made within it. Use when an error occurs during transaction or when changes need to be cancelled.",
752
738
  inputSchema: {
753
739
  type: "object",
754
740
  properties: {
@@ -762,7 +748,7 @@ const TOOLS = [
762
748
  },
763
749
  {
764
750
  name: "get_transaction_status",
765
- description: "Returns the status of all active transactions.",
751
+ description: "Shows all active transactions with their IDs, start times, and operation counts. Use to monitor transaction state or debug transaction issues.",
766
752
  inputSchema: {
767
753
  type: "object",
768
754
  properties: {},
@@ -770,7 +756,7 @@ const TOOLS = [
770
756
  },
771
757
  {
772
758
  name: "execute_in_transaction",
773
- description: "Executes a SQL query within an active transaction.",
759
+ description: "Executes a SQL query within an existing transaction context. The query becomes part of the transaction and will be committed or rolled back with it. Use after begin_transaction.",
774
760
  inputSchema: {
775
761
  type: "object",
776
762
  properties: {
@@ -935,7 +921,7 @@ const TOOLS = [
935
921
  // Data Export Tools
936
922
  {
937
923
  name: "export_table_to_csv",
938
- description: "Export table data to CSV format with optional filtering, pagination, and sorting.",
924
+ description: "📄 Exports table data to CSV format with filtering, pagination, and sorting. For sensitive data, use safe_export_table instead which includes automatic data masking.",
939
925
  inputSchema: {
940
926
  type: "object",
941
927
  properties: {
@@ -991,7 +977,7 @@ const TOOLS = [
991
977
  },
992
978
  {
993
979
  name: "export_query_to_csv",
994
- description: "Export the results of a SELECT query to CSV format.",
980
+ description: "📄 Executes a SELECT query and exports results to CSV format. Supports complex queries with JOINs and aggregations. For sensitive data, consider using safe_export_table or adding manual data masking.",
995
981
  inputSchema: {
996
982
  type: "object",
997
983
  properties: {
@@ -1015,7 +1001,7 @@ const TOOLS = [
1015
1001
  // Cache Management Tools
1016
1002
  {
1017
1003
  name: "get_cache_stats",
1018
- description: "Get query cache statistics including hit rate, size, and configuration.",
1004
+ description: "📊 Returns query cache performance metrics: hit rate, miss rate, size, memory usage, and entry count. Use to monitor cache effectiveness and tune cache settings.",
1019
1005
  inputSchema: {
1020
1006
  type: "object",
1021
1007
  properties: {},
@@ -1079,7 +1065,7 @@ const TOOLS = [
1079
1065
  // Query Optimization Tools
1080
1066
  {
1081
1067
  name: "analyze_query",
1082
- description: "Analyze a SQL query and get optimization suggestions including recommended indexes and hints.",
1068
+ description: "🔍 Analyzes a SQL query using EXPLAIN and provides optimization suggestions: missing indexes, inefficient operations, cost estimates. Returns actionable recommendations. Use before running expensive queries.",
1083
1069
  inputSchema: {
1084
1070
  type: "object",
1085
1071
  properties: {
@@ -1833,7 +1819,7 @@ const TOOLS = [
1833
1819
  },
1834
1820
  {
1835
1821
  name: "truncate_table",
1836
- description: "Truncates a table (removes all rows quickly). Requires 'ddl' permission. WARNING: This is irreversible!",
1822
+ description: "🗑️ DESTRUCTIVE: Removes ALL rows from a table instantly (faster than DELETE). Resets auto-increment counters. Cannot be undone! Consider backup_table first. Requires 'ddl' permission. ⚠️ WARNING: IRREVERSIBLE!",
1837
1823
  inputSchema: {
1838
1824
  type: "object",
1839
1825
  properties: {
@@ -2057,7 +2043,7 @@ const TOOLS = [
2057
2043
  },
2058
2044
  {
2059
2045
  name: "backup_database",
2060
- description: "Backup entire database or selected tables to SQL dump format.",
2046
+ description: "💾 Creates SQL dump backup of entire database or specific tables. Includes structure and optionally data. Returns backup as SQL text. Use before major schema changes or migrations.",
2061
2047
  inputSchema: {
2062
2048
  type: "object",
2063
2049
  properties: {
@@ -2723,7 +2709,7 @@ const TOOLS = [
2723
2709
  // Performance Monitoring Tools
2724
2710
  {
2725
2711
  name: "get_performance_metrics",
2726
- description: "Get comprehensive MySQL performance metrics including query performance, connection stats, buffer pool metrics, and InnoDB statistics.",
2712
+ description: "📊 COMPREHENSIVE MONITORING: Returns complete MySQL performance dashboard including query stats, connection pool, buffer pool efficiency, InnoDB metrics, and disk I/O. Use for performance troubleshooting or health checks.",
2727
2713
  inputSchema: {
2728
2714
  type: "object",
2729
2715
  properties: {},
@@ -2849,7 +2835,7 @@ const TOOLS = [
2849
2835
  // Intelligent Query Assistant
2850
2836
  {
2851
2837
  name: "build_query_from_intent",
2852
- description: "Converts natural language to optimized SQL with context-aware query generation. Analyzes your intent and generates safe, optimized SQL queries with explanations.",
2838
+ description: "🤖 AI-POWERED: Converts natural language descriptions into optimized SQL queries. Example: 'show me all users who registered last month' → SELECT query. Includes query explanation and safety checks. RECOMMENDED for when users describe what they want instead of writing SQL.",
2853
2839
  inputSchema: {
2854
2840
  type: "object",
2855
2841
  properties: {
@@ -2882,7 +2868,7 @@ const TOOLS = [
2882
2868
  },
2883
2869
  {
2884
2870
  name: "suggest_query_improvements",
2885
- description: "Analyzes a SQL query and suggests improvements for speed, memory, or readability. Identifies inefficient patterns and provides optimized alternatives.",
2871
+ description: "🎯 AI-POWERED: Analyzes a SQL query and suggests optimizations for speed, memory usage, or readability. Identifies missing indexes, inefficient JOINs, subquery opportunities, and anti-patterns. Use when a query is slow or complex.",
2886
2872
  inputSchema: {
2887
2873
  type: "object",
2888
2874
  properties: {
@@ -2908,7 +2894,7 @@ const TOOLS = [
2908
2894
  // ==========================================
2909
2895
  {
2910
2896
  name: "design_schema_from_requirements",
2911
- description: "Designs a database schema from natural language requirements. Returns a proposed schema spec and CREATE TABLE / CREATE INDEX statements (does not execute DDL).",
2897
+ description: "🤖 AI-POWERED SCHEMA DESIGN: Converts business requirements into complete database schema. Input: 'I need a blog with users, posts, and comments' Output: normalized table structures with relationships, indexes, and CREATE statements. Does NOT execute DDL automatically.",
2912
2898
  inputSchema: {
2913
2899
  type: "object",
2914
2900
  properties: {
@@ -2960,7 +2946,7 @@ const TOOLS = [
2960
2946
  },
2961
2947
  {
2962
2948
  name: "audit_database_security",
2963
- description: "Audits MySQL security configuration and (optionally) accounts/privileges using read-only inspection queries. Returns prioritized findings and recommendations.",
2949
+ description: "🔒 AI-POWERED SECURITY AUDIT: Analyzes database security configuration, user privileges, password policies, and access patterns. Returns prioritized security risks with remediation steps. Read-only, safe to run anytime.",
2964
2950
  inputSchema: {
2965
2951
  type: "object",
2966
2952
  properties: {
@@ -2981,7 +2967,7 @@ const TOOLS = [
2981
2967
  },
2982
2968
  {
2983
2969
  name: "recommend_indexes",
2984
- description: "Analyzes real query patterns from performance_schema digests and suggests concrete CREATE INDEX statements. Uses heuristics to avoid duplicate/redundant indexes.",
2970
+ description: "🎯 AI-POWERED INDEX RECOMMENDATIONS: Analyzes actual query patterns from performance_schema and suggests specific indexes to create. Identifies slow queries and missing indexes. Returns ready-to-execute CREATE INDEX statements. Avoids redundant indexes.",
2985
2971
  inputSchema: {
2986
2972
  type: "object",
2987
2973
  properties: {
@@ -3017,7 +3003,7 @@ const TOOLS = [
3017
3003
  // ==========================================
3018
3004
  {
3019
3005
  name: "generate_test_data",
3020
- description: "Generates synthetic test data as SQL INSERT statements for a given table (does not execute). Attempts FK-aware value selection for referential integrity.",
3006
+ description: "🤖 AI-POWERED DATA GENERATION: Creates realistic synthetic test data based on column names and types. Respects foreign key relationships. Returns INSERT statements (does not execute). Perfect for testing, demos, or development environments.",
3021
3007
  inputSchema: {
3022
3008
  type: "object",
3023
3009
  properties: {
@@ -3069,7 +3055,7 @@ const TOOLS = [
3069
3055
  },
3070
3056
  {
3071
3057
  name: "visualize_query",
3072
- description: "Creates a visual representation of a read-only SQL query as a Mermaid flowchart, based on EXPLAIN FORMAT=JSON and lightweight SQL parsing.",
3058
+ description: "📊 AI-POWERED VISUALIZATION: Converts a SQL query into a visual Mermaid flowchart showing execution flow, table scans, joins, and filters. Based on EXPLAIN analysis. Helps understand complex query execution. Use when users ask to 'visualize' or 'explain' a query.",
3073
3059
  inputSchema: {
3074
3060
  type: "object",
3075
3061
  properties: {
@@ -3150,7 +3136,7 @@ const TOOLS = [
3150
3136
  // Smart Data Discovery
3151
3137
  {
3152
3138
  name: "smart_search",
3153
- description: "Finds relevant tables, columns, data patterns, and relationships using semantic search. Essential for exploring large databases with hundreds of tables.",
3139
+ description: "🔍 AI-POWERED SEARCH: Finds tables, columns, and data using semantic search. Example: search 'customer email' finds email columns, user tables, contact info, etc. Essential for exploring unfamiliar or large databases (100+ tables). Much smarter than simple name matching.",
3154
3140
  inputSchema: {
3155
3141
  type: "object",
3156
3142
  properties: {
@@ -3245,7 +3231,7 @@ const TOOLS = [
3245
3231
  // Documentation Generator
3246
3232
  {
3247
3233
  name: "generate_documentation",
3248
- description: "Generates comprehensive database documentation with business glossary in Markdown, HTML, or JSON format. Includes schema, relationships, and example queries.",
3234
+ description: "📝 AI-POWERED DOCUMENTATION: Generates comprehensive database documentation in Markdown, HTML, or JSON. Includes schema diagrams, table descriptions, relationships, and example queries. Perfect for onboarding or creating data catalogs.",
3249
3235
  inputSchema: {
3250
3236
  type: "object",
3251
3237
  properties: {
@@ -3334,7 +3320,7 @@ const TOOLS = [
3334
3320
  // Create the MCP server
3335
3321
  const server = new index_js_1.Server({
3336
3322
  name: "mysql-mcp-server",
3337
- version: "1.17.0",
3323
+ version: "1.28.0",
3338
3324
  }, {
3339
3325
  capabilities: {
3340
3326
  tools: {},
@@ -3410,11 +3396,11 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
3410
3396
  result = await mysqlMCP.bulkDelete((args || {}));
3411
3397
  break;
3412
3398
  // Query Tools
3413
- case "run_query":
3414
- result = await mysqlMCP.runQuery((args || {}));
3399
+ case "run_select_query":
3400
+ result = await mysqlMCP.runSelectQuery((args || {}));
3415
3401
  break;
3416
- case "execute_sql":
3417
- result = await mysqlMCP.executeSql((args || {}));
3402
+ case "execute_write_query":
3403
+ result = await mysqlMCP.executeWriteQuery((args || {}));
3418
3404
  break;
3419
3405
  // DDL Tools
3420
3406
  case "create_table":
@@ -3441,9 +3427,6 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
3441
3427
  case "read_changelog":
3442
3428
  result = await mysqlMCP.readChangelog((args || {}));
3443
3429
  break;
3444
- case "get_table_relationships":
3445
- result = await mysqlMCP.getTableRelationships((args || {}));
3446
- break;
3447
3430
  case "get_all_tables_relationships":
3448
3431
  result = await mysqlMCP.getAllTablesRelationships((args || {}));
3449
3432
  break;
package/dist/server.js CHANGED
@@ -273,7 +273,7 @@ apiRouter.delete('/tables/:tableName/records/:id', validateInput((req) => (0, in
273
273
  apiRouter.post('/query', requestSizeLimit(inputValidation_1.INPUT_LIMITS.MAX_QUERY_LENGTH), validateInput(inputValidation_1.validateQuery), async (req, res, next) => {
274
274
  try {
275
275
  const { query, params } = req.body;
276
- const result = await mcp.runQuery({
276
+ const result = await mcp.runSelectQuery({
277
277
  query,
278
278
  params: params || []
279
279
  });
@@ -286,7 +286,7 @@ apiRouter.post('/query', requestSizeLimit(inputValidation_1.INPUT_LIMITS.MAX_QUE
286
286
  apiRouter.post('/execute', requestSizeLimit(inputValidation_1.INPUT_LIMITS.MAX_QUERY_LENGTH), validateInput(inputValidation_1.validateQuery), async (req, res, next) => {
287
287
  try {
288
288
  const { query, params } = req.body;
289
- const result = await mcp.executeSql({
289
+ const result = await mcp.executeWriteQuery({
290
290
  query,
291
291
  params: params || []
292
292
  });
@@ -50,7 +50,7 @@ class AiTools {
50
50
  // 3. Run EXPLAIN
51
51
  try {
52
52
  const explainQuery = `EXPLAIN FORMAT=JSON ${query}`;
53
- // Note: We use the raw connection or executeSql equivalent.
53
+ // Note: We use the raw connection or executeWriteQuery equivalent.
54
54
  // But EXPLAIN is safe-ish if the inner query is safe.
55
55
  // validation passed, so we try EXPLAIN.
56
56
  const explainResult = await this.db.query(explainQuery);
@@ -109,20 +109,20 @@ class DatabaseTools {
109
109
  };
110
110
  }
111
111
  try {
112
- const query = `
113
- SELECT
114
- COLUMN_NAME as column_name,
115
- DATA_TYPE as data_type,
116
- IS_NULLABLE as is_nullable,
117
- COLUMN_KEY as column_key,
118
- COLUMN_DEFAULT as column_default,
119
- EXTRA as extra
120
- FROM
121
- INFORMATION_SCHEMA.COLUMNS
122
- WHERE
123
- TABLE_NAME = ?
124
- ORDER BY
125
- ORDINAL_POSITION
112
+ const query = `
113
+ SELECT
114
+ COLUMN_NAME as column_name,
115
+ DATA_TYPE as data_type,
116
+ IS_NULLABLE as is_nullable,
117
+ COLUMN_KEY as column_key,
118
+ COLUMN_DEFAULT as column_default,
119
+ EXTRA as extra
120
+ FROM
121
+ INFORMATION_SCHEMA.COLUMNS
122
+ WHERE
123
+ TABLE_NAME = ?
124
+ ORDER BY
125
+ ORDINAL_POSITION
126
126
  `;
127
127
  const results = await this.db.query(query, [
128
128
  params.table_name,
@@ -160,18 +160,18 @@ class DatabaseTools {
160
160
  };
161
161
  }
162
162
  // Get tables and row counts
163
- const tablesQuery = `
164
- SELECT TABLE_NAME, TABLE_ROWS
165
- FROM INFORMATION_SCHEMA.TABLES
166
- WHERE TABLE_SCHEMA = ?
163
+ const tablesQuery = `
164
+ SELECT TABLE_NAME, TABLE_ROWS
165
+ FROM INFORMATION_SCHEMA.TABLES
166
+ WHERE TABLE_SCHEMA = ?
167
167
  `;
168
168
  const tables = await this.db.query(tablesQuery, [database]);
169
169
  // Get columns for all tables
170
- const columnsQuery = `
171
- SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_KEY
172
- FROM INFORMATION_SCHEMA.COLUMNS
173
- WHERE TABLE_SCHEMA = ?
174
- ORDER BY TABLE_NAME, ORDINAL_POSITION
170
+ const columnsQuery = `
171
+ SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_KEY
172
+ FROM INFORMATION_SCHEMA.COLUMNS
173
+ WHERE TABLE_SCHEMA = ?
174
+ ORDER BY TABLE_NAME, ORDINAL_POSITION
175
175
  `;
176
176
  const columns = await this.db.query(columnsQuery, [database]);
177
177
  // Build text summary
@@ -223,22 +223,22 @@ class DatabaseTools {
223
223
  };
224
224
  }
225
225
  // Get tables and columns
226
- const columnsQuery = `
227
- SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_KEY
228
- FROM INFORMATION_SCHEMA.COLUMNS
229
- WHERE TABLE_SCHEMA = ?
230
- ORDER BY TABLE_NAME, ORDINAL_POSITION
226
+ const columnsQuery = `
227
+ SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_KEY
228
+ FROM INFORMATION_SCHEMA.COLUMNS
229
+ WHERE TABLE_SCHEMA = ?
230
+ ORDER BY TABLE_NAME, ORDINAL_POSITION
231
231
  `;
232
232
  const columns = await this.db.query(columnsQuery, [database]);
233
233
  // Get foreign keys
234
- const fkQuery = `
235
- SELECT
236
- TABLE_NAME, COLUMN_NAME,
237
- REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
238
- FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
239
- WHERE TABLE_SCHEMA = ?
240
- AND REFERENCED_TABLE_SCHEMA = ?
241
- AND REFERENCED_TABLE_NAME IS NOT NULL
234
+ const fkQuery = `
235
+ SELECT
236
+ TABLE_NAME, COLUMN_NAME,
237
+ REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
238
+ FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
239
+ WHERE TABLE_SCHEMA = ?
240
+ AND REFERENCED_TABLE_SCHEMA = ?
241
+ AND REFERENCED_TABLE_NAME IS NOT NULL
242
242
  `;
243
243
  const fks = await this.db.query(fkQuery, [database, database]);
244
244
  // Build Mermaid ER diagram
@@ -252,7 +252,7 @@ class DdlTools {
252
252
  if (!isDdl) {
253
253
  return {
254
254
  status: "error",
255
- error: "Only DDL operations (CREATE, ALTER, DROP, TRUNCATE, RENAME) are allowed with execute_ddl. For SELECT queries, use the 'run_query' tool instead. For INSERT/UPDATE/DELETE, use the 'execute_sql' tool.",
255
+ error: "Only DDL operations (CREATE, ALTER, DROP, TRUNCATE, RENAME) are allowed with execute_ddl. For SELECT queries, use the 'run_select_query' tool instead. For INSERT/UPDATE/DELETE, use the 'execute_write_query' tool.",
256
256
  };
257
257
  }
258
258
  const result = await this.db.query(query);
@@ -8,7 +8,7 @@ export declare class QueryTools {
8
8
  /**
9
9
  * Execute a safe read-only SELECT query with optional optimizer hints
10
10
  */
11
- runQuery(queryParams: {
11
+ runSelectQuery(queryParams: {
12
12
  query: string;
13
13
  params?: any[];
14
14
  hints?: QueryHints;
@@ -36,7 +36,7 @@ export declare class QueryTools {
36
36
  * Execute write operations (INSERT, UPDATE, DELETE) with validation
37
37
  * Note: DDL operations are blocked by the security layer for safety
38
38
  */
39
- executeSql(queryParams: {
39
+ executeWriteQuery(queryParams: {
40
40
  query: string;
41
41
  params?: any[];
42
42
  }): Promise<{
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.QueryTools = void 0;
7
7
  const connection_1 = __importDefault(require("../db/connection"));
8
- const schemas_1 = require("../validation/schemas");
9
8
  const queryOptimizer_1 = require("../optimization/queryOptimizer");
10
9
  class QueryTools {
11
10
  constructor(security) {
@@ -16,14 +15,7 @@ class QueryTools {
16
15
  /**
17
16
  * Execute a safe read-only SELECT query with optional optimizer hints
18
17
  */
19
- async runQuery(queryParams) {
20
- // Validate input schema
21
- if (!(0, schemas_1.validateRunQuery)(queryParams)) {
22
- return {
23
- status: "error",
24
- error: "Invalid parameters: " + JSON.stringify(schemas_1.validateRunQuery.errors),
25
- };
26
- }
18
+ async runSelectQuery(queryParams) {
27
19
  try {
28
20
  const { query, params = [], hints, useCache = true } = queryParams;
29
21
  // Check if user has execute permission to bypass dangerous keyword checks
@@ -41,7 +33,7 @@ class QueryTools {
41
33
  if (queryValidation.queryType !== "SELECT") {
42
34
  return {
43
35
  status: "error",
44
- error: "Only SELECT queries are allowed with runQuery. Use executeSql for other operations.",
36
+ error: "Only SELECT queries are allowed with run_select_query. Use execute_write_query for other operations.",
45
37
  };
46
38
  }
47
39
  // Validate parameters
@@ -120,18 +112,11 @@ class QueryTools {
120
112
  * Execute write operations (INSERT, UPDATE, DELETE) with validation
121
113
  * Note: DDL operations are blocked by the security layer for safety
122
114
  */
123
- async executeSql(queryParams) {
124
- // Validate input schema
125
- if (!(0, schemas_1.validateRunQuery)(queryParams)) {
126
- return {
127
- status: "error",
128
- error: "Invalid parameters: " + JSON.stringify(schemas_1.validateRunQuery.errors),
129
- };
130
- }
115
+ async executeWriteQuery(queryParams) {
131
116
  try {
132
117
  const { query, params = [] } = queryParams;
133
118
  // Validate query using security layer
134
- // Pass true for bypassDangerousCheck since this is executeSql (requires 'execute' permission)
119
+ // Pass true for bypassDangerousCheck since this is executeWriteQuery (requires 'execute' permission)
135
120
  const queryValidation = this.security.validateQuery(query, true);
136
121
  if (!queryValidation.valid) {
137
122
  return {
@@ -139,11 +124,11 @@ class QueryTools {
139
124
  error: `Query validation failed: ${queryValidation.error}`,
140
125
  };
141
126
  }
142
- // Ensure it's not a SELECT query (use runQuery for that)
127
+ // Ensure it's not a SELECT query (use runSelectQuery for that)
143
128
  if (queryValidation.queryType === "SELECT") {
144
129
  return {
145
130
  status: "error",
146
- error: "SELECT queries should use runQuery method instead of executeSql.",
131
+ error: "SELECT queries should use run_select_query method instead of execute_write_query.",
147
132
  };
148
133
  }
149
134
  // Validate parameters
@@ -116,7 +116,7 @@ class TransactionTools {
116
116
  };
117
117
  }
118
118
  // SECURITY VALIDATION: Check if user has execute permission
119
- const hasExecutePermission = this.security.isToolEnabled("executeSql");
119
+ const hasExecutePermission = this.security.isToolEnabled("executeWriteQuery");
120
120
  // SECURITY VALIDATION: Validate the query before execution
121
121
  const queryValidation = this.security.validateQuery(params.query, hasExecutePermission);
122
122
  if (!queryValidation.valid) {
@@ -172,36 +172,6 @@ export declare const deleteRecordSchema: {
172
172
  };
173
173
  additionalProperties: boolean;
174
174
  };
175
- export declare const runQuerySchema: {
176
- type: string;
177
- required: string[];
178
- properties: {
179
- query: {
180
- type: string;
181
- };
182
- params: {
183
- type: string;
184
- items: {};
185
- nullable: boolean;
186
- };
187
- };
188
- additionalProperties: boolean;
189
- };
190
- export declare const executeSqlSchema: {
191
- type: string;
192
- required: string[];
193
- properties: {
194
- query: {
195
- type: string;
196
- };
197
- params: {
198
- type: string;
199
- items: {};
200
- nullable: boolean;
201
- };
202
- };
203
- additionalProperties: boolean;
204
- };
205
175
  export declare const createTableSchema: {
206
176
  type: string;
207
177
  required: string[];
@@ -630,12 +600,6 @@ export declare const validateBulkUpdate: import("ajv").ValidateFunction<{
630
600
  export declare const validateBulkDelete: import("ajv").ValidateFunction<{
631
601
  [x: string]: {};
632
602
  }>;
633
- export declare const validateRunQuery: import("ajv").ValidateFunction<{
634
- [x: string]: {};
635
- }>;
636
- export declare const validateExecuteSql: import("ajv").ValidateFunction<{
637
- [x: string]: {};
638
- }>;
639
603
  export declare const validateCreateTable: import("ajv").ValidateFunction<{
640
604
  [x: string]: {};
641
605
  }>;
@@ -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.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;
6
+ exports.validateStoredProcedureCreation = exports.validateStoredProcedureExecution = exports.validateShowCreateProcedure = 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.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.deleteRecordSchema = exports.updateRecordSchema = exports.readRecordsSchema = exports.createRecordSchema = exports.readTableSchemaSchema = exports.listTablesSchema = void 0;
7
+ exports.validateExportQueryToCsv = exports.validateExportTableToCsv = exports.validateGetAllTablesRelationships = exports.validateGetTableRelationships = void 0;
8
8
  const ajv_1 = __importDefault(require("ajv"));
9
9
  const ajv = new ajv_1.default();
10
10
  // Schema definitions
@@ -141,33 +141,8 @@ const filterConditionSchema = {
141
141
  },
142
142
  additionalProperties: false
143
143
  };
144
- exports.runQuerySchema = {
145
- type: 'object',
146
- required: ['query'],
147
- properties: {
148
- query: { type: 'string' },
149
- params: {
150
- type: 'array',
151
- items: {},
152
- nullable: true
153
- }
154
- },
155
- additionalProperties: false
156
- };
157
- // SQL execution schema
158
- exports.executeSqlSchema = {
159
- type: 'object',
160
- required: ['query'],
161
- properties: {
162
- query: { type: 'string' },
163
- params: {
164
- type: 'array',
165
- items: {},
166
- nullable: true
167
- }
168
- },
169
- additionalProperties: false
170
- };
144
+ // Note: runQuerySchema and executeSqlSchema have been removed
145
+ // Use runSelectQuerySchema and executeWriteQuerySchema instead
171
146
  // DDL schemas
172
147
  exports.createTableSchema = {
173
148
  type: 'object',
@@ -518,8 +493,6 @@ exports.validateDeleteRecord = ajv.compile(exports.deleteRecordSchema);
518
493
  exports.validateBulkInsert = ajv.compile(bulkInsertSchema);
519
494
  exports.validateBulkUpdate = ajv.compile(bulkUpdateSchema);
520
495
  exports.validateBulkDelete = ajv.compile(bulkDeleteSchema);
521
- exports.validateRunQuery = ajv.compile(exports.runQuerySchema);
522
- exports.validateExecuteSql = ajv.compile(exports.executeSqlSchema);
523
496
  exports.validateCreateTable = ajv.compile(exports.createTableSchema);
524
497
  exports.validateAlterTable = ajv.compile(exports.alterTableSchema);
525
498
  exports.validateDropTable = ajv.compile(exports.dropTableSchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@berthojoris/mcp-mysql-server",
3
- "version": "1.26.4",
3
+ "version": "1.28.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",
@@ -87,4 +87,4 @@
87
87
  "ts-node": "^10.9.1",
88
88
  "typescript": "^5.2.2"
89
89
  }
90
- }
90
+ }