Skip to main content
Glama
sajithrw

MCP MySQL Server

by sajithrw

mysql_list_databases

Retrieve a complete list of all databases available on your MySQL server for database management and connection setup.

Instructions

List all databases on the MySQL server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function implementing the mysql_list_databases tool. It checks for an active MySQL connection, executes the 'SHOW DATABASES' SQL query, formats the results as JSON, and returns them in the MCP response format.
    private async handleListDatabases() { if (!this.pool) { throw new Error("Not connected to MySQL. Use mysql_connect first."); } try { const [results] = await this.pool.execute("SHOW DATABASES"); return { content: [ { type: "text", text: `Available databases:\n${JSON.stringify(results, null, 2)}`, }, ], }; } catch (error) { throw new Error(`Failed to list databases: ${error instanceof Error ? error.message : String(error)}`); } }
  • src/index.ts:157-164 (registration)
    Tool registration in the ListTools response, including name, description, and input schema (empty properties, no required parameters).
    { name: "mysql_list_databases", description: "List all databases on the MySQL server", inputSchema: { type: "object", properties: {}, }, },
  • Input schema definition for the mysql_list_databases tool, specifying an empty object (no input parameters needed).
    inputSchema: { type: "object", properties: {}, },
  • src/index.ts:253-254 (registration)
    Dispatch/registration in the CallToolRequest switch statement, routing calls to mysql_list_databases to the handleListDatabases function.
    case "mysql_list_databases": return await this.handleListDatabases();

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

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