mirror of
https://github.com/executeautomation/mcp-database-server.git
synced 2025-12-09 21:12:57 +08:00
Validate and log MySQL connection port in MysqlAdapter
Added validation for the MySQL connection port to ensure it is a number, with error handling for invalid values. Included a debug log statement to output the port being used for the connection.
This commit is contained in:
@@ -35,6 +35,16 @@ export class MysqlAdapter implements DbAdapter {
|
||||
} else if (connectionInfo.ssl === true) {
|
||||
this.config.ssl = {};
|
||||
}
|
||||
// Validate port
|
||||
if (connectionInfo.port && typeof connectionInfo.port !== 'number') {
|
||||
const parsedPort = parseInt(connectionInfo.port as any, 10);
|
||||
if (isNaN(parsedPort)) {
|
||||
throw new Error(`Invalid port value for MySQL: ${connectionInfo.port}`);
|
||||
}
|
||||
this.config.port = parsedPort;
|
||||
}
|
||||
// Log the port for debugging
|
||||
console.error(`[DEBUG] MySQL connection will use port: ${this.config.port}`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user