Skip to main content
Glama
devakone

MySQL Query MCP Server

by devakone

info

Retrieve MySQL database information from specified environments to understand database structures and configurations for query planning and data investigation.

Instructions

Get information about MySQL databases

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
environmentYesTarget environment to get information from

Implementation Reference

  • The handler function that implements the core logic of the 'info' tool: connects to the specified MySQL environment pool, executes queries to retrieve server version, status, variables, processlist, and databases, formats the information as JSON, and returns it.
    export async function runInfoTool(params: z.infer<typeof InfoToolSchema>): Promise<{ content: { type: string; text: string }[] }> {
      const { environment } = params;
    
      // Get connection pool
      const pool = pools.get(environment);
      if (!pool) {
        throw new Error(`No connection pool available for environment: ${environment}`);
      }
    
      try {
        const connection = await pool.getConnection();
        
        try {
          // Get server version
          const [versionRows] = await connection.query("SELECT VERSION() as version") as [any[], any[]];
          const version = versionRows[0].version;
    
          // Get server status
          const [statusRows] = await connection.query("SHOW STATUS") as [any[], any[]];
          const status = statusRows.reduce((acc: Record<string, string>, row: any) => {
            acc[row.Variable_name] = row.Value;
            return acc;
          }, {});
    
          // Get server variables
          const [variableRows] = await connection.query("SHOW VARIABLES") as [any[], any[]];
          const variables = variableRows.reduce((acc: Record<string, string>, row: any) => {
            acc[row.Variable_name] = row.Value;
            return acc;
          }, {});
    
          // Get process list
          const [processRows] = await connection.query("SHOW PROCESSLIST") as [any[], any[]];
          const processlist = processRows;
    
          // Get databases
          const [databaseRows] = await connection.query("SHOW DATABASES") as [any[], any[]];
          const databases = databaseRows.map((row: any) => row.Database);
    
          const info: DatabaseInfo = {
            version,
            status: status.Uptime ? `Up ${status.Uptime} seconds` : "Unknown",
            variables,
            processlist,
            databases,
          };
    
          return {
            content: [{
              type: "text",
              text: JSON.stringify(info, null, 2),
            }],
          };
        } finally {
          connection.release();
        }
      } catch (error) {
        const message = error instanceof Error ? error.message : "Unknown error occurred";
        throw new Error(`Failed to get database info: ${message}`);
      }
    } 
  • Zod schema definition for the 'info' tool input parameters, requiring an 'environment' from the enum ['local', 'development', 'staging', 'production'].
    // Info parameters schema
    export const InfoParams = z.object({
      environment: Environment,
    });
    export type InfoParameters = z.infer<typeof InfoParams>;
  • src/index.ts:65-72 (registration)
    Imports the 'info' tool's name, description, schema, and handler function from src/tools/info.js for use in MCP server registration.
    debug('Importing info tool...');
    import {
      infoToolName,
      infoToolDescription,
      InfoToolSchema,
      runInfoTool,
    } from "./tools/info.js";
    debug('Info tool imported:', { infoToolName });
  • src/index.ts:124-137 (registration)
    Registers the 'info' tool in the MCP server's capabilities object, specifying its description and input schema.
    [infoToolName]: {
      description: infoToolDescription,
      inputSchema: {
        type: "object",
        properties: {
          environment: {
            type: "string",
            enum: ["local", "development", "staging", "production"],
            description: "Target environment to get information from",
          },
        },
        required: ["environment"],
      },
    },
  • src/index.ts:229-235 (registration)
    Handles 'info' tool calls in the MCP CallToolRequestSchema handler by validating arguments with InfoToolSchema and invoking runInfoTool.
    case infoToolName: {
      debug('Validating info tool arguments...');
      const validated = InfoToolSchema.parse(args);
      debug('Validated info tool args:', validated);
      debug('Executing info tool...');
      return await runInfoTool(validated);
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'gets' information, implying a read-only operation, but doesn't specify what type of information (e.g., schema, status, metrics), permissions required, rate limits, or response format. This leaves significant gaps in understanding the tool's behavior.

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 that directly states the tool's purpose without any unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what information is returned (e.g., database details, tables, performance data), how it's formatted, or any behavioral traits like error handling. For a tool with no structured context, this minimal description is insufficient.

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

Parameters3/5

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

The input schema has 100% description coverage, with the single parameter 'environment' fully documented in the schema. The description doesn't add any meaning beyond this, such as explaining why environment selection matters or how it affects the information retrieved. Given the high schema coverage, a baseline score of 3 is appropriate.

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 tool's purpose with a specific verb ('Get') and resource ('information about MySQL databases'), making it immediately understandable. However, it doesn't differentiate from sibling tools like 'environments' or 'query', which might also provide database-related information, so it doesn't reach the highest score.

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 alternatives like the 'environments' or 'query' sibling tools. It lacks any context about use cases, prerequisites, or exclusions, leaving the agent with minimal direction.

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