New:Microsoft Teams Notifications Are Now Available in Socket.Learn more β†’
Get Started

@neverinfamous/mysql-mcp

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neverinfamous/mysql-mcp

Enterprise-grade MySQL MCP Server with OAuth 2.0 authentication, connection pooling & tool filtering

Source
npmnpm
Version
3.2.1
Version published
Weekly downloads
51
-42.05%
Maintainers
1
Weekly downloads
Β 
Created
Source

mysql-mcp

GitHub License: MIT CodeQL npm version Docker Pulls Security TypeScript Tests E2E Coverage

πŸ“š Full Documentation (Wiki) β€’ Changelog β€’ Security β€’ Release Article

The Most Comprehensive MySQL MCP Server Available

mysql-mcp is the definitive Model Context Protocol server for MySQL β€” empowering AI assistants like AntiGravity, Claude, Cursor, and other MCP clients with unparalleled database capabilities. Features Code Mode β€” a revolutionary approach that provides access to all 224 tools through a single JavaScript sandbox, eliminating the massive token overhead of multi-step tool calls. Also includes deterministic error handling, process-isolated code execution, and enterprise-grade features without sacrificing ease of use.

🎯 What Sets Us Apart

FeatureDescription
224 Specialized ToolsThe largest MySQL tool collection for MCP β€” from core CRUD and native JSON functions (MySQL 5.7+) to advanced spatial/GIS, document store, and cluster management
18 Observability ResourcesReal-time schema, performance metrics, process lists, status variables, replication status, and InnoDB diagnostics
19 AI-Powered PromptsGuided workflows for query building, schema design, performance tuning, and infrastructure setup
Code Mode (Massive Token Savings)Execute complex operations locally inside a separate V8 isolate (worker_threads). Instead of spending thousands of tokens on back-and-forth tool calls, Code Mode exposes all 224 capabilities locally, reducing token overhead by up to 90% while supercharging AI agent reasoning.
Token-Optimized PayloadsEvery tool response is audited for token efficiency. Tools with large payloads offer optional flags (summary, limit, compact) to reduce response size β€” monitoring, sysschema, stats, spatial, and cluster tools all support payload reduction
OAuth 2.1 + Access ControlEnterprise-ready security with RFC 9728/8414 compliance, granular scopes (read, write, admin, full, db:*, table:*:*), and Keycloak integration
Smart Tool Filtering25 tool groups + 11 shortcuts let you stay within IDE limits while exposing exactly what you need
Dual HTTP TransportStreamable HTTP (/mcp) for modern clients + legacy SSE (/sse) for backward compatibility β€” both protocols supported simultaneously with session management, security headers, CORS, rate limiting, and body size enforcement
High-Performance PoolingBuilt-in connection pooling for efficient, concurrent database access
Ecosystem IntegrationsFirst-class support for MySQL Router, ProxySQL, and MySQL Shell utilities
Advanced EncryptionFull TLS/SSL support for secure connections, plus tools for managing data masking, encryption monitoring, and compliance
Production-Ready SecuritySQL injection protection, parameterized queries, input validation, and audit capabilities
Deterministic Error HandlingEvery tool returns structured {success, error, code, category, suggestion, recoverable} responses β€” no raw exceptions, no silent failures, no misleading messages. Agents get actionable context instead of cryptic MySQL error codes
Strict TypeScript100% type-safe codebase with 2185 tests and 90% coverage
MCP 2025-11-25 CompliantFull protocol support with tool safety hints, resource priorities, and progress notifications

πŸš€ Quick Start

Prerequisites

  • Node.js 24+
  • MySQL 5.7+ or 8.0+ server
  • npm or yarn

Installation

npm install -g @neverinfamous/mysql-mcp

Run the server:

mysql-mcp --transport stdio --mysql mysql://user:password@localhost:3306/database

Or use npx without installing:

