Skip to main content
Glama
sussa3007

MySql MCP Server

list_tables

Retrieve a list of all tables in the current MySQL database. Use this tool to quickly access and manage table names for efficient database navigation and query execution.

Instructions

Get a list of tables in the current database.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
random_stringYesDummy parameter for no-parameter tools

Implementation Reference

  • The handler for the "list_tables" tool within the CallToolRequestSchema switch statement. It executes a "SHOW TABLES" query using the shared executeQuery function and returns the result as JSON or an error message.
    case "list_tables": {
      try {
        const rows = await executeQuery("SHOW TABLES");
        return {
          content: [{ type: "text", text: JSON.stringify(rows, null, 2) }],
          isError: false
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text:
                error instanceof Error
                  ? error.message
                  : "Unknown error occurred"
            }
          ],
          isError: true
        };
      }
    }
  • src/index.ts:203-216 (registration)
    Registration of the "list_tables" tool in the ListToolsRequestSchema response. Includes the tool name, description, and input schema definition (using a dummy parameter since no real inputs are needed).
    {
      name: "list_tables",
      description: "Get a list of tables in the current database.",
      inputSchema: {
        type: "object",
        properties: {
          random_string: {
            type: "string",
            description: "Dummy parameter for no-parameter tools"
          }
        },
        required: ["random_string"]
      }
    },
  • Input schema for the "list_tables" tool, which requires a dummy 'random_string' parameter as it's a no-parameter tool.
    inputSchema: {
      type: "object",
      properties: {
        random_string: {
          type: "string",
          description: "Dummy parameter for no-parameter tools"
        }
      },
      required: ["random_string"]
    }
  • Shared helper function 'executeQuery' used by the list_tables handler to safely execute the SQL query, including read-only mode validation.
    async function executeQuery(sql: string, params: any[] = []): Promise<any> {
      const conn = await getConnection();
    
      // Check if in readonly mode and validate query type
      if (connectionConfig.readonly) {
        const queryType = getQueryType(sql);
        if (isWriteOperation(queryType)) {
          throw new Error(
            "Server is in read-only mode. Write operations are not allowed."
          );
        }
      }
    
      // Execute the query
      const [rows] = await conn.query(sql, params);
      return rows;
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.3/5.0
Behavior2/5

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

No annotations are present, so the description bears full responsibility. It fails to disclose the dummy parameter requirement, return format, or safety profile, leaving behavioral gaps.

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 very concise with one short sentence. While efficient, it omits return type info and dummy parameter mention, but for a simple list tool it's acceptable.

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?

Without output schema, the description should explain return values (e.g., array of table names). It also fails to clarify the required dummy parameter, making it incomplete 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% because the dummy parameter's description explains its purpose. The tool description adds no parameter details, meeting the baseline for high coverage.

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 verb 'Get' and resource 'list of tables' with context 'current database', distinguishing it from siblings like list_databases and describe_table.

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 using this tool to browse tables but provides no explicit when-to-use or when-not-to-use guidance compared to siblings. It lacks exclusions or context about prerequisites like setting a database first.

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

Deploy Server

Other Tools

Related Tools