@cainli/mcp-server-mysql 2.0.17 → 2.0.18

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.
@@ -36,6 +36,7 @@ function validateInfoSchemaQuery(sql, requiredDb) {
36
36
  return { valid: true };
37
37
  }
38
38
  const normalizedSql = sql.replace(/\s+/g, " ").trim().toLowerCase();
39
+ const normalizedRequiredDb = requiredDb.toLowerCase().replace(/`/g, "");
39
40
  const infoSchemaPatterns = [
40
41
  /from\s+information_schema\.tables\b/,
41
42
  /from\s+information_schema\.`tables`\b/,
@@ -46,16 +47,25 @@ function validateInfoSchemaQuery(sql, requiredDb) {
46
47
  if (!targetsInfoSchemaTables) {
47
48
  return { valid: true };
48
49
  }
49
- const hasTableSchemaFilter = normalizedSql.includes("table_schema") &&
50
- (normalizedSql.includes("=") ||
51
- normalizedSql.includes("in") ||
52
- normalizedSql.includes("?"));
53
- if (hasTableSchemaFilter) {
50
+ const hasRequiredDbFilter = (normalizedSql.includes("table_schema") &&
51
+ (normalizedSql.includes(`table_schema = '${normalizedRequiredDb}'`) ||
52
+ normalizedSql.includes(`table_schema = "${normalizedRequiredDb}"`) ||
53
+ normalizedSql.includes(`table_schema = \`${normalizedRequiredDb}\``) ||
54
+ normalizedSql.includes(`table_schema='${normalizedRequiredDb}'`) ||
55
+ normalizedSql.includes(`table_schema="${normalizedRequiredDb}"`) ||
56
+ normalizedSql.includes(`table_schema=\`${normalizedRequiredDb}\``) ||
57
+ normalizedSql.includes("table_schema") &&
58
+ normalizedSql.includes("=") &&
59
+ normalizedSql.includes("?"))) ||
60
+ (normalizedSql.includes("table_schema") &&
61
+ normalizedSql.includes("in") &&
62
+ normalizedSql.includes(`'${normalizedRequiredDb}'`));
63
+ if (hasRequiredDbFilter) {
54
64
  return { valid: true };
55
65
  }
56
66
  return {
57
67
  valid: false,
58
- reason: `Querying information_schema.tables requires a database filter. Please add 'WHERE table_schema = '${requiredDb}'' to your query. Required database: ${requiredDb}`,
68
+ reason: `Querying information_schema.tables requires a database filter for '${requiredDb}'. Please add 'WHERE table_schema = '${requiredDb}'' to your query.`,
59
69
  };
60
70
  }
61
71
  export { extractSchemaFromQuery, getQueryTypes, validateInfoSchemaQuery };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cainli/mcp-server-mysql",
3
- "version": "2.0.17",
3
+ "version": "2.0.18",
4
4
  "description": "MCP server for interacting with MySQL databases with write operations support",
5
5
  "license": "MIT",
6
6
  "author": "cainli (https://github.com/cainli)",