Skip to main content
Glama
devakone

MySQL Query MCP Server

by devakone

environments

List available MySQL database environments to select and connect to specific databases for querying and data exploration.

Instructions

List available MySQL database environments

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function that executes the 'environments' tool logic: filters and lists available MySQL environments based on configured environment variables.
    export async function runEnvironmentsTool(_params?: z.infer<typeof EnvironmentsToolSchema>): Promise<{ content: { type: string; text: string }[] }> { try { debug('=== Running environments tool ==='); // Log all environment variables for debugging const envVars = Object.keys(process.env) .filter(key => key.includes('_DB_')) .reduce((acc, key) => ({ ...acc, [key]: process.env[key] }), {}); debug('Found DB-related environment variables:', envVars); const environments = Object.values(Environment.enum).filter(env => { const envPrefix = ENV_PREFIX_MAP[env]; // Check only for required variables that pools.ts uses const hasConfig = !!( process.env[`${envPrefix}_DB_HOST`] && process.env[`${envPrefix}_DB_USER`] && process.env[`${envPrefix}_DB_NAME`] ); debug(`Checking ${env} (${envPrefix}):`, { prefix: envPrefix, host: process.env[`${envPrefix}_DB_HOST`], user: process.env[`${envPrefix}_DB_USER`], db: process.env[`${envPrefix}_DB_NAME`], hasConfig }); return hasConfig; }); debug('Available environments:', environments); // Return the environments in the format expected by the MCP protocol return { content: [{ type: "text", text: JSON.stringify({ environments, count: environments.length, debug: { envVars, environments } }, null, 2), }], }; } catch (error) { debug('Error in environments tool:', error); throw error; } }
  • Tool name, description, and Zod input schema definition (empty object since no parameters required).
    export const environmentsToolName = "environments"; export const environmentsToolDescription = "List available MySQL database environments"; export const EnvironmentsToolSchema = z.object({});
  • src/index.ts:138-145 (registration)
    Registration of the 'environments' tool in the MCP server capabilities, including description and input schema.
    [environmentsToolName]: { description: environmentsToolDescription, inputSchema: { type: "object", properties: {}, required: [], }, },
  • src/index.ts:236-242 (registration)
    Dispatch handler in CallToolRequestSchema that validates arguments and calls the runEnvironmentsTool function.
    case environmentsToolName: { debug('Validating environments tool arguments...'); const validated = EnvironmentsToolSchema.parse(args); debug('Validated environments tool args:', validated); debug('Executing environments tool...'); return await runEnvironmentsTool(validated); }
  • Type definition for the 'environments' tool in the MySQLTools interface.
    environments: Tool;

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/devakone/mysql-query-mcp-server'

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