Skip to main content
Glama
nilsir

MCP Server MySQL

by nilsir

list_tables

Retrieve all tables in a MySQL database to understand its structure and available data. Specify a database name or use the current connection to view tables.

Instructions

List all tables in the current or specified database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNoDatabase name (optional, uses current if not specified)

Implementation Reference

  • The handler function for the 'list_tables' tool. It connects to the MySQL pool, executes 'SHOW TABLES' (optionally from a specific database), extracts table names from the result rows, and returns a structured response with the list of tables.
    async ({ database }) => {
      const p = await getPool();
    
      let sql = "SHOW TABLES";
      if (database) {
        sql = `SHOW TABLES FROM \`${database}\``;
      }
    
      const [rows] = await p.query<RowDataPacket[]>(sql);
    
      const tables = rows.map((row) => Object.values(row)[0] as string);
      const output = { tables, database: database || null };
    
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify(tables, null, 2),
          },
        ],
        structuredContent: output,
      };
    }
  • Input schema for the 'list_tables' tool using Zod, defining an optional 'database' parameter.
    {
      database: z.string().optional().describe("Database name (optional, uses current if not specified)"),
    },
  • src/index.ts:233-262 (registration)
    Registration of the 'list_tables' tool on the MCP server, specifying name, description, input schema, and handler function.
    server.tool(
      "list_tables",
      "List all tables in the current or specified database",
      {
        database: z.string().optional().describe("Database name (optional, uses current if not specified)"),
      },
      async ({ database }) => {
        const p = await getPool();
    
        let sql = "SHOW TABLES";
        if (database) {
          sql = `SHOW TABLES FROM \`${database}\``;
        }
    
        const [rows] = await p.query<RowDataPacket[]>(sql);
    
        const tables = rows.map((row) => Object.values(row)[0] as string);
        const output = { tables, database: database || null };
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(tables, null, 2),
            },
          ],
          structuredContent: output,
        };
      }
    );
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('List all tables') but doesn't describe behavioral traits such as output format (e.g., list of names, metadata), pagination, permissions required, or error handling. For a tool with no annotations, this leaves significant gaps in understanding how it behaves.

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 that efficiently conveys the tool's purpose without unnecessary words. It is front-loaded with the core action and appropriately sized for a simple tool, earning its place with zero waste.

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, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks details on behavioral traits (e.g., output format) and usage guidelines. With no annotations or output schema, the description should do more to compensate, but it meets the bare minimum for a simple list operation.

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 input schema has 100% description coverage, with the 'database' parameter documented as optional and defaulting to the current database. The description adds minimal value beyond the schema by mentioning 'current or specified database', which aligns with the schema's description. Baseline is 3 since the schema does the heavy lifting, and no additional parameter semantics are provided.

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 verb ('List') and resource ('tables'), specifying scope ('all tables in the current or specified database'). It distinguishes from siblings like 'list_databases' (which lists databases) and 'describe_table' (which describes a specific table), though it doesn't explicitly mention these distinctions. The purpose is specific and actionable.

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. It doesn't mention siblings like 'list_databases' for listing databases or 'query' for querying table contents, nor does it specify prerequisites (e.g., needing a connection). Usage is implied by the action, but no explicit context or exclusions are provided.

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

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