Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jul 25, 2025

This PR implements a MySQL MCP (Model Context Protocol) server as requested in #6201.

Summary

Added a new package @roo-code/mcp-server-mysql that provides MySQL database operations through the MCP protocol.

Features

  • Connection pooling for efficient database resource management
  • Query execution tools:
    • query - Execute SELECT queries safely
    • execute - Execute INSERT, UPDATE, DELETE, and DDL operations
    • list_databases - List all databases
    • list_tables - List tables in a database
    • describe_table - Get table structure
    • test_connection - Test database connectivity
  • Security considerations:
    • Separation of read (query) and write (execute) operations
    • Connection configuration via environment variables
  • TypeScript support with full type definitions
  • Comprehensive documentation in README.md

Configuration

The server uses environment variables for configuration:

  • MYSQL_HOST - MySQL server host (default: localhost)
  • MYSQL_PORT - MySQL server port (default: 3306)
  • MYSQL_USER - MySQL username (default: root)
  • MYSQL_PASSWORD - MySQL password
  • MYSQL_DATABASE - Default database (optional)

Testing

Basic test structure is included. The implementation follows the project's patterns and conventions.

Closes #6201


Important

Adds @roo-code/mcp-server-mysql package for MySQL operations via MCP with connection pooling, query tools, and TypeScript support.

  • New Package:
    • Adds @roo-code/mcp-server-mysql for MySQL operations via MCP.
  • Features:
    • Connection pooling for resource management.
    • Query tools: query, execute, list_databases, list_tables, describe_table, test_connection.
    • Security: separates read (query) and write (execute) operations.
    • TypeScript support with type definitions.
  • Configuration:
    • Uses environment variables: MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE.
  • Testing:
    • Basic tests in index.test.ts for server instance and tool registration.
  • Misc:
    • Documentation in README.md.
    • ESLint configuration in eslint.config.mjs.
    • Package metadata in package.json.

This description was created by Ellipsis for 1a42981. You can customize this summary. It will automatically update as commits are pushed.

- Implement MySQL MCP server with connection pooling
- Add tools for query execution, database/table listing, and schema inspection
- Support both SELECT queries and data modification operations
- Include comprehensive documentation and TypeScript types
- Add basic test structure

Closes #6201
@roomote roomote bot requested review from cte, jr and mrubens as code owners July 25, 2025 05:35
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. documentation Improvements or additions to documentation enhancement New feature or request labels Jul 25, 2025
@roomote roomote bot mentioned this pull request Jul 25, 2025
1 task
await connection.changeUser({ database })
}

const [rows, fields] = (await connection.execute(`DESCRIBE ${table}`)) as [
Copy link
Contributor

Choose a reason for hiding this comment

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

Potential SQL injection risk: the table name is interpolated directly in the DESCRIBE query. Consider sanitizing it (e.g., using mysql.escapeId() or validating allowed characters).

Suggested change
const [rows, fields] = (await connection.execute(`DESCRIBE ${table}`)) as [
const [rows, fields] = (await connection.execute(`DESCRIBE ${mysql.escapeId(table)}`)) as [

if (database) {
await connection.changeUser({ database })
}

Copy link
Contributor

Choose a reason for hiding this comment

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

For the 'execute' tool, dynamic SQL is executed directly. Consider advising users to use parameterized queries or proper sanitization when constructing dynamic SQL to prevent injection risks.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 25, 2025
@daniel-lxs
Copy link
Member

Not what the issue was created for

@daniel-lxs daniel-lxs closed this Jul 28, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jul 28, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

MySQL

4 participants