Skip to content

Add MySQL support to MCP Database Server #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 30, 2025

Conversation

executeautomation
Copy link
Owner

Updated package.json and package-lock.json to include MySQL dependencies. Enhanced README with MySQL usage instructions and configuration details. Modified index.ts to handle MySQL connection parameters and logging. Added MysqlAdapter for database interactions.

Updated package.json and package-lock.json to include MySQL dependencies. Enhanced README with MySQL usage instructions and configuration details. Modified index.ts to handle MySQL connection parameters and logging. Added MysqlAdapter for database interactions.
Copy link

⏳ I'm reviewing this pull request for security vulnerabilities and code quality issues. I'll provide an update when I'm done

*/
async init(): Promise<void> {
try {
console.error(`[INFO] Connecting to MySQL: ${this.host}, Database: ${this.database}`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Description: Log Injection occurs when untrusted user input is directly written to log files without proper sanitization. This can allow attackers to manipulate log entries, potentially leading to security issues like log forging or cross-site scripting. To prevent this, always sanitize user input before logging by removing or encoding newline characters, using string encoding functions, and leveraging built-in sanitization features of logging libraries when available. Learn more - https://cwe.mitre.org/data/definitions/117.html

Severity: High

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix involves using a sanitizeLog function (from an imported sanitize-log package) to sanitize user input before logging, preventing potential log injection vulnerabilities.

Suggested change
console.error(`[INFO] Connecting to MySQL: ${this.host}, Database: ${this.database}`);
// Import the sanitize-log package for log sanitization
async init(): Promise<void> {
try {
console.error(`[INFO] Connecting to MySQL: ${sanitizeLog(this.host)}, Database: ${sanitizeLog(this.database)}`);
this.connection = await mysql.createConnection(this.config);
console.error(`[INFO] MySQL connection established successfully`);
} catch (err) {
console.error(`[ERROR] MySQL connection error: ${sanitizeLog((err as Error).message)}`);
throw new Error(`Failed to connect to MySQL: ${sanitizeLog((err as Error).message)}`);
}
}

Copy link

✅ I finished the code review, and left comments with the issues I found. I will now generate code fix suggestions.

kartmcad added 2 commits May 31, 2025 08:32
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.
Bumped version to 1.1.0 in index.ts and package.json. Updated README and connection reference documentation to include MySQL port option and usage examples. Added release notes for new features and improvements related to MySQL support.
@executeautomation executeautomation merged commit b0cc71e into main May 30, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants