Skip to main content
Glama

MySQL MCP Server

This is a Model Context Protocol (MCP) server that provides access to a MySQL database. It allows agent to execute SQL queries against a MySQL database.

Features

  • Execute SQL queries against a MySQL database:

    • Read data (SELECT statements)

    • Create tables (CREATE TABLE statements)

    • Insert data (INSERT INTO statements)

    • Update data (UPDATE statements)

    • Delete data (DELETE FROM statements)

  • Returns query results in JSON format

  • Configurable database connection settings

  • Transaction logging with unique IDs

Related MCP server: MCP MySQL Server

Prerequisites

  • Node.js (v14 or higher)

  • MySQL server

  • MCP SDK

Installation

  1. Clone or download this repository

  2. Install dependencies:

cd mysql-mcp-server
npm install
  1. Build the server:

npm run build

Configuration

The MySQL MCP server uses the following environment variables for configuration:

  • MYSQL_HOST: MySQL server hostname (default: 'localhost')

  • MYSQL_PORT: MySQL server port (default: 3306)

  • MYSQL_USER: MySQL username (default: 'mcp101')

  • MYSQL_PASSWORD: MySQL password (default: '123qwe')

  • MYSQL_DATABASE: MySQL database name (default: 'mcpdb')

Database Setup

  1. Create a MySQL database:

CREATE DATABASE mcpdb;
  1. Create a MySQL user with access to the database:

CREATE USER 'mcp101'@'localhost' IDENTIFIED BY '123qwe';
GRANT ALL PRIVILEGES ON mcpdb.* TO 'mcp101'@'localhost';
FLUSH PRIVILEGES;
  1. Create a test table with sample data:

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');

MCP Configuration

Add the MySQL MCP server to your MCP settings file:

VSCode (Claude Extension)

File: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

Change the args according your MySQL configuruation

{
  "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"
    }
  }
}

Claude Desktop App

File: ~/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"
    }
  }
}

Usage

Once configured, you can use the MySQL MCP server in your conversations with Claude. For example:

"Can you show me all the users in the test_users table?"

Claude will use the run_sql_query tool to execute:

SELECT * FROM test_users

Available Tools

run_sql_query

Executes a read-only SQL query (SELECT statements only) against the MySQL database.

Parameters:

  • query: The SQL SELECT query to execute.

Example:

{
  "query": "SELECT * FROM test_users"
}

create_table

Creates a new table in the MySQL database.

Parameters:

  • query: The SQL CREATE TABLE query to execute.

Example:

{
  "query": "CREATE TABLE products (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), price DECIMAL(10,2))"
}

insert_data

Inserts data into a table in the MySQL database.

Parameters:

  • query: The SQL INSERT INTO query to execute.

Example:

{
  "query": "INSERT INTO products (name, price) VALUES ('Laptop', 999.99), ('Smartphone', 499.99)"
}

update_data

Updates data in a table in the MySQL database.

Parameters:

  • query: The SQL UPDATE query to execute.

Example:

{
  "query": "UPDATE products SET price = 899.99 WHERE name = 'Laptop'"
}

delete_data

Deletes data from a table in the MySQL database.

Parameters:

  • query: The SQL DELETE FROM query to execute.

Example:

{
  "query": "DELETE FROM products WHERE name = 'Smartphone'"
}

Security Considerations

  • Use a dedicated MySQL user with appropriate privileges for the MCP server

  • Consider using read-only privileges if you only need to query data

  • Store sensitive information like database credentials securely

  • All operations are logged with unique transaction IDs for auditing

Available Tools

6 tools
create_tableC

Creates a new table in the MySQL database.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL CREATE TABLE query to execute.

TDQS

C2.9/5.0
Behavior2/5

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.

Conciseness5/5

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.

Completeness2/5

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.

Parameters3/5

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.

Purpose4/5

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.

Usage Guidelines2/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL DELETE FROM query to execute.

TDQS

C2.9/5.0
Behavior2/5

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.

Conciseness5/5

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.

Completeness2/5

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.

Parameters3/5

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.

Purpose4/5

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.

Usage Guidelines2/5

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.)

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL statement to execute.

TDQS

B3.2/5.0
Behavior2/5

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.

Conciseness5/5

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.

Completeness2/5

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.

Parameters3/5

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.

Purpose4/5

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.

Usage Guidelines3/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL INSERT INTO query to execute.

TDQS

C2.9/5.0
Behavior2/5

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.

Conciseness5/5

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.

Completeness2/5

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.

Parameters3/5

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.

Purpose4/5

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.

Usage Guidelines2/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL SELECT query to execute.

TDQS

A4.4/5.0
Behavior4/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines5/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL UPDATE query to execute.

TDQS

C2.9/5.0
Behavior2/5

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.

Conciseness5/5

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.

Completeness2/5

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.

Parameters3/5

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.

Purpose4/5

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.

Usage Guidelines2/5

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.

TDQS

A3.5/5.0
Disambiguation4/5

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.

Naming Consistency5/5

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.

Tool Count5/5

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.

Completeness4/5

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

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    A 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.
    5
    342
    MIT
  • F
    license
    B
    quality
    D
    maintenance
    A 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
  • F
    license
    Not graded
    quality
    D
    maintenance
    A 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
  • A
    license
    B
    quality
    D
    maintenance
    A 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.
    4
    12
    10
    MIT

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/michael7736/mysql-mcp-server'

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