Skip to main content
Glama

MySQL MCP Server

A Model Context Protocol (MCP) server that provides readonly MySQL database operations for AI agents with support for multiple database servers.

Features

  • list_servers: Show all configured MySQL servers

  • list_tables: List all tables in the database

  • describe_table: Show table structure and column information

  • query: Execute SELECT queries (readonly only)

  • show_databases: List available databases

  • use_database: Switch to a different database on a server

Related MCP server: MCP MySQL Server

Installation

For detailed installation instructions, see INSTALLATION.md

From npm (once published)

npm install -g @your-username/mysql-mcp

From source

git clone <repository-url>
cd mysql-mcp
npm install

Configuration

Configure multiple MySQL servers using a JSON environment variable MYSQL_SERVERS:

{
  "production": {
    "host": "prod.example.com",
    "port": 3306,
    "user": "prod_user",
    "password": "prod_password",
    "database": "prod_db"
  },
  "staging": {
    "host": "staging.example.com",
    "port": 3306,
    "user": "staging_user",
    "password": "staging_password",
    "database": "staging_db"
  },
  "local": {
    "host": "localhost",
    "port": 3306,
    "user": "root",
    "password": "local_password",
    "database": "test_db"
  }
}

Option 2: Single Server (Backward Compatible)

Copy .env.example to .env and configure your MySQL connection:

cp .env.example .env

Set the following environment variables:

  • MYSQL_HOST: MySQL server host (default: localhost)

  • MYSQL_PORT: MySQL server port (default: 3306)

  • MYSQL_USER: MySQL username (default: root)

  • MYSQL_PASSWORD: MySQL password

  • MYSQL_DATABASE: Database name to connect to

Usage with Claude Desktop

Multiple Servers Configuration

If installed from npm:

{
  "mcpServers": {
    "mysql": {
      "command": "mysql-mcp",
      "env": {
        "MYSQL_SERVERS": "{\"production\":{\"host\":\"prod.example.com\",\"port\":3306,\"user\":\"prod_user\",\"password\":\"prod_password\",\"database\":\"prod_db\"},\"staging\":{\"host\":\"staging.example.com\",\"port\":3306,\"user\":\"staging_user\",\"password\":\"staging_password\",\"database\":\"staging_db\"}}"
      }
    }
  }
}

If running from source:

{
  "mcpServers": {
    "mysql": {
      "command": "node",
      "args": ["path/to/mysql-mcp/server.js"],
      "env": {
        "MYSQL_SERVERS": "{\"production\":{\"host\":\"prod.example.com\",\"port\":3306,\"user\":\"prod_user\",\"password\":\"prod_password\",\"database\":\"prod_db\"},\"staging\":{\"host\":\"staging.example.com\",\"port\":3306,\"user\":\"staging_user\",\"password\":\"staging_password\",\"database\":\"staging_db\"}}"
      }
    }
  }
}

Single Server Configuration

