Skip to main content
Glama
neverinfamous

MySQL MCP Server

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
LOG_LEVELNoLog verbosity level (debug, info, warning, error)info
MYSQL_HOSTYesThe MySQL database host
MYSQL_PORTNoThe MySQL database port3306
MYSQL_USERYesThe MySQL database user
MYSQLSH_PATHNoPath to MySQL Shell executable
OAUTH_ISSUERNoOAuth authorization server URL
OAUTH_ENABLEDNoEnable OAuth 2.1 authentication
PROXYSQL_HOSTNoProxySQL admin interface host
PROXYSQL_PORTNoProxySQL admin interface port
PROXYSQL_USERNoProxySQL admin username
MYSQL_DATABASEYesThe MySQL database name
MYSQL_PASSWORDYesThe MySQL database password
OAUTH_AUDIENCENoExpected OAuth token audience
OAUTH_JWKS_URINoOAuth JWKS URI (auto-discovered if not provided)
MYSQL_ROUTER_URLNoMySQL Router REST API URL (e.g., https://localhost:8443)
MYSQL_ROUTER_USERNoMySQL Router REST API username
PROXYSQL_PASSWORDNoProxySQL admin password
METADATA_CACHE_TTL_MSNoCache TTL for schema metadata in milliseconds30000
MYSQL_ROUTER_INSECURENoSet to 'true' to bypass SSL certificate verification for MySQL Router
MYSQL_ROUTER_PASSWORDNoMySQL Router REST API password
OAUTH_CLOCK_TOLERANCENoOAuth clock tolerance in seconds

Capabilities

Features and capabilities supported by this server

CapabilityDetails
tools
{
  "listChanged": true
}
logging
{}
prompts
{
  "listChanged": true
}
resources
{
  "subscribe": true,
  "listChanged": true
}

Tools

Functions exposed to the LLM to take actions

NameDescription
mysql_read_queryA

Execute a read-only SQL query (SELECT). Uses prepared statements for safety.

mysql_write_queryA

Execute a write SQL query (INSERT, UPDATE, DELETE). Uses prepared statements for safety.

mysql_list_tablesA

List all tables and views in the database with metadata.

mysql_describe_tableA

Get detailed information about a table's structure including columns, types, and constraints.

mysql_create_tableA

Create a new table with specified columns, engine, and charset.

mysql_drop_tableB

Drop (delete) a table from the database.

mysql_get_indexesA

Get all indexes for a table including type, columns, and cardinality.

mysql_create_indexA

Create an index on a table. Supports BTREE, HASH, FULLTEXT, and SPATIAL index types.

mysql_enable_versioningA

Enable optimistic concurrency control (OCC) on a table. Adds a _version column and an auto-increment trigger.

mysql_disable_versioningB

Disable optimistic concurrency control (OCC) on a table. Drops the _version column and its trigger.

mysql_check_versionA

Read the current _version of a specific row for optimistic concurrency control.

mysql_conditional_updateA

Update a row only if its _version matches expectedVersion. Prevents lost updates in multi-agent environments.

mysql_transaction_beginA

Begin a new transaction with optional isolation level. Returns a transaction ID for subsequent operations.

mysql_transaction_commitA

Commit a transaction, making all changes permanent.

mysql_transaction_rollbackC

Rollback a transaction, undoing all changes.

mysql_transaction_savepointC

Create a savepoint within a transaction for partial rollback.

mysql_transaction_releaseA

Release a savepoint, removing it without rolling back.

mysql_transaction_rollback_toA

Rollback to a savepoint, undoing changes after that point.

mysql_transaction_executeA

Execute multiple SQL statements atomically. All statements succeed or all are rolled back.

mysql_json_extractC

Extract values from JSON columns using JSON path expressions.

mysql_json_setB

Set or update values in JSON columns at specified paths.

mysql_json_insertA

Insert values into JSON columns only if the path does not exist.

mysql_json_replaceB

Replace values in JSON columns only if the path exists.

mysql_json_removeC

Remove values from JSON columns at specified paths.

mysql_json_containsB

Find rows where JSON column contains a specified value.

mysql_json_keysA

Get the keys of a JSON object at the specified path.

mysql_json_array_appendC

Append a value to a JSON array at the specified path.

mysql_json_getC

Simple JSON value extraction by row ID.

mysql_json_updateC

Simple JSON value update by row ID.

mysql_json_searchB

Search for a string value in JSON columns and return matching paths.

mysql_json_validateA

Validate if a string is valid JSON.

mysql_json_mergeA

Merge two JSON documents using JSON_MERGE_PATCH or JSON_MERGE_PRESERVE.

mysql_json_diffA

Compare two JSON documents and identify differences.

mysql_json_normalizeA

Normalize JSON column structure by extracting all unique keys across documents.

mysql_json_statsA

Analyze statistics for a JSON column including depth, size, and key frequency.

mysql_json_index_suggestB

Suggest functional indexes for frequently accessed JSON paths.

mysql_regexp_matchC

Find rows where column matches a regular expression pattern.

mysql_like_searchB

Find rows using LIKE pattern matching with % and _ wildcards.

mysql_soundexB

Find rows with phonetically similar values using SOUNDEX.

mysql_substringB

Extract substrings from column values.

mysql_concatA

Concatenate multiple columns with an optional separator.

mysql_collation_convertC

Convert column values to a different character set or collation.

mysql_execute_codeA

Execute TypeScript/JavaScript code in a sandboxed environment with access to all MySQL tools via the mysql.* API.

Available API groups:

  • mysql.core: readQuery, writeQuery, listTables, describeTable, createTable, createIndex (8 methods)

  • mysql.transactions: begin, commit, rollback, savepoint, execute (7 methods)

  • mysql.json: extract, set, insert, remove, contains, keys, merge, diff, stats (17 methods)

  • mysql.text: regexpMatch, likeSearch, soundex, substring, concat, collationConvert (6 methods)

  • mysql.fulltext: fulltextSearch, fulltextCreate, fulltextBoolean, fulltextExpand (5 methods)

  • mysql.performance: explain, explainAnalyze, slowQueries, bufferPoolStats, tableStats (8 methods)

  • mysql.optimization: indexRecommendation, queryRewrite, forceIndex, optimizerTrace (4 methods)

  • mysql.admin: optimizeTable, analyzeTable, checkTable, repairTable, flushTables, killQuery, serverConfig, appendInsight, auditSearch (9 methods)

  • mysql.monitoring: showProcesslist, showStatus, showVariables, innodbStatus, poolStats (7 methods)

  • mysql.backup: createDump, exportTable, importData, restoreDump (4 methods)

  • mysql.replication: masterStatus, slaveStatus, binlogEvents, gtidStatus, replicationLag (5 methods)

  • mysql.partitioning: partitionInfo, addPartition, dropPartition, reorganizePartition (4 methods)

  • mysql.schema: listSchemas, createView, listFunctions, listTriggers (10 methods)

  • mysql.events: eventCreate, eventAlter, eventDrop, eventList, schedulerStatus (6 methods)

  • mysql.sysschema: sysSchemaStats, sysStatementSummary, sysIoSummary (8 methods)

  • mysql.stats: descriptive, percentiles, correlation, regression, timeSeries, histogram (8 methods)

  • mysql.spatial: distance, distanceSphere, point, polygon, buffer (12 methods)

  • mysql.security: sslStatus, userPrivileges, audit, sensitiveTables (9 methods)

  • mysql.cluster: clusterStatus, grStatus, grMembers, clusterTopology (10 methods)

  • mysql.roles: roleCreate, roleGrant, roleAssign, roleList (8 methods)

  • mysql.docstore: docCreateCollection, docFind, docAdd, docModify (9 methods)

  • mysql.router: routerStatus, routerRoutes, routerRouteHealth (9 methods)

Example:

const tables = await mysql.core.listTables();
const results = [];
for (const t of tables.tables) {
    const count = await mysql.core.readQuery(`SELECT COUNT(*) as n FROM \`${t.name}\``);
    results.push({ table: t.name, rows: count.rows[0].n });
}
return results;

Prompts

Interactive templates invoked by user choice

NameDescription
mysql_tool_indexShow all available MySQL tools organized by category
mysql_quick_queryQuickly run a SQL query - shortcut for mysql_read_query or mysql_write_query
mysql_quick_schemaQuickly explore database schema - lists tables or describes a specific table
mysql_query_builderHelp build SQL queries for common operations
mysql_schema_designHelp design table schemas
mysql_performance_analysisAnalyze and optimize slow queries
mysql_migrationGenerate migration scripts for schema changes
mysql_database_health_checkComprehensive database health assessment workflow
mysql_backup_strategyDesign enterprise backup strategy with RTO/RPO planning
mysql_index_tuningAnalyze and optimize database indexes
mysql_setup_routerComplete MySQL Router setup and configuration guide
mysql_setup_proxysqlComplete ProxySQL setup and configuration guide
mysql_setup_replicationMySQL replication setup and configuration guide
mysql_setup_shellMySQL Shell setup and usage guide
mysql_setup_eventsComplete MySQL Event Scheduler setup and configuration guide
mysql_sys_schema_guideComplete MySQL sys schema usage guide for diagnostics and troubleshooting
mysql_setup_spatialComplete MySQL Spatial/GIS setup and usage guide
mysql_setup_clusterComplete MySQL InnoDB Cluster and Group Replication setup guide
mysql_setup_docstoreComplete MySQL Document Store and X DevAPI setup guide

Resources

Contextual data attached and managed by the client

NameDescription
mysql_helpCritical gotchas, parameter aliases, and Code Mode API reference
mysql_help_coreTool reference for the core tool group
mysql_help_jsonTool reference for the json tool group
mysql_help_transactionsTool reference for the transactions tool group
mysql_help_textTool reference for the text tool group
mysql_help_fulltextTool reference for the fulltext tool group
mysql_help_statsTool reference for the stats tool group
mysql_help_spatialTool reference for the spatial tool group
mysql_help_adminTool reference for the admin tool group
mysql_help_monitoringTool reference for the monitoring tool group
mysql_help_performanceTool reference for the performance tool group
mysql_help_optimizationTool reference for the optimization tool group
mysql_help_backupTool reference for the backup tool group
mysql_help_replicationTool reference for the replication tool group
mysql_help_partitioningTool reference for the partitioning tool group
mysql_help_schemaTool reference for the schema tool group
mysql_help_introspectionTool reference for the introspection tool group
mysql_help_migrationTool reference for the migration tool group
mysql_help_eventsTool reference for the events tool group
mysql_help_sysschemaTool reference for the sysschema tool group
mysql_help_securityTool reference for the security tool group
mysql_help_rolesTool reference for the roles tool group
mysql_help_docstoreTool reference for the docstore tool group
mysql_help_clusterTool reference for the cluster tool group
mysql_help_proxysqlTool reference for the proxysql tool group
mysql_help_routerTool reference for the router tool group
mysql_help_shellTool reference for the shell tool group
mysql_help_vectorTool reference for the vector tool group
mysql_metricsIn-memory streaming metrics including p50/p95/p99 latency and token usage
Database SchemaFull database schema including tables, views, and indexes
Table ListList of all tables with metadata
Server VariablesMySQL server configuration variables
Server StatusMySQL server status metrics
Active ProcessesCurrently running queries and connections
Connection PoolConnection pool statistics
Server CapabilitiesMySQL server version, extensions, and available tool categories
Database HealthComprehensive database health status
Performance MetricsQuery performance statistics and slow query analysis
Index StatisticsIndex usage statistics, unused indexes, and duplicate detection
Replication StatusReplication status, lag monitoring, and GTID information
InnoDB StatusInnoDB buffer pool statistics and engine status
Scheduled EventsEvent Scheduler status and scheduled events overview
sys Schema DiagnosticsKey diagnostic information from MySQL sys schema views
Lock ContentionCurrent InnoDB lock waits and blocking transactions
Cluster StatusGroup Replication and InnoDB Cluster status overview
Spatial ColumnsSpatial columns and indexes in the database
Document Store CollectionsX DevAPI document collections in the current database
Business Insights MemoSynthesized memo of business insights discovered during database analysis. Populated via mysql_append_insight tool.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/neverinfamous/mysql-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server