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;
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action. It doesn't disclose behavioral traits like whether this is a read-only operation, if it requires authentication, what format the list returns in, or any rate limits. The description is minimal and lacks important operational context.

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, efficient sentence with zero waste. It's appropriately sized for a simple tool and front-loads the essential information without unnecessary elaboration.

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

Completeness3/5

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

For a zero-parameter tool with no output schema, the description provides the basic purpose but lacks completeness. Without annotations, it should ideally mention behavioral aspects like read-only nature or return format. The simplicity of the tool keeps it from being completely inadequate, but there are clear gaps in operational context.

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 0 parameters with 100% schema description coverage, so the schema fully documents the absence of parameters. The description appropriately doesn't add parameter details beyond what's already covered, maintaining a baseline score of 4 for zero-parameter tools.

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

Purpose4/5

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

The description clearly states the action ('List') and resource ('available MySQL database environments'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'info' or 'query', which might also retrieve information about MySQL environments.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus the 'info' or 'query' siblings. There's no mention of alternatives, prerequisites, or specific contexts where this tool is preferred over others.

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