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);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't describe any behavioral traits, such as whether it's read-only (implied by 'list'), what permissions are required, how results are returned (e.g., format, pagination), or error handling. This leaves significant gaps for an agent to understand the tool's behavior.

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 in Chinese that directly states the tool's purpose without any unnecessary words. It's front-loaded and efficiently communicates the core functionality, making it easy for an agent to parse and understand quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (one optional parameter) and no output schema, the description is minimally adequate but lacks completeness. It doesn't explain return values (e.g., list format, error cases) or behavioral context, which is important since no annotations are provided. However, the simplicity of the tool means the description isn't entirely inadequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with the single parameter 'database' fully documented in the schema as optional and defaulting to the current connection. The description doesn't add any additional meaning beyond what the schema provides, such as examples or constraints, but the schema already covers the parameter adequately, meeting the baseline for high coverage.

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 action ('列出' - list) and resource ('指定数据库的所有表' - all tables of a specified database), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'mysql_list_databases' or 'mysql_describe_table', but the specificity about tables provides some implicit distinction.

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?

The description provides no guidance on when to use this tool versus alternatives like 'mysql_list_databases' (for listing databases) or 'mysql_describe_table' (for table details). There's no mention of prerequisites, such as requiring an active connection via 'mysql_connect', or context about when listing tables is appropriate versus other operations.

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

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