Skip to main content
Glama
pickstar-2002

MySQL MCP Server

mysql_list_tables

List all tables in a MySQL database to view structure and manage data organization. Specify a database name or use the current connection.

Instructions

列出指定数据库的所有表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNo数据库名称(可选,使用当前连接的数据库)

Implementation Reference

  • The handler function for the 'mysql_list_tables' tool. It calls DatabaseManager.listTables and returns the formatted result as tool content.
    private async handleListTables(args: { database?: string }): Promise<any> { const tables = await this.dbManager.listTables(args.database); return { content: [ { type: 'text', text: `表列表:\n${JSON.stringify(tables, null, 2)}`, }, ], }; }
  • Core implementation in DatabaseManager that executes the SQL query against information_schema.TABLES to list tables in the specified database.
    async listTables(database?: string): Promise<TableInfo[]> { const dbName = database || this.config?.database; if (!dbName) { throw new Error('请指定数据库名称'); } const result = await this.query(` SELECT TABLE_NAME as name, ENGINE as engine, TABLE_ROWS as rows, DATA_LENGTH as dataLength, INDEX_LENGTH as indexLength, TABLE_COMMENT as comment FROM information_schema.TABLES WHERE TABLE_SCHEMA = ? AND TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME `, [dbName]); return result.rows as TableInfo[]; }
  • Input schema definition for the 'mysql_list_tables' tool, specifying optional 'database' parameter.
    name: 'mysql_list_tables', description: '列出指定数据库的所有表', inputSchema: { type: 'object', properties: { database: { type: 'string', description: '数据库名称(可选,使用当前连接的数据库)' }, }, }, },
  • src/server.ts:243-244 (registration)
    Switch case registration that routes 'mysql_list_tables' tool calls to the handleListTables handler.
    case 'mysql_list_tables': return await this.handleListTables(args as any);

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

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