Skip to main content
Glama

MySQL ReadOnly MCP Server

by zhaojw-php

mysql_list_databases

Retrieve all database names from a MySQL server to identify available data sources for read-only queries.

Instructions

List all available databases

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "properties": {}, "type": "object" }

Implementation Reference

  • Tool handler for 'mysql_list_databases' that invokes MySQLConnection.listDatabases() and formats the result as JSON response.
    case 'mysql_list_databases': { const result = await mysqlConnection.listDatabases(); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
  • src/index.ts:77-84 (registration)
    Registration of the 'mysql_list_databases' tool in the listTools response, including name, description, and input schema.
    { name: 'mysql_list_databases', description: 'List all available databases', inputSchema: { type: 'object', properties: {}, }, },
  • Core implementation logic for listing databases: executes 'SHOW DATABASES', extracts names, and filters out system databases.
    async listDatabases(): Promise<string[]> { const query = 'SHOW DATABASES'; const result = await this.executeQuery(query); // Extract database names from result return result.rows.map((row: any) => { const key = Object.keys(row)[0]; // Get the first column name return row[key]; }).filter((db: string) => { // Filter out system databases return !['information_schema', 'mysql', 'performance_schema', 'sys'].includes(db); }); }

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/zhaojw-php/mysql-readonly-mcp'

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