Skip to main content
Glama
jianglisuda

MCP MySQL Server

by jianglisuda

MCP MySQL Server

Model Context Protocol (MCP) server for MySQL database connectivity.

Features

  • Execute SQL SELECT queries with parameterized inputs (read-only)

  • List all tables in the database (read-only metadata)

  • Describe table structure (read-only metadata)

  • Read-only access only - no INSERT, UPDATE, DELETE operations

Related MCP server: MCP MySQL Server

Installation

  1. Clone this repository

  2. Install dependencies:

    npm install
  3. Build the TypeScript code:

    npm run build

Configuration

Copy .env.example to .env and update the MySQL connection settings:

cp .env.example .env

Edit .env with your MySQL credentials:

MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=yourpassword
MYSQL_DATABASE=yourdatabase

Usage

Development mode

npm run dev

Production mode

npm run build
npm start

Integration with WorkBuddy

Add this server to your WorkBuddy configuration. Example configuration for WorkBuddy:

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

Tools

mysql_query

Execute a SQL SELECT query with parameterized inputs. Read-only - only SELECT queries are allowed.

Parameters:

  • sql (string): SQL SELECT query with ? placeholders

  • parameters (string[]): Array of parameter values

mysql_list_tables

List all tables in the current database. Read-only metadata query.

mysql_describe_table

Get the schema of a table. Read-only metadata query.

Parameters:

  • tableName (string): Name of the table to describe

Permissions

This MCP server provides read-only access only. The following restrictions are enforced:

  • Only SELECT queries are allowed via mysql_query

  • No INSERT, UPDATE, DELETE, or other data modification operations

  • Metadata queries (mysql_list_tables, mysql_describe_table) are read-only

  • All queries use parameterized statements to prevent SQL injection

Security

  • All SQL queries use parameterized statements to prevent SQL injection

  • Table names are validated with regex before use

  • Connection credentials are loaded from environment variables

License

MIT

Available Tools

3 tools
mysql_describe_tableA

Get the schema of a table (columns, types, constraints). This is a read-only metadata query.

ParametersJSON Schema
NameRequiredDescriptionDefault
tableNameYesName of the table to describe

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description discloses read-only behavior, which is crucial for safe invocation. No additional traits (e.g., performance, locks) are mentioned, but it is truthful and adequate.

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?

Two concise sentences, front-loaded with purpose. No unnecessary words. Efficient and clear.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple one-parameter metadata tool with no output schema, the description is sufficiently complete. It covers purpose, safety, and expected output scope.

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 coverage is 100%, and the description adds no extra meaning beyond the schema's 'Name of the table to describe'. Baseline score 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 it retrieves table schema (columns, types, constraints) and specifies it's read-only. It distinguishes from sibling tools: mysql_list_tables (list tables) and mysql_query (run queries).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description indicates use for getting table structure but does not explicitly state when to avoid or mention alternative tools. The context is clear but lacks exclusion guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

mysql_list_tablesA

List all tables in the current database. This is a read-only metadata query.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description clearly indicates the tool is a read-only metadata query, which is the key behavioral trait. It does not detail the exact output format, but for a simple listing this is acceptable.

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?

Two short, front-loaded sentences convey purpose and key trait without any extraneous words.

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?

The tool is simple with no parameters and no output schema. The description covers the essential purpose and safety characteristic. It could have elaborated on the output format, but for a list tool this is largely sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has no parameters and the input schema (empty) has 100% coverage. According to guidelines, 0 parameters yields a baseline of 4; the description need not add parameter info.

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 tool lists all tables in the current database and specifies it is read-only. It effectively distinguishes from siblings such as mysql_describe_table and mysql_query.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the tool is for listing tables and is read-only, but does not explicitly state when not to use it or provide alternatives beyond the sibling context. However, the context makes it clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

mysql_queryA

Execute a SQL SELECT query and return results. This is a read-only query tool. Use parameterized queries to prevent SQL injection.

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYesSQL SELECT query with ? placeholders for parameters
parametersNoArray of parameter values to bind to the query

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must disclose behavioral traits. It states the tool is read-only, but fails to mention other behaviors such as error handling, rate limits, or authentication requirements.

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 only two sentences, front-loaded with the core purpose, and contains no unnecessary words or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simplicity of the tool (2 parameters, no output schema, no nested objects), the description covers the read-only nature and security practice. However, it lacks information on return format or error scenarios, which would be helpful for an agent.

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 description adds minimal value beyond the schema. It repeats the injection prevention advice but does not elaborate on parameter formatting or binding details.

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 'Execute a SQL SELECT query and return results' and explicitly notes it is a read-only tool, distinguishing it from siblings like mysql_describe_table and mysql_list_tables which have different purposes.

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 provides guidance on using parameterized queries to prevent SQL injection, but does not explicitly state when to use this tool versus its siblings or when not to use it, leaving usage context implicit.

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.

  1. 3 tool updatesv1.0.0
    • First observedmysql_describe_table
    • First observedmysql_list_tables
    • First observedmysql_query

TDQS

A4/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: listing tables, describing a table's schema, and executing SELECT queries. There is no overlap or ambiguity.

Naming Consistency4/5

Two tools follow a consistent 'mysql_verb_noun' pattern (mysql_describe_table, mysql_list_tables), but mysql_query deviates by using only a verb. This minor inconsistency is still clear.

Tool Count3/5

With only 3 tools, the set is on the lower end. It covers basic read-only operations but feels slightly thin for a MySQL server, especially missing write operations. However, the read-only scope is explicitly stated.

Completeness5/5

For the stated read-only purpose, the tools provide complete coverage: metadata exploration (list tables, describe table) and data querying (SELECT). No obvious gaps.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables read-only access to MySQL databases through natural language queries. Provides automatic table schema discovery and executes SELECT, SHOW, DESCRIBE, and EXPLAIN statements within secure read-only transactions.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to safely query MySQL databases with read-only access by default, supporting table listing, structure inspection, and SQL queries with optional write operation control.
    10 npm
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables safe interaction with MySQL databases through SELECT queries, table structure inspection, and database schema exploration. Provides read-only access to query data and examine database metadata.
    1
    -
  • A
    license
    A
    quality
    D
    maintenance
    Enables read-only MySQL database access, allowing listing databases, tables, describing schemas, and executing SELECT/SHOW/DESCRIBE/EXPLAIN queries.
    7
    12 npm
    4
    MIT