Skip to main content
Glama
nilsir

MCP Server MySQL

by nilsir

use_database

Switch between MySQL databases to manage, query, or modify data in different database contexts within the MCP Server MySQL environment.

Instructions

Switch to a different database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseYesDatabase name

Implementation Reference

  • The handler function for the 'use_database' tool. It acquires a database pool connection, executes the 'USE `database`' SQL command to switch databases, constructs a success output, and returns a structured response with text content.
    async ({ database }) => { const p = await getPool(); await p.query(`USE \`${database}\``); const output = { success: true, database }; return { content: [ { type: "text" as const, text: `Switched to database ${database}`, }, ], structuredContent: output, }; }
  • Input schema definition using Zod for the 'use_database' tool, requiring a 'database' string parameter.
    { database: z.string().describe("Database name"), },
  • src/index.ts:495-518 (registration)
    Registration of the 'use_database' tool via server.tool(), including name, description, input schema, and handler function.
    server.tool( "use_database", "Switch to a different database", { database: z.string().describe("Database name"), }, async ({ database }) => { const p = await getPool(); await p.query(`USE \`${database}\``); const output = { success: true, database }; return { content: [ { type: "text" as const, text: `Switched to database ${database}`, }, ], 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