Skip to main content
Glama
Darkstar326

MCP MySQL Server

by Darkstar326

mysql_list_tables

Lists all tables in a MySQL database to inspect schema structure and available data. Specify a database name or use the current connection.

Instructions

List all tables in the current or specified database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNoDatabase name (uses current database if not specified)

Implementation Reference

  • The main handler function that implements the mysql_list_tables tool logic. It checks for an active connection, constructs a SHOW TABLES query (optionally for a specific database), executes it, and returns the list of tables.
    private async handleListTables(args: any) {
      if (!this.pool) {
        throw new Error("Not connected to MySQL. Use mysql_connect first.");
      }
    
      const { database } = args;
      let query = "SHOW TABLES";
      
      if (database) {
        query = `SHOW TABLES FROM \`${database}\``;
      }
    
      try {
        const [results] = await this.pool.execute(query);
        return {
          content: [
            {
              type: "text",
              text: `Tables${database ? ` in database '${database}'` : ""}:\n${JSON.stringify(results, null, 2)}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to list tables: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • src/index.ts:248-267 (registration)
    The switch statement in the CallToolRequest handler that dispatches to the mysql_list_tables handler based on the tool name.
    switch (name) {
      case "mysql_connect":
        return await this.handleConnect(args);
      case "mysql_query":
        return await this.handleQuery(args);
      case "mysql_list_databases":
        return await this.handleListDatabases();
      case "mysql_list_tables":
        return await this.handleListTables(args);
      case "mysql_describe_table":
        return await this.handleDescribeTable(args);
      case "mysql_show_indexes":
        return await this.handleShowIndexes(args);
      case "mysql_get_table_stats":
        return await this.handleGetTableStats(args);
      case "mysql_disconnect":
        return await this.handleDisconnect();
      default:
        throw new Error(`Unknown tool: ${name}`);
    }
  • src/index.ts:165-177 (registration)
    The tool registration object in the ListTools response, including name, description, and input schema for mysql_list_tables.
    {
      name: "mysql_list_tables",
      description: "List all tables in the current or specified database",
      inputSchema: {
        type: "object",
        properties: {
          database: {
            type: "string",
            description: "Database name (uses current database if not specified)",
          },
        },
      },
    },
  • The input schema definition for the mysql_list_tables tool.
    inputSchema: {
      type: "object",
      properties: {
        database: {
          type: "string",
          description: "Database name (uses current database if not specified)",
        },
      },
    },
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 behavioral disclosure. It states the action ('List all tables') but doesn't describe behavioral traits such as whether this is a read-only operation, potential permissions required, rate limits, or what the output format looks like (e.g., list of table names, pagination). For a tool with no annotations, 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, clear sentence that efficiently conveys the tool's purpose without unnecessary words. It is front-loaded with the core action and scope, making it easy to parse. Every part of the sentence earns its place by specifying what is listed and under what conditions.

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's low complexity (1 optional parameter, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose and parameter context, but lacks details on behavioral aspects and output, which are important for a tool with no annotations. For a simple list operation, it meets the minimum viable threshold but doesn't provide a complete picture 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 input schema has 1 parameter with 100% description coverage, documenting that 'database' is optional and defaults to the current database. The description adds minimal value beyond the schema by mentioning 'current or specified database,' which aligns with the schema but doesn't provide additional semantics like format examples or constraints. 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.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('tables'), specifying scope ('all tables in the current or specified database'). It distinguishes from some siblings like mysql_describe_table (single table details) and mysql_list_databases (databases instead of tables), but doesn't explicitly differentiate from mysql_get_table_stats which also operates on tables. The purpose is specific and actionable.

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 context by mentioning 'current or specified database,' which helps understand when to specify the database parameter. However, it doesn't provide explicit guidance on when to use this tool versus alternatives like mysql_list_databases (for listing databases) or mysql_get_table_stats (for table statistics). No exclusions or prerequisites are mentioned.

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

Install Server

Other Tools

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

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