Skip to main content
Glama
devakone

MySQL Query MCP Server

by devakone

environments

Retrieve a list of available MySQL database environments to identify which databases can be queried.

Instructions

List available MySQL database environments

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler that checks environment variables for each environment (local, development, staging, production) and returns a list of configured environments with DB_HOST, DB_USER, and DB_NAME.
    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;
      }
    }
  • Zod schema for the environments tool (empty object - no input parameters needed).
    export const EnvironmentsToolSchema = z.object({});
  • src/index.ts:30-35 (registration)
    Import of the environments tool components into the main server file.
    import {
      environmentsToolName,
      environmentsToolDescription,
      EnvironmentsToolSchema,
      runEnvironmentsTool,
    } from "./tools/environments.js";
  • src/index.ts:221-227 (registration)
    CallTool handler case that routes 'environments' tool requests to runEnvironmentsTool after schema validation.
    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);
    }
  • src/index.ts:183-191 (registration)
    ListTools handler registration of the environments tool (no input parameters required).
    {
      name: environmentsToolName,
      description: environmentsToolDescription,
      inputSchema: {
        type: "object",
        properties: {},
        required: [],
      },
    },
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description clearly indicates a read-only listing operation with no side effects. With no annotations provided, this straightforward disclosure is sufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence with no unnecessary words. It is front-loaded with the action and resource.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (no parameters, no output schema), the description adequately explains its purpose. It could optionally hint at the format of the list, but not required.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has no parameters, so schema coverage is 100%. The description adds no parameter info, but none is needed; baseline score for zero parameters is 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the specific verb 'List' and clearly identifies the resource as 'available MySQL database environments'. It distinguishes from sibling tools 'info' and 'query' by implying this is a listing operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use when the agent needs to see available environments before running queries or getting info, but does not explicitly state when to use or avoid this tool relative to siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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