Skip to main content
Glama

MySQL MCP Server

mysql_list_tables

Retrieve a list of all tables in a specified MySQL database using this tool. Helps users quickly manage and organize database structures for efficient table management.

Instructions

列出指定数据库的所有表

Input Schema

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

Input Schema (JSON Schema)

{ "properties": { "database": { "description": "数据库名称(可选,使用当前连接的数据库)", "type": "string" } }, "type": "object" }

Implementation Reference

  • MCP tool handler function that executes the mysql_list_tables tool by delegating to DatabaseManager.listTables and formatting the response as text 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 helper function in DatabaseManager that queries the information_schema to retrieve the list of 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.
    inputSchema: { type: 'object', properties: { database: { type: 'string', description: '数据库名称(可选,使用当前连接的数据库)' }, }, },
  • src/server.ts:95-104 (registration)
    Tool registration in the ListTools response, including name, description, and input schema.
    { name: 'mysql_list_tables', description: '列出指定数据库的所有表', inputSchema: { type: 'object', properties: { database: { type: 'string', description: '数据库名称(可选,使用当前连接的数据库)' }, }, }, },
  • src/server.ts:243-244 (registration)
    Dispatch case in the CallToolRequest handler switch statement that routes to the mysql_list_tables 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