Skip to main content
Glama

MySQL ReadOnly MCP Server

by zhaojw-php

mysql_list_tables

Retrieve a list of all database tables to understand database structure and available data for querying in MySQL databases.

Instructions

List all tables in the database

Input Schema

NameRequiredDescriptionDefault
databaseNoDatabase name (optional, defaults to configured database)

Input Schema (JSON Schema)

{ "properties": { "database": { "description": "Database name (optional, defaults to configured database)", "type": "string" } }, "type": "object" }

Implementation Reference

  • Core handler function that executes the 'SHOW TABLES' query to list tables in the specified or default database, extracts table names from the result.
    async listTables(database?: string): Promise<string[]> { const dbName = database || this.config.database; if (!dbName) { throw new Error('No database specified'); } const query = `SHOW TABLES FROM \`${dbName}\``; const result = await this.executeQuery(query); // Extract table names from result return result.rows.map((row: any) => { const key = Object.keys(row)[0]; // Get the first column name return row[key]; }); }
  • Tool dispatch handler case that extracts arguments, calls the MySQL connection's listTables method, and formats the response.
    case 'mysql_list_tables': { const { database } = args as { database?: string }; const result = await mysqlConnection.listTables(database); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
  • src/index.ts:46-58 (registration)
    Registers the mysql_list_tables tool in the ListTools response, including its description and input schema.
    { name: 'mysql_list_tables', description: 'List all tables in the database', inputSchema: { type: 'object', properties: { database: { type: 'string', description: 'Database name (optional, defaults to configured database)', }, }, }, },
  • Defines the input schema for the mysql_list_tables tool.
    { name: 'mysql_list_tables', description: 'List all tables in the database', inputSchema: { type: 'object', properties: { database: { type: 'string', description: 'Database name (optional, defaults to configured database)', }, }, }, },

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/zhaojw-php/mysql-readonly-mcp'

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