{
  "mcpServers": {
    "mysql": {
      "command": "node",
      "args": ["path/to/mysql-mcp/server.js"],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

Using Multiple Servers

When multiple servers are configured, all tools accept an optional server parameter:

// List tables from production server
await list_tables({ server: "production" })

// Query staging server
await query({ 
  sql: "SELECT * FROM users LIMIT 10",
  server: "staging"
})

// Describe table on local server
await describe_table({ 
  table_name: "products",
  server: "local"
})

// If no server is specified, "default" is used
await list_tables() // Uses "default" server

Security

This server only allows readonly operations (SELECT, SHOW, DESCRIBE) for safety. All other SQL operations are blocked.

Available Tools

6 tools
describe_tableB

Describe the structure of a specific table

ParametersJSON Schema
NameRequiredDescriptionDefault
serverNoServer name (optional, defaults to 'default')
table_nameYesName of the table to describe

TDQS

B3.4/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 operation but does not disclose whether it is read-only, what it returns (columns/types/constraints), or failure behavior for unknown tables. 'Describe' implies a metadata read, but little behavioral context is added.

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?

A single front-loaded sentence with no filler. It is appropriately sized for a simple metadata tool.

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?

For a simple describe operation with full schema coverage, the essential invocation details are present: target table and optional server. The absence of an output schema is mitigated by the phrase 'structure', though an explicit note on return format or read-only behavior would make it fully complete.

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%, so the schema already documents both server and table_name. The description's 'specific table' aligns with table_name but adds no syntax or format nuance beyond the schema.

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 identifies a specific verb ('describe') and resource ('structure of a specific table'), making the operation clear and distinct from list_tables (which lists names) and query (which reads data). It does not explicitly name sibling alternatives, which prevents a 5.

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 the tool is for inspecting the schema of a single known table, but it gives no explicit when-to-use guidance or alternatives such as list_tables for discovering tables. An agent must infer appropriate use from the name and surrounding context.

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

list_serversA

List all configured MySQL servers

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4/5.0
Behavior3/5

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

No annotations are provided, so the description carries full burden. 'List all' strongly implies a read-only, side-effect-free operation, which is helpful. However, it does not disclose what 'configured' means, whether any connection state is required, or how results are returned. It adds basic behavioral context but no deeper detail.

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 sentence that is front-loaded with the verb and the exact scope. There is no wasted text or redundant information. Every word earns its place.

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?

This is a simple no-argument listing tool, so the description is largely sufficient for an agent to know when and why to call it. The only gap is the lack of an output schema or description of the return format, but for a server listing it is reasonably inferable. It is not as rich as the HIGH calibration example, but it does not need to be given its low complexity.

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 zero parameters, so the baseline is 4. The schema already covers everything (empty properties object, 100% coverage). The description adds no parameter meaning because there are no parameters to explain, which 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 uses a specific verb and resource: 'List all configured MySQL servers.' It clearly distinguishes itself from siblings like list_tables and show_databases by specifying the resource type (MySQL servers) and scope ('all configured'). An agent can tell exactly what this tool does.

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 usage is implied by the description: call this when you need the list of configured MySQL servers. However, there is no explicit mention of when to use this tool versus alternatives, nor any exclusions or prerequisites. The context is clear but the guidance is minimal.

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

list_tablesC

List all tables in the database

ParametersJSON Schema
NameRequiredDescriptionDefault
serverNoServer name (optional, defaults to 'default')

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 responsibility for disclosing behavior. It accurately states that the action lists tables, but it does not mention read-only semantics, whether system/views are included, permission requirements, or any side effects. This is a meaningful gap for a tool with no annotation safety hints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is one short sentence with no filler and leads with the action. It is appropriately concise, though it omits context that would slightly extend it without harming conciseness.

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?

There is no output schema defining the return value, and the description does not state what information is returned (e.g., table names only, schema, row counts). It also fails to clarify the database/server scope, especially given the optional server parameter)Skip. For a tool with minimal annotations, this is insufficient for an agent to predict the full invocation result.

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%, and the only parameter, 'server', is already described in the input schema with its default value. The tool description adds no extra meaning beyond what the schema provides, so the baseline score of 3 applies.

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 uses a specific verb and resource ('List all tables in the database') and is distinguishable from siblings like describe_table, query, and list_servers. However, it does not explicitly clarify whether 'the database' means the current database or all databases on a server, which introduces minor ambiguity.

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 gives no indication of when to use this tool versus alternatives such as list_servers, show_databases, or describe_table. It neither states prerequisites nor excludes scenarios, leaving the agent to infer the tool's role solely from its name.

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

queryA

Execute a SELECT query (readonly operations only)

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYesSQL SELECT query to execute
serverNoServer name (optional, defaults to 'default')

TDQS

A3.7/5.0
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the critical read-only nature, which is useful safety information. However, it does not mention result set behavior, error handling, or constraints like single-statement execution, so the behavioral disclosure is minimal beyond the read-only guarantee.

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, front-loaded sentence that states the action and its primary constraint with zero filler. Every word contributes to the agent's understanding.

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?

For a simple two-parameter tool with no output schema and no annotations, the description is adequate but not rich. It omits return format details, but the SELECT semantics strongly imply a result set. It would benefit from noting whether the server parameter is only for selecting among configured servers.

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 both parameters (sql and server) are already well documented in the schema. The description adds no extra parameter-level meaning, so the baseline 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 states a specific verb ('Execute'), a specific resource ('a SELECT query'), and a clear scope ('readonly operations only'). This distinguishes it from the sibling metadata tools (list_servers, list_tables, describe_table), which do not run arbitrary SQL.

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 context for using this tool is implied: it is for running read-only SELECT queries against data. However, there is no explicit guidance on when to use it versus the alternative sibling tools, nor any exclusions or prerequisites (e.g., 'use list_tables first to discover tables').

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

show_databasesB

List all databases available

ParametersJSON Schema
NameRequiredDescriptionDefault
serverNoServer name (optional, defaults to 'default')

TDQS

B3.1/5.0
Behavior2/5

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

There are no annotations, so the description carries the full burden of disclosing behavior. It only says 'List all databases available,' which implies a read-only operation but does not explain behavior around the optional server parameter, default server handling, output format, or potential limitations. For a tool with no structured behavioral metadata, this is a meaningful gap.

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 one short, front-loaded sentence with no filler. It immediately states the action and the resource, making it easy to scan and parse.

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?

This is a simple tool with one optional parameter and no output schema, so the description is mostly adequate. However, it does not explain what 'available' means in relation to the optional server parameter or how this tool relates to list_servers. A sentence clarifying the server scope or expected usage would make it complete.

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%, so the schema already fully documents the optional 'server' parameter and its default value. The description adds no additional meaning about how the parameter affects the result, but because the schema handles parameter semantics, a baseline score of 3 is appropriate.

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 uses a specific verb and resource: 'List all databases available.' This clearly identifies the operation and the object, and it is distinguishable from siblings like list_servers and list_tables because it explicitly names databases. It does not explicitly contrast with related tools, but the core purpose is unambiguous.

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 gives no guidance on when to use this tool versus alternatives such as list_servers or list_tables. It does not mention any prerequisites like connecting to a server or explain whether this tool is the right choice for a given workflow. The agent is left to infer usage from the name and description alone.

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

use_databaseB

Switch to a different database on a server

ParametersJSON Schema
NameRequiredDescriptionDefault
serverNoServer name (optional, defaults to 'default')
databaseYesDatabase name to switch to

TDQS

B3.3/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 of exposing side effects. It only says 'Switch', without clarifying that this changes the active database context for subsequent operations, whether it validates the database exists, or what the success/failure behavior is.

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, front-loaded sentence with no filler. It conveys the essential operation without redundancy, 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.

Completeness3/5

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

The tool is simple and has fully documented parameters, but the absence of annotations and output schema leaves gaps around side effects and return behavior. The description is minimally viable but does not fully explain the consequences of switching databases.

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%, so the schema already fully documents both parameters. The description adds no additional meaning beyond 'database on a server', and the schema already explains the server default. Baseline 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 uses a specific verb ('Switch') and a clear resource ('database on a server'). It is immediately distinguishable from the sibling tools, which list servers/tables, query, or describe schemas rather than changing context.

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 states what the tool does but gives no guidance on when to use it instead of alternatives. It does not mention that it should be used before queries, how it relates to show_databases, or when the optional server parameter matters.

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. 6 tool updatesv1.0.0
    • First observeddescribe_table
    • First observedlist_servers
    • First observedlist_tables
    • First observedquery
    • First observedshow_databases
    • First observeduse_database

TDQS

A3.6/5.0

Scored across 6 tools

Disambiguation5/5

Each tool targets a distinct resource or action: servers, databases, tables, schema, and querying. There is no meaningful overlap between list_servers, show_databases, list_tables, describe_table, use_database, and query.

Naming Consistency4/5

Most tools follow a clear verb_noun snake_case pattern (list_servers, list_tables, describe_table, show_databases, use_database). The single tool 'query' deviates slightly by lacking a noun object, but the imperative style remains consistent.

Tool Count5/5

Six tools is well-scoped for a read-only MySQL exploration server. Each tool covers a necessary step in navigating servers, databases, tables, and data without redundancy.

Completeness4/5

The tool set provides a complete read-only workflow: discover servers, select databases, list tables, inspect schemas, and run SELECT queries. It intentionally lacks write and administrative operations, which is a minor limitation if broader MySQL management is expected.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables LLMs to interact with MySQL databases by inspecting schemas and executing safe, read-only queries within transactions.
    9 npm
    10
    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
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides AI assistants with secure read-only access to MySQL databases through validated SELECT queries. Supports SSL/TLS connections and implements multiple security layers to prevent data modification.
    600 npm
    3
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Enables AI assistants to inspect and query a MySQL database through safe, structured tools, including schema discovery and read-only queries.
    9
    122 npm
    MIT