Skip to main content
Glama
Malove86

MCP MySQL Server

by Malove86

list_tables

Retrieve a complete list of tables in a MySQL database using the MCP MySQL Server interface, enabling efficient database management and navigation.

Instructions

List all tables in the database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
random_stringNoDummy parameter for no-parameter tools

Implementation Reference

  • The handler function for the 'list_tables' tool. It ensures a database connection, executes 'SHOW TABLES' query using the MySQL connection pool, logs the operation, and returns the list of tables as a formatted JSON string in the MCP response format.
    private async handleListTables(requestId: string) {
      await this.ensureConnection();
    
      try {
        console.error(`[${requestId}] Executing SHOW TABLES`);
        const [rows] = await this.pool!.query('SHOW TABLES');
        console.error(`[${requestId}] SHOW TABLES completed, found ${Array.isArray(rows) ? rows.length : 0} tables`);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(rows, null, 2),
            },
          ],
        };
      } catch (error) {
        const errorMsg = getErrorMessage(error);
        console.error(`[${requestId}] Failed to list tables: ${errorMsg}`);
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to list tables: ${errorMsg}`
        );
      }
    }
  • src/index.ts:236-249 (registration)
    Registration of the 'list_tables' tool in the ListToolsRequestSchema handler. Defines the tool name, description, and input schema (with no required parameters).
    {
      name: 'list_tables',
      description: 'List all tables in the database',
      inputSchema: {
        type: 'object',
        properties: {
          random_string: {
            type: 'string',
            description: 'Dummy parameter for no-parameter tools',
          }
        },
        required: [], // 修改为可选参数
      },
    },
  • Input schema definition for the 'list_tables' tool, specifying an optional dummy parameter since the tool takes no real inputs.
    inputSchema: {
      type: 'object',
      properties: {
        random_string: {
          type: 'string',
          description: 'Dummy parameter for no-parameter tools',
        }
      },
      required: [], // 修改为可选参数
    },
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action. It doesn't disclose behavioral traits like whether this requires database connection, returns paginated results, includes system tables, or has 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.

Conciseness5/5

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

The description is a single, clear sentence with no wasted words. It's front-loaded with the essential information and earns its place efficiently.

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?

For a database listing tool with no annotations and no output schema, the description is insufficient. It doesn't explain what information is returned (table names only? metadata?), format, or any constraints, leaving significant gaps for an agent.

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 required parameters (one dummy parameter with 100% schema coverage). The description appropriately doesn't discuss parameters since none are needed for the core functionality, though it could mention the dummy parameter is optional.

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 ('all tables in the database'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'describe_table' or 'query', which prevents a perfect score.

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?

No guidance is provided on when to use this tool versus alternatives like 'describe_table' (for table details) or 'query' (for executing SQL). The description only states what it does, not when it's appropriate.

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

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

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