Skip to main content
Glama
ImRieul

MySQL MCP Server

by ImRieul

describe_all_tables

Show the schema of all tables in a database with a single query. Returns column details for every table, providing a comprehensive overview of the database structure.

Instructions

Show the schema of all tables at once. Much more efficient than calling describe_table for each table individually. Warning: response can be large for databases with many tables — prefer describe_table for specific tables when possible.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNoDatabase name. Uses the current database if omitted.

Implementation Reference

  • The handler function that executes the describe_all_tables tool logic. It validates input, queries information_schema.COLUMNS for all tables in the database, groups columns by table, and returns formatted output.
    export function createDescribeAllTablesHandler(runner: QueryRunner) {
      return async ({ database }: { database?: string }) => {
        if (database) {
          const dbValidation = validateIdentifier(database, 'Database');
          if (!dbValidation.valid) {
            return {
              isError: true as const,
              content: [{ type: 'text' as const, text: dbValidation.message! }],
            };
          }
        }
    
        try {
          return await runner.withConnection(async (query) => {
            const db = await resolveDatabase(query, database);
            if (!db) {
              return {
                isError: true as const,
                content: [
                  {
                    type: 'text' as const,
                    text: 'Error: No database selected. Specify a database name or set MYSQL_DATABASE.',
                  },
                ],
              };
            }
    
            const sql = `SELECT TABLE_NAME, COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_KEY, COLUMN_DEFAULT, EXTRA, COLUMN_COMMENT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = ${quoteStringValue(db)} ORDER BY TABLE_NAME, ORDINAL_POSITION`;
            const [rows] = await query(sql);
            const typedRows = rows as Record<string, unknown>[];
    
            if (typedRows.length === 0) {
              return { content: [{ type: 'text' as const, text: '(no tables)' }] };
            }
    
            const tableMap = new Map<string, string[]>();
            for (const r of typedRows) {
              const tableName = String(r.TABLE_NAME);
              const line = formatColumn({
                name: String(r.COLUMN_NAME),
                type: String(r.COLUMN_TYPE),
                nullable: r.IS_NULLABLE === 'YES',
                key: String(r.COLUMN_KEY ?? ''),
                defaultValue: r.COLUMN_DEFAULT,
                extra: String(r.EXTRA ?? ''),
                comment: String(r.COLUMN_COMMENT ?? ''),
              });
              if (!tableMap.has(tableName)) {
                tableMap.set(tableName, []);
              }
              tableMap.get(tableName)!.push(line);
            }
    
            const parts = Array.from(tableMap.entries()).map(([table, lines]) => `${table}:\n${lines.join('\n')}`);
    
            return {
              content: [{ type: 'text' as const, text: parts.join('\n\n') }],
            };
          });
        } catch (error) {
          return {
            isError: true as const,
            content: [{ type: 'text' as const, text: formatError(error) }],
          };
        }
      };
    }
  • Input schema and description for the describe_all_tables tool. Accepts an optional 'database' string parameter.
    export const describeAllTablesToolConfig = {
      title: 'Describe All Tables',
      description:
        'Show the schema of all tables at once. Much more efficient than calling describe_table for each table individually. ' +
        'Warning: response can be large for databases with many tables — prefer describe_table for specific tables when possible.',
      inputSchema: {
        database: z.string().optional().describe('Database name. Uses the current database if omitted.'),
      },
    };
  • Registration of describe_all_tables with the MCP server, including its name, description, input schema, and handler.
    server.tool(
      describeAllTablesToolName,
      describeAllTablesToolConfig.description,
      describeAllTablesToolConfig.inputSchema,
      createDescribeAllTablesHandler(runner),
    );
  • Import of describeAllTablesToolName, describeAllTablesToolConfig, and createDescribeAllTablesHandler from the module.
    import {
      describeAllTablesToolName,
      describeAllTablesToolConfig,
      createDescribeAllTablesHandler,
    } from './describe-all-tables.js';
  • The formatColumn helper used by describe_all_tables to format each column's output string (name, type, constraints, defaults, etc.).
    export interface ColumnInfo {
      name: string;
      type: string;
      nullable: boolean;
      key: string;
      defaultValue: unknown;
      extra: string;
      comment: string;
    }
    
    export function formatColumn(col: ColumnInfo): string {
      let result = `${col.name} ${col.type}`;
      if (!col.nullable) result += ' NOT NULL';
      if (col.key === 'PRI') result += ' PK';
      else if (col.key === 'UNI') result += ' UNIQUE';
      else if (col.key === 'MUL') result += ' INDEX';
      if (col.defaultValue != null) result += ` DEFAULT ${col.defaultValue}`;
      if (col.extra) result += ` ${col.extra}`;
      if (col.comment) result += ` -- ${col.comment}`;
      return result;
    }
Behavior3/5

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

No annotations provided, so description carries full burden. Warns about large response size but does not mention permissions, side effects, or output format. Adequate but not comprehensive.

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?

Two sentences plus a warning, every sentence adds value, front-loaded with purpose. Highly concise and structured.

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

Completeness4/5

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

For a simple tool with one optional parameter and no output schema, the description covers purpose, efficiency comparison, and size warning. Could optionally describe response structure, but largely complete.

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?

Schema description coverage is 100%, and description adds no new parameter meaning beyond what the schema already provides. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states 'Show the schema of all tables at once' with specific verb and resource, explicitly distinguishes from sibling tool 'describe_table'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly recommends using describe_table for specific tables when efficient, and warns about large responses, providing clear when-to-use and when-not-to-use guidance.

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

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