AgentStack
MCP verified MIT Self-run

Mysql Mcp

mcp-az-coder-123-mysql-mcp · by az-coder-123

Secure MySQL MCP Server with Clean Architecture. Enables AI assistants (Cursor, Copilot, Cline) to safely interact with MySQL/MariaDB databases, featuring RBAC, audit logging, and intelligent query validation.

No reviews yet
0 installs
12 views
0.0% view→install

Install

$ agentstack add mcp-az-coder-123-mysql-mcp

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets Used
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Mysql Mcp? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

MySQL MCP Server

A secure and professional MySQL Model Context Protocol (MCP) server with clean architecture, designed for seamless integration with GitHub Copilot, Cline, and other AI coding assistants in VS Code.

Features

  • Clean Architecture: Follows Single Responsibility Principle for maintainability and scalability
  • Security First: Built-in permission system, audit logging, and query validation
  • Connection Pooling: Efficient MySQL connection management with connection pooling
  • Schema Inspection: Tools for exploring database structure
  • Query Execution: Secure SQL query execution with timeout controls
  • Audit Logging: Comprehensive logging of all database operations

Quick Start

Installation

npm install

Configuration

Copy the example configuration and update credentials:

cp .env.example .env

Then edit .env in the project root:

# MySQL Connection
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=your_username
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=your_database

# Security Settings
SECURITY_ENABLED=true
ALLOWED_OPERATIONS=SELECT,SHOW,DESCRIBE,EXPLAIN
MAX_QUERY_EXECUTION_TIME=30000

# Audit Settings
AUDIT_ENABLED=true
AUDIT_LOG_LEVEL=info

Build

npm run build

Run

npm start

Integration with VS Code

GitHub Copilot

Recommended for this repository: use the workspace MCP file at .vscode/mcp.json.

It is already included in this project and should look like:

{
  "servers": {
    "mysql-local": {
      "type": "stdio",
      "command": "node",
      "args": ["${workspaceFolder}/dist/index.js"],
      "env": {
        "MYSQL_HOST": "${env:MYSQL_HOST}",
        "MYSQL_PORT": "${env:MYSQL_PORT}",
        "MYSQL_USER": "${env:MYSQL_USER}",
        "MYSQL_PASSWORD": "${env:MYSQL_PASSWORD}",
        "MYSQL_DATABASE": "${env:MYSQL_DATABASE}"
      }
    }
  }
}

Alternative: add to VS Code user settings (settings.json):

{
  "mcpServers": {
    "mysql": {
      "command": "node",
      "args": ["/path/to/mysql-mcp/dist/index.js"],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

Cline

Configure in Cline settings:

{
  "mcpServers": {
    "mysql": {
      "command": "node",
      "args": ["/path/to/mysql-mcp/dist/index.js"],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

Available Tools

Query Tools

execute_query

Execute SQL queries against the database.

Parameters:

  • sql (required): SQL query to execute
  • database (optional): Database name
  • userId (optional): User ID for permission checking
  • timeout (optional): Query timeout in milliseconds

Schema Tools

list_databases

List all available databases.

Parameters:

  • userId (optional): User ID for permission checking
list_tables

List all tables in a database.

Parameters:

  • database (optional): Database name
  • userId (optional): User ID for permission checking
describe_table

Get the structure of a table.

Parameters:

  • table (required): Table name
  • database (optional): Database name
  • userId (optional): User ID for permission checking

Admin Tools

getserverstatus

Get MySQL server status variables.

Parameters:

  • userId (optional): User ID for permission checking
getprocesslist

Get list of running MySQL processes.

Parameters:

  • userId (optional): User ID for permission checking
kill_query

Kill a running MySQL process.

Parameters:

  • processId (required): Process ID to kill
  • userId (optional): User ID for permission checking
gettableindexes

Get index information for a table.

Parameters:

  • table (required): Table name
  • database (optional): Database name
  • userId (optional): User ID for permission checking
gettableconstraints

Get constraint information for a table.

Parameters:

  • table (required): Table name
  • database (optional): Database name
  • userId (optional): User ID for permission checking
analyze_table

Analyze table statistics.

Parameters:

  • table (required): Table name
  • database (optional): Database name
  • userId (optional): User ID for permission checking
optimize_table

Optimize a table.

Parameters:

  • table (required): Table name
  • database (optional): Database name
  • userId (optional): User ID for permission checking

RBAC Tools

All RBAC tools require authentication and API key permission rbac_admin.

Role and Permission Management
  • create_role(name, desc)
  • delete_role(id)
  • list_roles()
  • create_permission(name, desc)
  • list_permissions()
  • assign_permission_to_role(roleId, permId)
  • revoke_permission_from_role(roleId, permId)
User Role Assignment
  • assign_role_to_user(userId, roleId)
  • revoke_role_from_user(userId, roleId)
  • list_user_roles(userId)
Authorization Checks
  • check_user_permission(userId, permissionName)
  • current_user_permissions()
  • can_access(userId, resource, action, attributes?)
RBAC Audit
  • audit_log(event, actor, target, details)
  • query_audit_logs(filter)
RBAC Database Operations
  • db_migrate_rbac()
  • db_seed_rbac_defaults()
  • db_check_integrity()

Available Resources

mysql://status

Current database connection status and pool information.

mysql://config

Server configuration (sanitized, no sensitive data).

mysql://audit/statistics

Statistics about database operations.

mysql://audit/logs

Recent database operation logs.

Architecture

src/
├── config/           # Configuration management
├── mysql/            # MySQL connection management
├── security/         # Permission and audit logging
├── tools/            # MCP tools implementation
├── resources/        # MCP resources
├── types/            # TypeScript type definitions
└── index.ts          # Main entry point

Key Components

  1. ConfigManager: Handles configuration loading and validation
  2. MySQLConnectionManager: Manages connection pooling and query execution
  3. PermissionManager: Handles permission checking and access control
  4. AuditLogger: Logs all database operations for security
  5. QueryTool: Executes SQL queries with security validation
  6. SchemaTool: Inspects database schema
  7. DatabaseResource: Provides MCP resources

Security

  • Permission-based access control
  • Query timeout enforcement
  • Operation whitelisting/blacklisting
  • Audit logging of all operations
  • Rate limiting support

See [docs/security.md](docs/security.md) for detailed security documentation.

Documentation

  • [Getting Started](docs/getting-started.md)
  • [Configuration](docs/configuration.md)
  • [Security](docs/security.md)
  • [Tools Reference](docs/tools.md)
  • [Resources Reference](docs/resources.md)
  • [Integration Guide](docs/integration.md)

Development

# Install dependencies
npm install

# Run in development mode
npm run dev

# Build
npm run build

# Lint
npm run lint

# Format
npm run format

Requirements

  • Node.js >= 18.0.0
  • MySQL 5.7+ or MariaDB 10.3+

License

MIT License - see [LICENSE](LICENSE) file for details.

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting pull requests.

Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.