Skip to main content
Glama
sajithrw

MCP MySQL Server

by sajithrw

mysql_list_tables

Lists all tables in a MySQL database to inspect schema structure and manage database organization.

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 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)}`);
      }
    }
  • Input schema definition for the mysql_list_tables tool, specifying an optional database parameter.
    inputSchema: {
      type: "object",
      properties: {
        database: {
          type: "string",
          description: "Database name (uses current database if not specified)",
        },
      },
    },
  • src/index.ts:165-177 (registration)
    Registration of the mysql_list_tables tool in the ListToolsRequest handler, including name, description, and schema.
    {
      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)",
          },
        },
      },
    },
  • src/index.ts:255-256 (registration)
    Switch case in the CallToolRequest handler that routes calls to mysql_list_tables to the appropriate handler function.
    case "mysql_list_tables":
      return await this.handleListTables(args);
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It states the tool lists tables, which implies a read-only operation, but doesn't disclose any behavioral traits such as whether it requires authentication, potential rate limits, error handling, or the format of returned data. The description is minimal and lacks essential context for safe and effective use.

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 functionality without any wasted words. It is front-loaded with the main action ('List all tables') and appropriately sized for a simple tool. Every part of the sentence earns its place by specifying scope.

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 tool's simplicity (1 optional parameter, no output schema, no annotations), the description is incomplete. It doesn't explain what the output looks like (e.g., list of table names, metadata), any dependencies like requiring a connection, or error scenarios. For a tool with no annotations or output schema, more context is needed to ensure the agent can use it correctly.

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 parameter 'database' fully documented in the schema as 'Database name (uses current database if not specified).' The description adds no additional meaning beyond this, as it only repeats the same information about current or specified database. With high schema coverage, the baseline is 3, and the description doesn't compensate with extra details.

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 ('List all tables') and resource ('in the current or specified database'), making the purpose immediately understandable. It distinguishes from siblings like mysql_list_databases (which lists databases) and mysql_describe_table (which describes a specific table), though it doesn't explicitly mention these alternatives. The description is specific but lacks explicit sibling differentiation.

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 suggests when to specify the database parameter. However, it provides no explicit guidance on when to use this tool versus alternatives like mysql_list_databases or mysql_query, nor does it mention prerequisites such as needing an active connection. The guidance is implied but incomplete.

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

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