Skip to main content
Glama
devakone

MySQL Query MCP Server

by devakone

environments

List available MySQL database environments to identify and access datasets for querying and analysis within the MySQL Query MCP Server.

Instructions

List available MySQL database environments

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The runEnvironmentsTool function that implements the core logic for the 'environments' tool. It checks environment variables for database configurations across local, development, staging, and production environments and returns a list of available ones.
    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 metadata exports: name, description, and Zod schema for input validation (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's capabilities.tools dictionary, defining its description and input schema.
    [environmentsToolName]: { description: environmentsToolDescription, inputSchema: { type: "object", properties: {}, required: [], }, },
  • src/index.ts:236-242 (registration)
    Dispatch case in the CallToolRequestSchema handler that validates arguments using the tool's schema and executes the runEnvironmentsTool handler.
    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); }
  • Zod enum definition for Environment type, used by the environments tool to iterate over possible environments.
    // Environment types export const Environment = z.enum(['local', 'development', 'staging', 'production']); export type Environment = z.infer<typeof Environment>;

Other Tools

Related 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