Skip to main content
Glama
devakone

MySQL Query MCP Server

by devakone

info

Retrieve metadata about MySQL databases in a specified environment. Provides essential details needed for database analysis and query planning.

Instructions

Get information about MySQL databases

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
environmentYesTarget environment to get information from

Implementation Reference

  • Main handler function for the 'info' tool. Takes environment parameter, connects to MySQL, and returns version, status, variables, processlist, and databases.
    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 defining input parameters for the info tool: requires an 'environment' field (enum: local, development, staging, production).
    // Info parameters schema
    export const InfoParams = z.object({
      environment: Environment,
    });
    export type InfoParameters = z.infer<typeof InfoParams>;
  • TypeScript interface defining the return shape of the info tool: version, status, variables, processlist, and databases.
    // Database info result type
    export interface DatabaseInfo {
      version: string;
      status: string;
      variables: Record<string, string>;
      processlist: unknown[];
      databases: string[];
    }
  • src/index.ts:109-122 (registration)
    Registration of the 'info' tool in the MCP server capabilities (server constructor).
    [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:214-220 (registration)
    CallTool handler dispatching to runInfoTool when the tool name is 'info', with Zod schema validation of arguments.
    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, and the description only implies a read operation ('Get information') without explicit statements about safety or side effects. It fails to disclose any behavioral traits beyond the basic action.

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

Conciseness4/5

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

The description is a single sentence, no wasted words, and appropriately sized for a simple tool. It is front-loaded with the core action.

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 absence of an output schema and the tool's simple nature, the description is too minimal. It does not specify what kind of information is returned or any additional context, leaving the agent underinformed.

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 schema provides 100% coverage with a description for the 'environment' parameter. The tool description adds no additional semantics beyond what is in the schema, earning the baseline score.

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 'Get information about MySQL databases,' specifying the verb and resource. However, it does not differentiate from siblings like 'query', which might also retrieve data.

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?

No guidance on when to use this tool versus alternatives like 'query' or 'environments'. The description does not provide context or exclusions.

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