@cainli/mcp-server-mysql 2.0.14 → 2.0.16

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 (2) hide show
  1. package/dist/index.js +7 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -172,13 +172,19 @@ export default function createMcpServer({ sessionId, config, }) {
172
172
  }
173
173
  let columnsQuery = "SELECT column_name, data_type FROM information_schema.columns WHERE table_name = ?";
174
174
  let queryParams = [tableName];
175
- const schemaName = dbName || (!isMultiDbMode ? mcpConfig.mysql.database : null);
175
+ let schemaName = dbName;
176
+ if (!schemaName && !isMultiDbMode && mcpConfig.mysql.database) {
177
+ schemaName = mcpConfig.mysql.database;
178
+ }
176
179
  if (!/^[a-zA-Z0-9_]+$/.test(tableName)) {
177
180
  throw new Error(`Invalid table name: ${tableName}`);
178
181
  }
179
182
  if (schemaName && !/^[a-zA-Z0-9_]+$/.test(schemaName)) {
180
183
  throw new Error(`Invalid schema name: ${schemaName}`);
181
184
  }
185
+ if (!isMultiDbMode && !schemaName) {
186
+ throw new Error(`In single-DB mode, a schema/database must be specified. Configured database: ${mcpConfig.mysql.database || 'none'}`);
187
+ }
182
188
  if (schemaName) {
183
189
  columnsQuery += " AND table_schema = ?";
184
190
  queryParams.push(schemaName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cainli/mcp-server-mysql",
3
- "version": "2.0.14",
3
+ "version": "2.0.16",
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)",