@berthojoris/mcp-mysql-server 1.43.5 → 1.44.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/DOCUMENTATIONS.md +19 -3
  3. package/README.md +7 -1
  4. package/bin/mcp-mysql.js +168 -168
  5. package/dist/cache/queryCache.js +1 -1
  6. package/dist/config/config.js +2 -1
  7. package/dist/config/featureConfig.d.ts +5 -0
  8. package/dist/config/featureConfig.js +11 -13
  9. package/dist/db/connection.d.ts +8 -1
  10. package/dist/db/connection.js +19 -14
  11. package/dist/mcp-server.js +30 -302
  12. package/dist/security/securityLayer.d.ts +21 -2
  13. package/dist/security/securityLayer.js +151 -21
  14. package/dist/tools/toolArgumentValidation.js +22 -22
  15. package/dist/tools/toolRegistry.d.ts +1 -1
  16. package/dist/tools/toolRegistry.js +7 -1
  17. package/manifest.json +1 -1
  18. package/package.json +86 -78
  19. package/dist/auth/authService.d.ts +0 -29
  20. package/dist/auth/authService.js +0 -114
  21. package/dist/tools/backupRestoreTools.d.ts +0 -18
  22. package/dist/tools/backupRestoreTools.js +0 -70
  23. package/dist/tools/documentationGeneratorTools.d.ts +0 -145
  24. package/dist/tools/documentationGeneratorTools.js +0 -820
  25. package/dist/tools/forecastingTools.d.ts +0 -36
  26. package/dist/tools/forecastingTools.js +0 -256
  27. package/dist/tools/functionTools.d.ts +0 -87
  28. package/dist/tools/functionTools.js +0 -358
  29. package/dist/tools/indexRecommendationTools.d.ts +0 -50
  30. package/dist/tools/indexRecommendationTools.js +0 -451
  31. package/dist/tools/intelligentQueryTools.d.ts +0 -94
  32. package/dist/tools/intelligentQueryTools.js +0 -713
  33. package/dist/tools/performanceTools.d.ts +0 -76
  34. package/dist/tools/performanceTools.js +0 -505
  35. package/dist/tools/processTools.d.ts +0 -61
  36. package/dist/tools/processTools.js +0 -181
  37. package/dist/tools/queryVisualizationTools.d.ts +0 -22
  38. package/dist/tools/queryVisualizationTools.js +0 -155
  39. package/dist/tools/schemaDesignTools.d.ts +0 -67
  40. package/dist/tools/schemaDesignTools.js +0 -359
  41. package/dist/tools/schemaPatternTools.d.ts +0 -19
  42. package/dist/tools/schemaPatternTools.js +0 -253
  43. package/dist/tools/schemaVersioningTools.d.ts +0 -138
  44. package/dist/tools/schemaVersioningTools.js +0 -1008
  45. package/dist/tools/securityAuditTools.d.ts +0 -39
  46. package/dist/tools/securityAuditTools.js +0 -319
  47. package/dist/tools/smartDiscoveryTools.d.ts +0 -163
  48. package/dist/tools/smartDiscoveryTools.js +0 -750
  49. package/dist/tools/testDataTools.d.ts +0 -26
  50. package/dist/tools/testDataTools.js +0 -325
@@ -1,114 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.authService = exports.AuthService = void 0;
7
- const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
8
- // Environment variables
9
- const JWT_SECRET = process.env.JWT_SECRET || 'default_secret_change_in_production';
10
- const JWT_EXPIRES_IN = process.env.JWT_EXPIRES_IN || '24h';
11
- const API_KEY = process.env.API_KEY;
12
- class AuthService {
13
- /**
14
- * Generate a JWT token for a user
15
- */
16
- generateToken(user) {
17
- // Cast to any to bypass TypeScript's strict type checking for JWT
18
- return jsonwebtoken_1.default.sign(user, JWT_SECRET, { expiresIn: JWT_EXPIRES_IN });
19
- }
20
- /**
21
- * Verify a JWT token
22
- */
23
- verifyToken(token) {
24
- // Cast to any to bypass TypeScript's strict type checking for JWT
25
- return jsonwebtoken_1.default.verify(token, JWT_SECRET);
26
- }
27
- /**
28
- * Middleware to authenticate using JWT
29
- */
30
- authenticateJWT(req, res, next) {
31
- const authHeader = req.headers['authorization'];
32
- const token = authHeader && authHeader.split(' ')[1];
33
- if (!token) {
34
- res.status(401).json({
35
- error: {
36
- code: 'AUTH_TOKEN_MISSING',
37
- message: 'Authentication token is required',
38
- details: 'Please provide a valid JWT token in the Authorization header'
39
- }
40
- });
41
- return;
42
- }
43
- try {
44
- const user = this.verifyToken(token);
45
- req.user = user;
46
- next();
47
- }
48
- catch (error) {
49
- res.status(403).json({
50
- error: {
51
- code: 'AUTH_TOKEN_INVALID',
52
- message: 'Invalid or expired token',
53
- details: 'Please provide a valid JWT token'
54
- }
55
- });
56
- }
57
- }
58
- /**
59
- * Middleware to authenticate using API key
60
- */
61
- authenticateApiKey(req, res, next) {
62
- const providedApiKey = req.headers['x-api-key'];
63
- if (!API_KEY) {
64
- console.warn('API_KEY environment variable is not set');
65
- res.status(500).json({
66
- error: {
67
- code: 'SERVER_CONFIG_ERROR',
68
- message: 'Server configuration error',
69
- details: 'API key authentication is not properly configured'
70
- }
71
- });
72
- return;
73
- }
74
- if (!providedApiKey || providedApiKey !== API_KEY) {
75
- res.status(401).json({
76
- error: {
77
- code: 'INVALID_API_KEY',
78
- message: 'Invalid API key',
79
- details: 'Please provide a valid API key in the X-API-Key header'
80
- }
81
- });
82
- return;
83
- }
84
- next();
85
- }
86
- /**
87
- * Login endpoint handler
88
- */
89
- login(req, res) {
90
- const { username, password } = req.body;
91
- // In a real application, you would validate credentials against a database
92
- // This is a simplified example for demonstration purposes
93
- if (username === 'admin' && password === 'password') {
94
- const user = {
95
- id: '1',
96
- username: 'admin',
97
- role: 'admin'
98
- };
99
- const token = this.generateToken(user);
100
- res.json({ token });
101
- }
102
- else {
103
- res.status(401).json({
104
- error: {
105
- code: 'INVALID_CREDENTIALS',
106
- message: 'Invalid username or password',
107
- details: 'Please check your credentials and try again'
108
- }
109
- });
110
- }
111
- }
112
- }
113
- exports.AuthService = AuthService;
114
- exports.authService = new AuthService();
@@ -1,18 +0,0 @@
1
- import SecurityLayer from "../security/securityLayer";
2
- /**
3
- * Backup and Restore Tools for MySQL MCP Server
4
- * Provides database backup (SQL dump generation) and restore functionality
5
- */
6
- export declare class BackupRestoreTools {
7
- private db;
8
- private security;
9
- constructor(security: SecurityLayer);
10
- /**
11
- * Validate database access
12
- */
13
- private validateDatabaseAccess;
14
- /**
15
- * Escape string value for SQL
16
- */
17
- private escapeValue;
18
- }
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BackupRestoreTools = void 0;
7
- const connection_1 = __importDefault(require("../db/connection"));
8
- const config_1 = require("../config/config");
9
- /**
10
- * Backup and Restore Tools for MySQL MCP Server
11
- * Provides database backup (SQL dump generation) and restore functionality
12
- */
13
- class BackupRestoreTools {
14
- constructor(security) {
15
- this.db = connection_1.default.getInstance();
16
- this.security = security;
17
- }
18
- /**
19
- * Validate database access
20
- */
21
- validateDatabaseAccess(requestedDatabase) {
22
- const connectedDatabase = config_1.dbConfig.database;
23
- if (!connectedDatabase) {
24
- return {
25
- valid: false,
26
- database: "",
27
- error: "No database configured. Please specify a database in your connection settings.",
28
- };
29
- }
30
- if (requestedDatabase && requestedDatabase !== connectedDatabase) {
31
- return {
32
- valid: false,
33
- database: "",
34
- error: `Access denied: You are connected to '${connectedDatabase}' but requested '${requestedDatabase}'. Cross-database access is not permitted.`,
35
- };
36
- }
37
- return {
38
- valid: true,
39
- database: connectedDatabase,
40
- };
41
- }
42
- /**
43
- * Escape string value for SQL
44
- */
45
- escapeValue(value) {
46
- if (value === null)
47
- return "NULL";
48
- if (typeof value === "number")
49
- return String(value);
50
- if (typeof value === "boolean")
51
- return value ? "1" : "0";
52
- if (value instanceof Date) {
53
- return `'${value.toISOString().slice(0, 19).replace("T", " ")}'`;
54
- }
55
- if (Buffer.isBuffer(value)) {
56
- return `X'${value.toString("hex")}'`;
57
- }
58
- // Escape string
59
- const escaped = String(value)
60
- .replace(/\\/g, "\\\\")
61
- .replace(/'/g, "\\'")
62
- .replace(/"/g, '\\"')
63
- .replace(/\n/g, "\\n")
64
- .replace(/\r/g, "\\r")
65
- .replace(/\t/g, "\\t")
66
- .replace(/\0/g, "\\0");
67
- return `'${escaped}'`;
68
- }
69
- }
70
- exports.BackupRestoreTools = BackupRestoreTools;
@@ -1,145 +0,0 @@
1
- import { SecurityLayer } from "../security/securityLayer";
2
- /**
3
- * AI-Powered Documentation Generator
4
- * Automatic database documentation generation with business glossary
5
- */
6
- export declare class DocumentationGeneratorTools {
7
- private db;
8
- private security;
9
- constructor(security: SecurityLayer);
10
- /**
11
- * Validate database access - ensures only the connected database can be accessed
12
- */
13
- private validateDatabaseAccess;
14
- /**
15
- * Generate comprehensive database documentation
16
- */
17
- generateDocumentation(params: {
18
- scope?: "database" | "table" | "column" | "relationship";
19
- table_name?: string;
20
- include_business_glossary?: boolean;
21
- format?: "markdown" | "html" | "json";
22
- include_examples?: boolean;
23
- include_statistics?: boolean;
24
- database?: string;
25
- }): Promise<{
26
- status: string;
27
- data?: {
28
- format: string;
29
- scope: string;
30
- content: string;
31
- metadata: {
32
- generated_at: string;
33
- database: string;
34
- tables_documented: number;
35
- columns_documented: number;
36
- };
37
- };
38
- error?: string;
39
- }>;
40
- /**
41
- * Generate data dictionary for a specific table
42
- */
43
- generateDataDictionary(params: {
44
- table_name: string;
45
- include_sample_values?: boolean;
46
- include_constraints?: boolean;
47
- database?: string;
48
- }): Promise<{
49
- status: string;
50
- data?: {
51
- table_name: string;
52
- description: string;
53
- columns: Array<{
54
- name: string;
55
- data_type: string;
56
- description: string;
57
- constraints: string[];
58
- is_nullable: boolean;
59
- default_value: string | null;
60
- sample_values?: any[];
61
- business_term?: string;
62
- }>;
63
- primary_key: string[];
64
- foreign_keys: Array<{
65
- column: string;
66
- references_table: string;
67
- references_column: string;
68
- }>;
69
- indexes: Array<{
70
- name: string;
71
- columns: string[];
72
- is_unique: boolean;
73
- }>;
74
- };
75
- error?: string;
76
- }>;
77
- /**
78
- * Generate a business glossary from the schema
79
- */
80
- generateBusinessGlossaryReport(params: {
81
- include_descriptions?: boolean;
82
- group_by?: "table" | "category" | "alphabetical";
83
- database?: string;
84
- }): Promise<{
85
- status: string;
86
- data?: {
87
- glossary: Array<{
88
- term: string;
89
- technical_name: string;
90
- source_table: string;
91
- data_type: string;
92
- description: string;
93
- category: string;
94
- related_terms?: string[];
95
- }>;
96
- categories: string[];
97
- total_terms: number;
98
- };
99
- error?: string;
100
- }>;
101
- /**
102
- * Generate business glossary from columns
103
- */
104
- private generateBusinessGlossary;
105
- /**
106
- * Get table statistics
107
- */
108
- private getTableStatistics;
109
- /**
110
- * Generate Markdown documentation
111
- */
112
- private generateMarkdown;
113
- /**
114
- * Generate HTML documentation
115
- */
116
- private generateHTML;
117
- /**
118
- * Generate JSON documentation
119
- */
120
- private generateJSON;
121
- /**
122
- * Group indexes by name
123
- */
124
- private groupIndexes;
125
- /**
126
- * Infer business term from column name
127
- */
128
- private inferBusinessTerm;
129
- /**
130
- * Infer column description from name and type
131
- */
132
- private inferColumnDescription;
133
- /**
134
- * Infer table description from name
135
- */
136
- private inferTableDescription;
137
- /**
138
- * Infer category from column name and type
139
- */
140
- private inferCategory;
141
- /**
142
- * Normalize column name for comparison
143
- */
144
- private normalizeColumnName;
145
- }