Skip to main content
Glama
xiangma9712

MySQL MCP Server

list_tables

Retrieve a list of database tables to view available data structures and understand database organization for query planning.

Instructions

Retrieves a list of tables in the database.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler for the 'list_tables' tool: executes a SQL query to fetch table names from information_schema.TABLES for the current database and returns the result as JSON.
    case "list_tables": {
      const [rows] = await connection.query(
        "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = ?",
        [process.env.MYSQL_DATABASE]
      );
      return {
        content: [{ type: "text", text: JSON.stringify(rows, null, 2) }],
        isError: false,
      };
    }
  • src/index.ts:61-67 (registration)
    Registration of the 'list_tables' tool in the ListToolsRequestHandler response, defining its name, description, and empty input schema (no parameters required).
    {
      name: "list_tables",
      description: "Retrieves a list of tables in the database.",
      inputSchema: {
        type: "object",
      },
    },
  • Schema definition for 'list_tables' tool: input is an empty object (no required parameters).
    {
      name: "list_tables",
      description: "Retrieves a list of tables in the database.",
      inputSchema: {
        type: "object",
      },
    },
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/xiangma9712/mysql-mcp-server'

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