Skip to main content
Glama
nilsir

MCP Server MySQL

by nilsir

list_databases

Retrieve all database names from a MySQL server to manage database inventory and access permissions.

Instructions

List all databases on the MySQL server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function that gets the MySQL connection pool, executes 'SHOW DATABASES' query, extracts database names, and returns formatted text and structured content.
    async () => { const p = await getPool(); const [rows] = await p.query<RowDataPacket[]>("SHOW DATABASES"); const databases = rows.map((row) => row.Database as string); const output = { databases }; return { content: [ { type: "text" as const, text: JSON.stringify(databases, null, 2), }, ], structuredContent: output, }; }
  • Input schema for the list_databases tool, which requires no parameters.
    {},
  • src/index.ts:209-230 (registration)
    Registration of the list_databases tool using McpServer.tool method, including name, description, schema, and handler.
    server.tool( "list_databases", "List all databases on the MySQL server", {}, async () => { const p = await getPool(); const [rows] = await p.query<RowDataPacket[]>("SHOW DATABASES"); const databases = rows.map((row) => row.Database as string); const output = { databases }; return { content: [ { type: "text" as const, text: JSON.stringify(databases, null, 2), }, ], structuredContent: output, }; } );

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