MySQL MCP Server
Servidor MySQL MCP
Este es un servidor de Protocolo de Contexto de Modelo (MCP) que proporciona acceso a una base de datos MySQL. Permite al agente ejecutar consultas SQL en dicha base de datos.
Características
Ejecutar consultas SQL contra una base de datos MySQL:
Leer datos (declaraciones SELECT)
Crear tablas (sentencias CREATE TABLE)
Insertar datos (sentencias INSERT INTO)
Actualizar datos (declaraciones UPDATE)
Eliminar datos (declaraciones DELETE FROM)
Devuelve los resultados de la consulta en formato JSON
Configuración de conexión de base de datos configurable
Registro de transacciones con identificadores únicos
Related MCP server: MCP MySQL Server
Prerrequisitos
Node.js (v14 o superior)
Servidor MySQL
Kit de desarrollo de software de MCP
Instalación
Clonar o descargar este repositorio
Instalar dependencias:
cd mysql-mcp-server
npm installConstruir el servidor:
npm run buildConfiguración
El servidor MySQL MCP utiliza las siguientes variables de entorno para la configuración:
MYSQL_HOST: nombre de host del servidor MySQL (predeterminado: 'localhost')MYSQL_PORT: puerto del servidor MySQL (predeterminado: 3306)MYSQL_USER: nombre de usuario de MySQL (predeterminado: 'mcp101')MYSQL_PASSWORD: Contraseña de MySQL (predeterminada: '123qwe')MYSQL_DATABASE: nombre de la base de datos MySQL (predeterminado: 'mcpdb')
Configuración de la base de datos
Crear una base de datos MySQL:
CREATE DATABASE mcpdb;Cree un usuario MySQL con acceso a la base de datos:
CREATE USER 'mcp101'@'localhost' IDENTIFIED BY '123qwe';
GRANT ALL PRIVILEGES ON mcpdb.* TO 'mcp101'@'localhost';
FLUSH PRIVILEGES;Cree una tabla de prueba con datos de muestra:
USE mcpdb;
CREATE TABLE test_users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100),
email VARCHAR(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO test_users (name, email) VALUES
('John Doe', 'john@example.com'),
('Jane Smith', 'jane@example.com'),
('Bob Johnson', 'bob@example.com');Configuración de MCP
Agregue el servidor MySQL MCP a su archivo de configuración MCP:
VSCode (extensión de Claude)
Archivo: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
Cambie los argumentos según su configuración de MySQL
{
"mcpServers": {
"mysql-mcp-server": {
"autoApprove": [],
"disabled": false,
"timeout": 60,
"command": "node",
"args": [
"/path/to/mysql-mcp-server/build/index.js"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "mcp101",
"MYSQL_PASSWORD": "123qwe",
"MYSQL_DATABASE": "mcpdb"
},
"transportType": "stdio"
}
}
}Aplicación de escritorio Claude
Archivo: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"mysql-mcp-server": {
"autoApprove": [],
"disabled": false,
"timeout": 60,
"command": "node",
"args": [
"/path/to/mysql-mcp-server/build/index.js"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "mcp101",
"MYSQL_PASSWORD": "123qwe",
"MYSQL_DATABASE": "mcpdb"
},
"transportType": "stdio"
}
}
}Uso
Una vez configurado, puedes usar el servidor MySQL MCP en tus conversaciones con Claude. Por ejemplo:
"¿Puedes mostrarme todos los usuarios en la tabla test_users?"
Claude utilizará la herramienta run_sql_query para ejecutar:
SELECT * FROM test_usersHerramientas disponibles
ejecutar_consulta_sql
Ejecuta una consulta SQL de solo lectura (solo declaraciones SELECT) en la base de datos MySQL.
Parámetros:
query: La consulta SQL SELECT a ejecutar.
Ejemplo:
{
"query": "SELECT * FROM test_users"
}crear_tabla
Crea una nueva tabla en la base de datos MySQL.
Parámetros:
query: La consulta SQL CREATE TABLE a ejecutar.
Ejemplo:
{
"query": "CREATE TABLE products (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), price DECIMAL(10,2))"
}insertar_datos
Inserta datos en una tabla en la base de datos MySQL.
Parámetros:
query: La consulta SQL INSERT INTO a ejecutar.
Ejemplo:
{
"query": "INSERT INTO products (name, price) VALUES ('Laptop', 999.99), ('Smartphone', 499.99)"
}actualizar_datos
Actualiza datos en una tabla en la base de datos MySQL.
Parámetros:
query: La consulta SQL UPDATE a ejecutar.
Ejemplo:
{
"query": "UPDATE products SET price = 899.99 WHERE name = 'Laptop'"
}eliminar_datos
Elimina datos de una tabla en la base de datos MySQL.
Parámetros:
query: La consulta SQL DELETE FROM a ejecutar.
Ejemplo:
{
"query": "DELETE FROM products WHERE name = 'Smartphone'"
}Consideraciones de seguridad
Utilice un usuario MySQL dedicado con privilegios adecuados para el servidor MCP
Considere usar privilegios de solo lectura si solo necesita consultar datos
Almacene información confidencial, como credenciales de bases de datos, de forma segura
Todas las operaciones se registran con identificadores de transacción únicos para auditoría.
Available Tools
6 toolscreate_tableC
Creates a new table in the MySQL database.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The SQL CREATE TABLE query to execute. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool creates a table, implying a write operation, but doesn't mention critical aspects like whether it requires specific permissions, if it's idempotent, what happens on errors, or any rate limits. This leaves significant gaps in understanding the tool's behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, clear sentence that efficiently conveys the core purpose without unnecessary words. It's front-loaded and wastes no space, making it easy for an agent to parse quickly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool that performs a database write operation with no annotations and no output schema, the description is insufficient. It doesn't address behavioral traits like error handling, permissions, or return values, leaving the agent with incomplete context for safe and effective use.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 100%, with the single parameter 'query' documented as 'The SQL CREATE TABLE query to execute.' The description doesn't add any meaningful semantics beyond this, such as SQL syntax examples or constraints, so it meets the baseline for adequate but not enhanced parameter understanding.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('creates') and resource ('new table in the MySQL database'), making the purpose immediately understandable. However, it doesn't distinguish this tool from sibling tools like 'execute_sql' or 'run_sql_query' which might also create tables, missing the opportunity to clarify its specific role in the toolset.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives like 'execute_sql' or 'run_sql_query', which could potentially handle similar tasks. The description lacks context about prerequisites, such as database permissions or connection requirements, leaving the agent to infer usage scenarios.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
delete_dataC
Deletes data from a table in the MySQL database.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The SQL DELETE FROM query to execute. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool performs a deletion, implying a destructive mutation, but fails to mention critical aspects like required permissions, whether deletions are permanent or reversible, transaction handling, error behavior, or rate limits. This leaves significant gaps for a destructive operation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that directly states the tool's purpose with zero wasted words. It is appropriately sized and front-loaded, making it easy to parse quickly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a destructive mutation tool with no annotations and no output schema, the description is insufficiently complete. It lacks details on behavioral traits (e.g., permanence, permissions), output expectations, error handling, and differentiation from siblings, leaving the agent with inadequate context for safe and effective use.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already fully documents the single 'query' parameter. The description adds no additional meaning about parameter usage, syntax examples, or constraints beyond what the schema provides, meeting the baseline for high coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Deletes') and target resource ('data from a table in the MySQL database'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'execute_sql' or 'run_sql_query' which could also handle DELETE operations, so it misses the highest score for sibling distinction.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives like 'execute_sql' or 'run_sql_query', nor does it mention prerequisites, exclusions, or specific contexts. It merely states what the tool does without indicating appropriate usage scenarios.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
execute_sqlB
Executes any non-SELECT SQL statement (e.g., ALTER TABLE, DROP, etc.)
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The SQL statement to execute. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It states the tool executes SQL statements but doesn't disclose behavioral traits like whether it requires specific permissions, if changes are reversible, potential side effects (e.g., data loss from DROP), or error handling. This is a significant gap for a mutation tool with zero annotation coverage.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence with zero waste. It's front-loaded with the core purpose and includes helpful examples (e.g., ALTER TABLE, DROP). Every word earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity (executes non-SELECT SQL, which can be destructive), lack of annotations, and no output schema, the description is incomplete. It should address behavioral aspects like safety, permissions, or return values to compensate for the missing structured data.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, with the 'query' parameter documented as 'The SQL statement to execute.' The description adds no additional meaning beyond this, as it doesn't specify syntax, format, or constraints. Baseline 3 is appropriate when the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb ('executes') and resource ('non-SELECT SQL statement') with specific examples (ALTER TABLE, DROP). However, it doesn't explicitly differentiate from siblings like 'run_sql_query' (which likely handles SELECT) or 'create_table'/'delete_data' (which are specific operations).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage by specifying 'non-SELECT SQL statement', which suggests when to use this tool (for non-SELECT operations) versus alternatives like 'run_sql_query' (for SELECT). However, it doesn't explicitly name alternatives or provide exclusions (e.g., when to use 'create_table' instead).
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
insert_dataC
Inserts data into a table in the MySQL database.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The SQL INSERT INTO query to execute. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden for behavioral disclosure. While 'inserts data' implies a write/mutation operation, it doesn't address critical aspects like required permissions, whether the operation is idempotent, transaction handling, error behavior, or what happens on success/failure. For a database mutation tool, this leaves significant gaps in understanding how it behaves.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence with zero wasted words. It's appropriately sized for a simple tool and front-loads the essential information (action + target) immediately.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a database mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what happens after insertion (e.g., returns inserted row count, error messages, or confirmation), nor does it address behavioral aspects like transaction safety or permission requirements. The combination of mutation nature and lack of structured metadata demands more descriptive context.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, with the single parameter 'query' fully documented in the schema. The description adds no additional parameter information beyond what the schema provides, such as query format examples or constraints. The baseline of 3 is appropriate when the schema does all the parameter documentation work.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('inserts data') and target resource ('into a table in the MySQL database'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from sibling tools like 'execute_sql' or 'run_sql_query' which might also handle INSERT operations, leaving some ambiguity about specialization.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives like 'execute_sql', 'update_data', or 'create_table'. It doesn't mention prerequisites, exclusions, or specific contexts where this tool is preferred, leaving the agent to guess based on tool names alone.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
run_sql_queryA
Executes a read-only SQL query (SELECT statements only) against the MySQL database.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The SQL SELECT query to execute. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Since no annotations are provided, the description carries the full burden of behavioral disclosure. It effectively describes key behavioral traits: it's read-only (implying no data mutation), limited to SELECT statements (constraining query types), and executes against a MySQL database (specifying the target). However, it lacks details on permissions, rate limits, error handling, or result format, which would be useful for a database tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, well-structured sentence that front-loads the key information: action ('Executes'), constraint ('read-only SQL query (SELECT statements only)'), and target ('against the MySQL database'). There is no wasted verbiage, and every word contributes to clarity and utility.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity (executing SQL queries), lack of annotations, and no output schema, the description is reasonably complete. It covers the core purpose, usage constraints, and target database. However, it doesn't address potential behavioral aspects like result format, pagination, timeouts, or authentication needs, which could be important for an AI agent to use it effectively.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 100%, with the single parameter 'query' documented as 'The SQL SELECT query to execute.' The description adds minimal value beyond this by reinforcing the SELECT-only constraint, but doesn't provide additional syntax, format, or validation details. With high schema coverage, the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the specific action ('Executes a read-only SQL query') and resource ('against the MySQL database'), with explicit limitation to 'SELECT statements only'. This distinguishes it from siblings like create_table, delete_data, insert_data, and update_data which are write operations, and from execute_sql which might allow broader SQL statements.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly states 'read-only SQL query (SELECT statements only)', providing clear guidance on when to use this tool (for SELECT queries) versus when not to use it (for write operations like INSERT, UPDATE, DELETE, or DDL). It implicitly suggests alternatives like insert_data for INSERT queries or update_data for UPDATE queries among the sibling tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
update_dataC
Updates data in a table in the MySQL database.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The SQL UPDATE query to execute. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool performs updates but doesn't mention critical aspects like required permissions, whether changes are reversible, transaction handling, error behavior, or rate limits. This is inadequate for a mutation tool with zero annotation coverage.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence with zero wasted words. It's appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a mutation tool with no annotations, no output schema, and multiple sibling tools, the description is incomplete. It lacks behavioral context, usage differentiation, and details about what happens after execution (e.g., success/failure responses, affected rows). The high schema coverage doesn't compensate for these gaps in a write operation context.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 100%, with the single parameter 'query' documented as 'The SQL UPDATE query to execute'. The description adds no additional parameter details beyond what the schema provides, so it meets the baseline for high schema coverage without compensating value.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Updates') and target ('data in a table in the MySQL database'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'execute_sql' or 'run_sql_query' that might also perform updates, leaving some ambiguity about when to choose this specific tool.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives like 'execute_sql', 'run_sql_query', or 'delete_data'. The description lacks context about prerequisites, constraints, or explicit recommendations for tool selection among siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
6 tool updates
- First observed
create_table - First observed
delete_data - First observed
execute_sql - First observed
insert_data - First observed
run_sql_query - First observed
update_data
TDQS
Scored across 6 tools
Most tools have distinct purposes with clear boundaries (e.g., create_table vs. insert_data vs. update_data). However, execute_sql and run_sql_query could cause confusion since both execute SQL statements, differentiated only by read-only vs. non-SELECT operations, which might not be immediately obvious to an agent.
All tool names follow a consistent verb_noun pattern (e.g., create_table, delete_data, execute_sql), with no mixing of conventions. This predictability makes it easy for agents to understand and use the tool set.
With 6 tools, this server is well-scoped for basic MySQL database operations. Each tool serves a clear purpose (e.g., table creation, data manipulation, query execution), and the count is appropriate for covering core functionalities without being overwhelming.
The tool set provides good coverage for basic CRUD operations (create, read, update, delete) and table management. However, there are minor gaps, such as missing tools for listing tables or databases, which could limit agents in exploratory tasks, though core workflows are still supported.
Maintenance
Related MCP Connectors
The Mercado Pago MCP Server implements the Model Context Protocol to provide AI agents and LLMs with access to Mercado Pago's APIs and tools within compatible development environments. It acts as an intermediary that translates Mercado Pago resources into executable functions (tools) that AI applications can invoke to perform actions and automate flows. The server simplifies integration, enables using documentation to implement or improve code, and optimizes operations through natural language interactions without manual implementations.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
- dataOAuthco.thinair
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Related MCP Servers
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases, providing tools for querying, executing statements, listing tables, and describing table structures.5251 npmMIT
- FlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases through a standardized interface, providing tools for querying, executing commands, and managing database schemas.7-
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases through natural language, supporting SQL queries, table creation, and schema exploration.3-
- AlicenseBqualityDmaintenanceA server based on Model Context Protocol that enables AI models to interact with MySQL databases through a standardized interface, supporting features like query execution, table listing, and automated connection management.430 npm10MIT