Skip to main content
Glama
f4ww4z

mcp-mysql-server

by f4ww4z

@f4ww4z/mcp-mysql-server

Trust Score

A Model Context Protocol server that provides MySQL database operations. This server enables AI models to interact with MySQL databases through a standardized interface.

Installation

Installing via Smithery

To install MySQL Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @f4ww4z/mcp-mysql-server --client claude

Manual Installation

npx @f4ww4z/mcp-mysql-server

Related MCP server: MCP MySQL Server

Configuration

The server requires the following environment variables to be set in your MCP settings configuration file:

recommended use

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@f4ww4z/mcp-mysql-server", "mysql://user:password@localhost:port/database"],
    }
  }
}
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@f4ww4z/mcp-mysql-server"],
      "env": {
        "MYSQL_HOST": "your_host",
        "MYSQL_USER": "your_user",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

codex

mac

~/.codex/config.toml

[mcp_servers.mcp-mysql-server]
command = "npx"
args = [
  "-y",
  "@f4ww4z/mcp-mysql-server",
  "mysql://user:password@127.0.0.1:3306/database"
]

windows

%USERPROFILE%\.codex\config.toml

[mcp_servers.mcp-mysql-server]
command = "npx"
args = [
  "-y",
  "@f4ww4z/mcp-mysql-server",
  "mysql://user:password@127.0.0.1:3306/database"
]

Running evals

The evals package loads an mcp client that then runs the index.ts file, so there is no need to rebuild between tests. You can load environment variables by prefixing the npx command. Full documentation can be found here.

OPENAI_API_KEY=your-key  npx mcp-eval src/evals/evals.ts src/index.ts

Available Tools

1. connect_db

Establish connection to MySQL database using provided credentials.

use_mcp_tool({
  server_name: "mysql",
  tool_name: "connect_db",
  arguments: {
    host: "localhost",
    user: "your_user",
    password: "your_password",
    database: "your_database"
  }
});

2. query

Execute SELECT queries with optional prepared statement parameters.

use_mcp_tool({
  server_name: "mysql",
  tool_name: "query",
  arguments: {
    sql: "SELECT * FROM users WHERE id = ?",
    params: [1]
  }
});

3. execute

Execute INSERT, UPDATE, or DELETE queries with optional prepared statement parameters.

use_mcp_tool({
  server_name: "mysql",
  tool_name: "execute",
  arguments: {
    sql: "INSERT INTO users (name, email) VALUES (?, ?)",
    params: ["John Doe", "john@example.com"]
  }
});

4. list_tables

List all tables in the connected database.

use_mcp_tool({
  server_name: "mysql",
  tool_name: "list_tables",
  arguments: {}
});

5. describe_table

Get the structure of a specific table.

use_mcp_tool({
  server_name: "mysql",
  tool_name: "describe_table",
  arguments: {
    table: "users"
  }
});

Features

  • Secure connection handling with automatic cleanup

  • Prepared statement support for query parameters

  • Comprehensive error handling and validation

  • TypeScript support

  • Automatic connection management

Security

  • Uses prepared statements to prevent SQL injection

  • Supports secure password handling through environment variables

  • Validates queries before execution

  • Automatically closes connections when done

Error Handling

The server provides detailed error messages for common issues:

  • Connection failures

  • Invalid queries

  • Missing parameters

  • Database errors

Contributing

Contributions are welcome! Please feel free to submit a Pull Request to https://github.com/f4ww4z/mcp-mysql-server

License

MIT

Available Tools

4 tools
describe_tableB

Get table structure

ParametersJSON Schema
NameRequiredDescriptionDefault
tableYesTable name

TDQS

B3.2/5.0
Behavior2/5

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

No annotations are provided, and the description fails to disclose behavioral traits like read-only nature, side effects, or required permissions. It simply states the function without additional context.

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 extremely concise (two words), front-loaded, and gets straight to the point. However, it could benefit from a bit more detail without sacrificing brevity.

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 tool is simple with one parameter and no output schema, the description is minimal but adequate for a basic understanding. However, it doesn't specify what 'structure' includes (e.g., columns, types), leaving some ambiguity.

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% with the only parameter 'table' described as 'Table name'. The description adds no new meaning beyond the schema, so 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 'Get table structure' clearly states the verb (Get) and resource (table structure), and distinguishes the tool from siblings like execute, list_tables, and query, 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 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 vs alternatives, such as list_tables or query. It lacks context on when not to use it or any prerequisites.

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

executeB

Execute an INSERT, UPDATE, or DELETE query

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYesSQL query (INSERT, UPDATE, DELETE)
paramsNoQuery parameters (optional)

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 must bear the burden of behavioral disclosure. It confirms mutation but fails to detail side effects, permanence, or return behavior.

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 a single short sentence with no wasted words, but it could include more detail without sacrificing 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?

Given the lack of output schema and annotations, the description does not explain return values or error behavior. It is too minimal for a mutation tool.

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 does not add meaning beyond the schema. The schema already documents 'sql' and 'params' adequately.

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 executes INSERT, UPDATE, or DELETE queries, which specifies the action and resource. It distinguishes from sibling tools like 'query' which likely handles SELECT statements.

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 for write operations but does not explicitly guide when to use this tool versus alternatives like 'query'. There is no mention of prerequisites or restrictions.

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

list_tablesB

List all tables in the database

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

B3/5.0
Behavior2/5

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

There are no annotations, so the description must fully disclose behavior. It merely states 'List all tables', which implies a read operation, but omits details on permissions, output format, or performance implications.

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 a single, efficient sentence with no unnecessary words. It is appropriately front-loaded but lacks any structural enhancement like bullet points that could aid readability.

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 no output schema or annotations, the description should explain what 'list' returns (e.g., table names, schemas). Without this, an agent may not know how to use the result. Sibling tools like 'describe_table' suggest additional context might be needed.

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, so the description cannot add parameter meaning. Baseline for zero parameters is 4, and the description is sufficient for the parameterless case.

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 tool lists all tables in the database. While it distinguishes from 'describe_table' by listing instead of describing, it does not explicitly differentiate from potential siblings like 'query' or 'execute'.

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 its siblings (describe_table, execute, query). It is implied that it retrieves table names, but no context on prerequisites or alternatives.

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

queryB

Execute a SELECT query

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYesSQL SELECT query
paramsNoQuery parameters (optional)

TDQS

B3.1/5.0
Behavior2/5

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

With no annotations, the description bears full responsibility for behavioral disclosure. It only states the tool executes a SELECT query, but does not explicitly confirm it is read-only, mention permission requirements, error handling, or the effect of malformed queries. The implied read-only nature is not sufficient.

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 a single concise sentence that front-loads the main action. It is not verbose, though it could include more context without losing conciseness. The structure is effective but minimal.

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, yet the description does not explain what the tool returns (e.g., result set structure, row count, error messages). It also lacks information on pagination, limits, or behavior with large queries, leaving the agent with significant gaps.

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 documents both parameters ('sql' and 'params') adequately. The description adds no additional meaning or context about parameter usage, formatting, or constraints beyond the schema, earning a baseline score of 3.

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 'Execute a SELECT query' clearly identifies the tool's action (execute) and resource (SELECT query). It distinguishes from sibling tools like 'execute' (which likely handles other SQL statements) and 'describe_table'/'list_tables' (which are informational).

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. It does not mention that for non-SELECT queries (e.g., INSERT, UPDATE) one should use the sibling 'execute' tool, nor does it specify any prerequisites or limitations.

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

TDQS

B3.2/5.0
Disambiguation5/5

Each tool serves a distinct purpose: describe_table shows schema, execute handles writes, list_tables lists tables, and query handles reads. No overlap or ambiguity.

Naming Consistency2/5

Naming is inconsistent: 'describe_table' and 'list_tables' follow verb_noun, while 'execute' is a bare verb and 'query' is a noun. No uniform pattern.

Tool Count4/5

Four tools is reasonable for basic database operations, covering schema inspection, reads, and writes. Could be slightly expanded, but not under- or over-scoped.

Completeness3/5

Covers essential CRUD and schema listing, but misses DDL operations like create/alter/drop table, which are common needs. Notable gap for schema modification.

Maintenance

ActivityInactive
ResponsivenessUnresponsive

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
    Not graded
    quality
    C
    maintenance
    A server that enables AI models to interact with MySQL databases through a Model Control Protocol, providing tools for table creation, schema inspection, query execution, and data retrieval.
    28
    MIT
  • 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

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

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