npx @neverinfamous/mysql-mcp --transport stdio --mysql mysql://user:password@localhost:3306/database

Docker

docker run -i --rm writenotenow/mysql-mcp:latest \
  --transport stdio \
  --mysql mysql://user:password@host.docker.internal:3306/database

From Source

git clone https://github.com/neverinfamous/mysql-mcp.git
cd mysql-mcp
npm install
npm run build
node dist/cli.js --transport stdio --mysql mysql://user:password@localhost:3306/database

Code Mode: Maximum Efficiency

Code Mode (mysql_execute_code) dramatically reduces token usage (70–90%) and is included by default in all presets.

Code executes in a worker-thread sandbox β€” a separate V8 isolate with its own memory space. All mysql.* API calls are forwarded to the main thread via a MessagePort-based RPC bridge, where the actual database operations execute. This provides:

  • Process-level isolation β€” user code runs in a separate V8 instance with enforced heap limits
  • Readonly enforcement β€” when readonly: true, write methods return structured errors instead of executing
  • Hard timeouts β€” worker termination if execution exceeds the configured limit
  • Full API access β€” all 25 tool groups are available via mysql.* (e.g., mysql.core.readQuery(), mysql.json.extract())

Set CODEMODE_ISOLATION=vm to fall back to the in-process vm module sandbox if needed.

⚑ Code Mode Only (Maximum Token Savings)

If you control your own setup, you can run with only Code Mode enabled β€” a single tool that provides access to all 224 tools' worth of capability through the mysql.* API:

