Skip to main content
Glama
Atomzzm
by Atomzzm

list_tables

Retrieve all table names from a MySQL database to understand its structure and available data.

Instructions

List all tables in the database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that ensures a database connection, executes 'SHOW TABLES' query, and returns the list of tables as JSON.
    private async handleListTables() {
      await this.ensureConnection();
    
      try {
        const [rows] = await this.connection!.query('SHOW TABLES');
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(rows, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to list tables: ${getErrorMessage(error)}`
        );
      }
    }
  • src/index.ts:167-175 (registration)
    Registers the 'list_tables' tool in the ListTools response, including its description and input schema (no parameters required).
    {
      name: 'list_tables',
      description: 'List all tables in the database',
      inputSchema: {
        type: 'object',
        properties: {},
        required: [],
      },
    },
  • Defines the input schema for the 'list_tables' tool, which requires no parameters.
    inputSchema: {
      type: 'object',
      properties: {},
      required: [],
    },
  • Dispatches to the handleListTables method in the CallToolRequestHandler switch statement.
    case 'list_tables':
      return await this.handleListTables();

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

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