{
  "mcpServers": {
    "mysql-mcp": {
      "command": "node",
      "args": [
        "/path/to/mysql-mcp/dist/cli.js",
        "--transport",
        "stdio",
        "--tool-filter",
        "codemode"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_user",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

This exposes just mysql_execute_code. The agent writes JavaScript against the typed mysql.* SDK β€” composing queries, chaining operations across all 25 tool groups, and returning exactly the data it needs β€” in one execution. This mirrors the Code Mode pattern pioneered by Cloudflare for their entire API: fixed token cost regardless of how many capabilities exist.

[!TIP] Maximize Token Savings: Instruct your AI agent to prefer Code Mode over individual tool calls:

"When using mysql-mcp, prefer mysql_execute_code (Code Mode) for multi-step database operations to minimize token usage."

For maximum savings, use --tool-filter codemode to run with Code Mode as your only tool. See the Code Mode wiki for full API documentation.

⚑ MCP Client Configuration

HTTP/SSE Server Usage (Advanced)

When to use HTTP mode: Use HTTP mode when deploying mysql-mcp as a standalone server that multiple clients can connect to remotely. For local development with Claude Desktop or Cursor IDE, use the default stdio mode shown below instead.

Use cases for HTTP mode:

  • Running the server in a Docker container accessible over a network
  • Deploying to cloud platforms (AWS, GCP, Azure)
  • Enabling OAuth 2.1 authentication for enterprise security
  • Allowing multiple AI clients to share one database connection

Authentication

mysql-mcp supports two authentication modes for HTTP transport:

Simple Bearer Token

Lightweight authentication for development or single-tenant deployments:

mysql-mcp --transport http --port 3000 --auth-token my-secret --mysql mysql://root:pass@localhost/db

# Or via environment variable
export MCP_AUTH_TOKEN=my-secret
mysql-mcp --transport http --port 3000 --mysql mysql://root:pass@localhost/db

Clients must include Authorization: Bearer <token> on all requests. /health and / are exempt.

For enterprise deployments, mysql-mcp supports OAuth 2.1 authentication with Keycloak or any RFC-compliant provider.

Quick Setup

1. Start with OAuth disabled (default)

mysql-mcp --mysql mysql://root:pass@localhost/db

2. Enable OAuth with an identity provider

mysql-mcp --mysql mysql://root:pass@localhost/db \
          --oauth-enabled \
          --oauth-issuer http://localhost:8080/realms/mysql-mcp \
          --oauth-audience mysql-mcp

Start the HTTP server:

Local installation:

node dist/cli.js --transport http --port 3000 --server-host 0.0.0.0 --mysql mysql://user:password@localhost:3306/database

Docker (expose port 3000):

docker run -p 3000:3000 writenotenow/mysql-mcp \
  --transport http \
  --port 3000 \
  --server-host 0.0.0.0 \
  --mysql mysql://user:password@host.docker.internal:3306/database

The server supports two MCP transport protocols simultaneously, enabling both modern and legacy clients to connect.

In stateless mode (--stateless): GET /mcp returns 405, DELETE /mcp returns 204, /sse and /messages return 404. Each POST /mcp creates a fresh transport with no session persistence. Ideal for serverless or stateless deployments.

Modern protocol (MCP 2025-03-26) β€” single endpoint, session-based:

MethodEndpointPurpose
POST/mcpJSON-RPC requests (initialize, tools/list, etc.)
GET/mcpSSE stream for server notifications
DELETE/mcpSession termination

Sessions are managed via the Mcp-Session-Id header.

Legacy SSE (Backward Compatibility)

Legacy protocol (MCP 2024-11-05) β€” for older MCP clients:

MethodEndpointPurpose
GET/sseOpens SSE stream, returns /messages?sessionId=<id> endpoint
POST/messages?sessionId=<id>Send JSON-RPC messages to the session

Utility Endpoints

MethodEndpointPurpose
GET/healthHealth check (database connectivity)
GET/.well-known/oauth-protected-resourceOAuth 2.1 metadata (when OAuth enabled)

Security Features

All HTTP responses include security headers:

  • X-Content-Type-Options: nosniff
  • X-Frame-Options: DENY
  • Cache-Control: no-store, no-cache, must-revalidate
  • Content-Security-Policy: default-src 'none'; frame-ancestors 'none'
  • Permissions-Policy: camera=(), microphone=(), geolocation=()
  • Referrer-Policy: no-referrer
  • Optional HSTS for HTTPS deployments

Additional protections:

  • Server Timeouts β€” Request (120s), keep-alive (65s), and headers (66s) timeouts prevent Slowloris DoS attacks
  • Configurable CORS β€” Exact origins and wildcard subdomain patterns (*.example.com)
  • Per-IP Rate Limiting β€” Sliding-window rate limiter with Retry-After header on 429 responses; /health endpoint bypasses rate limiting for monitoring probes
  • Trust Proxy β€” trustProxy option reads X-Forwarded-For for accurate client IP behind reverse proxies
  • Body Size Enforcement β€” Request body size limit (default 1 MB)

πŸ’‘ Tip: Most users should skip this section and use the stdio configuration below for local AI IDE integration.

Cursor IDE / Claude Desktop

{
  "mcpServers": {
    "mysql-mcp": {
      "command": "node",
      "args": [
        "C:/path/to/mysql-mcp/dist/cli.js",
        "--transport",
        "stdio",
        "--mysql",
        "mysql://user:password@localhost:3306/database"
      ]
    }
  }
}
{
  "mcpServers": {
    "mysql-mcp": {
      "command": "node",
      "args": ["C:/path/to/mysql-mcp/dist/cli.js", "--transport", "stdio"],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_user",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database",
        "MYSQL_XPORT": "33060"
      }
    }
  }
}

Note: MYSQL_XPORT (X Protocol port) defaults to 33060 if omitted. Only needed for mysqlsh_import_json and docstore tools. Set to your MySQL Router X Protocol port (e.g., 6448) when using InnoDB Cluster.

πŸ“– See the Configuration Wiki for more configuration options.

πŸ”— Database Connection Scenarios

ScenarioHost to UseExample Connection String
MySQL on host machinehost.docker.internalmysql://user:pass@host.docker.internal:3306/db
MySQL in DockerContainer name or networkmysql://user:pass@mysql-container:3306/db
Remote/Cloud MySQLHostname or IPmysql://user:pass@db.example.com:3306/db

MySQL on Host Machine

If MySQL is installed directly on your computer (via installer, Homebrew, etc.):

"--mysql", "mysql://user:password@host.docker.internal:3306/database"

MySQL in Another Docker Container

Add both containers to the same Docker network, then use the container name:

Create a network and run MySQL:

docker network create mynet
docker run -d --name mysql-db --network mynet -e MYSQL_ROOT_PASSWORD=pass mysql:8

Run MCP server on the same network:

docker run -i --rm --network mynet writenotenow/mysql-mcp:latest \
  --transport stdio --mysql mysql://root:pass@mysql-db:3306/mysql

Remote/Cloud MySQL (RDS, Cloud SQL, etc.)

Use the remote hostname directly:

"--mysql", "mysql://user:password@your-instance.region.rds.amazonaws.com:3306/database"
ProviderExample Hostname
AWS RDSyour-instance.xxxx.us-east-1.rds.amazonaws.com
Google Cloud SQLproject:region:instance (via Cloud SQL Proxy)
Azure MySQLyour-server.mysql.database.azure.com
PlanetScaleaws.connect.psdb.cloud (SSL required)
DigitalOceanyour-cluster-do-user-xxx.db.ondigitalocean.com

Tip: For remote connections, ensure your MySQL server allows connections from Docker's IP range and that firewalls/security groups permit port 3306.

πŸ› οΈ Tool Filtering

[!IMPORTANT] AI IDEs like Cursor have tool limits (typically 40-50 tools). With 224 tools available, you MUST use tool filtering to stay within your IDE's limits. All shortcuts and tool groups include Code Mode (mysql_execute_code) by default for token-efficient operations. To exclude it, add -codemode to your filter: --tool-filter core,json,-codemode

What Can You Filter?

The --tool-filter argument accepts shortcuts, groups, or tool names β€” mix and match freely:

Filter PatternExampleToolsDescription
Shortcut onlystarter39Use a predefined bundle
Groups onlycore,json,transactions33Combine individual groups
Shortcut + Groupstarter,spatial51Extend a shortcut
Shortcut - Toolstarter,-mysql_drop_table38Remove specific tools

Shortcuts (Predefined Bundles)

ShortcutToolsUse CaseWhat's Included
starter39Standard Packagecore, json, transactions, text, codemode
essential16Minimal footprintcore, transactions, codemode
dev-power47Power Developercore, schema, performance, stats, fulltext, transactions, codemode
ai-data46AI Data Analystcore, json, docstore, text, fulltext, codemode
ai-spatial44AI Spatial Analystcore, spatial, stats, performance, transactions, codemode
dba-monitor36DBA Monitoringcore, monitoring, performance, sysschema, optimization, codemode
dba-manage34DBA Managementcore, admin, backup, replication, partitioning, events, codemode
dba-secure33DBA Securitycore, security, roles, transactions, codemode
dba-schema32DBA Schemacore, schema, introspection, migration, codemode
base-core49Base Opscore, json, transactions, text, schema, codemode
base-advanced41Advanced Featuresdocstore, spatial, stats, fulltext, events, codemode
ecosystem41External Toolscluster, proxysql, router, shell, codemode

Tool Groups (25 Available)

Note: Tool counts below do NOT include Code Mode (mysql_execute_code), which is automatically added to all groups.

GroupToolsDescription
codemode1Code Mode (sandboxed code execution) 🌟 Recommended
core8Read/write queries, tables, indexes
transactions7BEGIN, COMMIT, ROLLBACK, savepoints
json17JSON functions, merge, diff, stats
text6REGEXP, LIKE, SOUNDEX
fulltext5Natural language & boolean search
performance8EXPLAIN, query analysis, slow queries
optimization4Index hints, recommendations
admin6OPTIMIZE, ANALYZE, CHECK
monitoring7PROCESSLIST, status variables
backup4Export, import, mysqldump
replication5Master/slave, binlog
partitioning4Partition management
schema11Views, procedures, triggers, constraints
shell10MySQL Shell utilities
events6Event Scheduler management
sysschema8sys schema diagnostics
stats8Statistical analysis tools
spatial12Spatial/GIS operations
security9Audit, SSL, encryption, masking
roles8MySQL 8.0 role management
docstore9Document Store collections
cluster10Group Replication, InnoDB Cluster
proxysql11ProxySQL management
router9MySQL Router REST API

Add one of these configurations to your IDE's MCP settings file (e.g., cline_mcp_settings.json, .cursorrules, or equivalent):

Best for: General MySQL database work with an AI agent. Exposes a single tool (mysql_execute_code) that provides access to all 224 tools via a JavaScript sandbox.

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

Option 2: Cluster (11 Tools for InnoDB Cluster Monitoring)

Best for: Monitoring InnoDB Cluster, Group Replication status, and cluster topology.

⚠️ Prerequisites:

  • InnoDB Cluster must be configured and running with Group Replication enabled
  • Connect to a cluster node directly (e.g., localhost:3307) β€” NOT a standalone MySQL instance
  • Use cluster_admin or root user with appropriate privileges
  • See MySQL Ecosystem Setup Guide for cluster setup instructions
{
  "mcpServers": {
    "mysql-mcp-cluster": {
      "command": "node",
      "args": [
        "/path/to/mysql-mcp/dist/cli.js",
        "--transport",
        "stdio",
        "--tool-filter",
        "cluster"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3307",
        "MYSQL_USER": "cluster_admin",
        "MYSQL_PASSWORD": "cluster_password",
        "MYSQL_DATABASE": "mysql"
      }
    }
  }
}

Option 3: Ecosystem (41 Tools for InnoDB Cluster Deployments)

Best for: MySQL Router, ProxySQL, MySQL Shell, and InnoDB Cluster deployments.

⚠️ Prerequisites:

  • InnoDB Cluster with MySQL Router requires the cluster to be running for Router REST API authentication (uses metadata_cache backend)
  • Router REST API uses HTTPS with self-signed certificates by default β€” set MYSQL_ROUTER_INSECURE=true to bypass certificate verification
  • X Protocol: InnoDB Cluster includes the MySQL X Plugin by default. Set MYSQL_XPORT to the Router's X Protocol port (e.g., 6448) for mysqlsh_import_json and docstore tools
  • See MySQL Ecosystem Setup Guide for detailed instructions
{
  "mcpServers": {
    "mysql-mcp-ecosystem": {
      "command": "node",
      "args": [
        "/path/to/mysql-mcp/dist/cli.js",
        "--transport",
        "stdio",
        "--tool-filter",
        "ecosystem"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3307",
        "MYSQL_XPORT": "6448",
        "MYSQL_USER": "cluster_admin",
        "MYSQL_PASSWORD": "cluster_password",
        "MYSQL_DATABASE": "testdb",
        "MYSQL_ROUTER_URL": "https://localhost:8443",
        "MYSQL_ROUTER_USER": "rest_api",
        "MYSQL_ROUTER_PASSWORD": "router_password",
        "MYSQL_ROUTER_INSECURE": "true",
        "PROXYSQL_HOST": "localhost",
        "PROXYSQL_PORT": "6032",
        "PROXYSQL_USER": "radmin",
        "PROXYSQL_PASSWORD": "radmin",
        "MYSQLSH_PATH": "/usr/local/bin/mysqlsh"
      }
    }
  }
}

Customization Notes:

  • Replace /path/to/mysql-mcp/ with your actual installation path
  • Update credentials with your actual values
  • For Windows: Use forward slashes (e.g., C:/mysql-mcp/dist/cli.js) or escape backslashes
  • For Windows MySQL Shell: "MYSQLSH_PATH": "C:\\Program Files\\MySQL\\MySQL Shell 9.5\\bin\\mysqlsh.exe"
  • Router Authentication: Router REST API authenticates against the InnoDB Cluster metadata. The cluster must be running for authentication to work.
  • Cluster Resource: The mysql://cluster resource is only available when connected to an InnoDB Cluster node

Legacy Syntax (still supported): If you start with a negative filter (e.g., -ecosystem), it assumes you want to start with all tools enabled and then subtract.

Syntax Reference

PrefixTargetExampleEffect
(none)ShortcutstarterWhitelist Mode: Enable ONLY this shortcut
(none)GroupcoreWhitelist Mode: Enable ONLY this group
(none)Toolmysql_read_queryWhitelist Mode: Enable ONLY this tool
+Group+spatialAdd tools from this group to current set
-Group-adminRemove tools in this group from current set
+Tool+mysql_explainAdd one specific tool
-Tool-mysql_drop_tableRemove one specific tool

Custom Tool Selection

You can list individual tool names (without + prefix) to create a fully custom whitelist β€” only the tools you specify will be enabled:

# Enable exactly 3 tools (whitelist mode)
--tool-filter "mysql_read_query,mysql_write_query,mysql_list_tables"

# Mix tools from different groups
--tool-filter "mysql_read_query,mysql_explain,mysql_json_extract"

# Combine with a shortcut or group
--tool-filter "starter,+mysql_spatial_distance,+mysql_json_diff"

This is useful for scripted or automated clients that need a minimal, precise set of capabilities.

πŸ“– See the Tool Filtering Wiki for advanced examples.

πŸ€– AI-Powered Prompts

This server includes 19 intelligent prompts for guided workflows:

PromptDescription
mysql_query_builderConstruct SQL queries with security best practices
mysql_schema_designDesign table schemas with indexes and relationships
mysql_performance_analysisAnalyze slow queries with optimization recommendations
mysql_migrationGenerate migration scripts with rollback options
mysql_database_health_checkComprehensive database health assessment
mysql_backup_strategyEnterprise backup planning with RTO/RPO
mysql_index_tuningIndex analysis and optimization workflow
mysql_setup_routerMySQL Router configuration guide
mysql_setup_proxysqlProxySQL configuration guide
mysql_setup_replicationReplication setup guide
mysql_setup_shellMySQL Shell usage guide
mysql_tool_indexComplete tool index with categories
mysql_quick_queryQuick query execution shortcut
mysql_quick_schemaQuick schema exploration
mysql_setup_eventsEvent Scheduler setup guide
mysql_sys_schema_guidesys schema usage and diagnostics
mysql_setup_spatialSpatial/GIS data setup guide
mysql_setup_clusterInnoDB Cluster/Group Replication guide
mysql_setup_docstoreDocument Store / X DevAPI guide

πŸ“Š Resources

This server exposes 18 resources for database observability:

ResourceDescription
mysql://schemaFull database schema
mysql://tablesTable listing with metadata
mysql://variablesServer configuration variables
mysql://statusServer status metrics
mysql://processlistActive connections and queries
mysql://poolConnection pool statistics
mysql://capabilitiesServer version, features, tool categories
mysql://healthComprehensive health status
mysql://performanceQuery performance metrics
mysql://indexesIndex usage and statistics
mysql://replicationReplication status and lag
mysql://innodbInnoDB buffer pool and engine metrics
mysql://eventsEvent Scheduler status and scheduled events
mysql://sysschemasys schema diagnostics summary
mysql://locksInnoDB lock contention detection
mysql://clusterGroup Replication/InnoDB Cluster status
mysql://spatialSpatial columns and indexes
mysql://docstoreDocument Store collections

πŸ”§ Advanced Configuration

For specialized setups, see these Wiki pages:

TopicDescription
MySQL RouterConfigure Router REST API access for InnoDB Cluster
ProxySQLConfigure ProxySQL admin interface access
MySQL ShellConfigure MySQL Shell for dump/load operations

⚑ Performance Tuning

Schema metadata is cached to reduce repeated queries during tool/resource invocations.

VariableDefaultDescription
METADATA_CACHE_TTL_MS30000Cache TTL for schema metadata (milliseconds)
LOG_LEVELinfoLog verbosity: debug, info, warning, error

Tip: Lower METADATA_CACHE_TTL_MS for development (e.g., 5000), or increase it for production with stable schemas (e.g., 300000 = 5 min).

Built-in payload optimization: Many tools support optional summary: true for condensed responses and limit parameters to cap result sizes. These are particularly useful for cluster status, monitoring, and sys schema tools where full responses can be large. See the code map for per-tool details.

CLI Options

OptionEnvironment VariableDescription
--server-hostMCP_HOSTHost to bind HTTP transport to (default: localhost)
--auth-tokenMCP_AUTH_TOKENSimple bearer token for HTTP authentication
--statelessβ€”Enable stateless HTTP mode (no sessions, no SSE)
--trust-proxyTRUST_PROXYTrust X-Forwarded-For for client IP
--log-levelLOG_LEVELLog level: debug, info, warn, error
--oauth-enabledOAUTH_ENABLEDEnable OAuth 2.1 authentication
--oauth-issuerOAUTH_ISSUERAuthorization server URL
--oauth-audienceOAUTH_AUDIENCEExpected token audience
--oauth-jwks-uriOAUTH_JWKS_URIJWKS URI (auto-discovered)
--oauth-clock-toleranceOAUTH_CLOCK_TOLERANCEClock tolerance in seconds

Priority: When both --auth-token and --oauth-enabled are set, OAuth 2.1 takes precedence. If neither is configured, the server warns and runs without authentication.

Scopes

ScopeAccess Level
readRead-only queries
writeRead + write operations
adminAdministrative operations
fullAll operations

πŸ“– See the OAuth Wiki for Keycloak setup and detailed configuration.

Development

See From Source above for setup. After cloning:

npm run lint && npm run typecheck  # Run checks
npm test                           # Run tests

MCP Inspector

Use MCP Inspector to visually test and debug mysql-mcp:

Build the server first:

npm run build

Launch Inspector with mysql-mcp:

npx @modelcontextprotocol/inspector node dist/cli.js \
  --transport stdio \
  --mysql mysql://user:password@localhost:3306/database

Open http://localhost:6274 to browse all 224 tools, 18 resources, and 19 prompts interactively.

CLI mode for scripting:

List all tools:

npx @modelcontextprotocol/inspector --cli node dist/cli.js \
  --transport stdio --mysql mysql://... \
  --method tools/list

Call a specific tool:

npx @modelcontextprotocol/inspector --cli node dist/cli.js \
  --transport stdio --mysql mysql://... \
  --method tools/call --tool-name mysql_list_tables

πŸ“– See the MCP Inspector Wiki for detailed usage.

Unit Testing

The project maintains high test coverage (~90%) using Vitest.

npm test

Run coverage report:

npm run test:coverage

Test Infrastructure:

  • Centralized mock factories in src/__tests__/mocks/
  • All 111 test files use shared mocks for consistency
  • Tests run without database connection (fully mocked)

Benchmarking

The project includes a performance benchmarking suite to track the efficiency of critical paths like Code Mode sandbox initialization, tool filtering, and URI routing.

npm run bench

Contributing

Contributions are welcome! Please read our Contributing Guidelines before submitting a pull request.

Security

For security concerns, please see our Security Policy.

⚠️ Never commit credentials - Store secrets in .env (gitignored)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Code of Conduct

Please read our Code of Conduct before participating in this project.

Keywords

mcp

FAQs

Package last updated on 16 May 2026

Related posts