Skip to main content
Glama
nilsir

MCP Server MySQL

by nilsir

health_check

Check MySQL database connection health and server status to verify connectivity and operational state.

Instructions

Check database connection health and get server status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'health_check' tool. It tests the database connection with a ping, measures latency, retrieves the MySQL server version, uptime, connected threads, and total queries executed, returning a structured health status.
    async () => {
      const startTime = Date.now();
      const p = await getPool();
    
      // Test connection with ping
      const connection = await p.getConnection();
      await connection.ping();
      connection.release();
    
      const pingLatency = Date.now() - startTime;
    
      // Get server version and status
      const [versionRows] = await p.query<RowDataPacket[]>("SELECT VERSION() as version");
      const [statusRows] = await p.query<RowDataPacket[]>("SHOW STATUS WHERE Variable_name IN ('Uptime', 'Threads_connected', 'Questions')");
    
      const version = versionRows[0]?.version || "unknown";
      const status: Record<string, string> = {};
      for (const row of statusRows) {
        status[row.Variable_name] = row.Value;
      }
    
      const output = {
        healthy: true,
        pingLatencyMs: pingLatency,
        serverVersion: version,
        uptime: status.Uptime ? parseInt(status.Uptime, 10) : null,
        threadsConnected: status.Threads_connected ? parseInt(status.Threads_connected, 10) : null,
        totalQueries: status.Questions ? parseInt(status.Questions, 10) : null,
      };
    
      return {
        content: [
          {
            type: "text" as const,
            text: `Database connection healthy (ping: ${pingLatency}ms, version: ${version})`,
          },
        ],
        structuredContent: output,
      };
    }
  • src/index.ts:598-642 (registration)
    Registers the 'health_check' tool on the MCP server, specifying the tool name, description, empty input schema, and the handler function.
    server.tool(
      "health_check",
      "Check database connection health and get server status",
      {},
      async () => {
        const startTime = Date.now();
        const p = await getPool();
    
        // Test connection with ping
        const connection = await p.getConnection();
        await connection.ping();
        connection.release();
    
        const pingLatency = Date.now() - startTime;
    
        // Get server version and status
        const [versionRows] = await p.query<RowDataPacket[]>("SELECT VERSION() as version");
        const [statusRows] = await p.query<RowDataPacket[]>("SHOW STATUS WHERE Variable_name IN ('Uptime', 'Threads_connected', 'Questions')");
    
        const version = versionRows[0]?.version || "unknown";
        const status: Record<string, string> = {};
        for (const row of statusRows) {
          status[row.Variable_name] = row.Value;
        }
    
        const output = {
          healthy: true,
          pingLatencyMs: pingLatency,
          serverVersion: version,
          uptime: status.Uptime ? parseInt(status.Uptime, 10) : null,
          threadsConnected: status.Threads_connected ? parseInt(status.Threads_connected, 10) : null,
          totalQueries: status.Questions ? parseInt(status.Questions, 10) : null,
        };
    
        return {
          content: [
            {
              type: "text" as const,
              text: `Database connection healthy (ping: ${pingLatency}ms, version: ${version})`,
            },
          ],
          structuredContent: output,
        };
      }
    );
  • Input schema for the 'health_check' tool, which takes no parameters.
    {},
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions checking health and getting status but doesn't disclose behavioral traits like what 'health' entails (e.g., latency, uptime), whether it requires authentication, if it's read-only, or what happens on failure. This leaves significant gaps for an agent to understand 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 front-loads the core functionality without any wasted words. It directly communicates the tool's purpose in a compact form, making it easy to parse and understand quickly.

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?

Given the tool's low complexity (0 parameters, no annotations, no output schema), the description is minimally adequate but incomplete. It states what the tool does but lacks details on behavior, output format, or usage context, which could hinder an agent's ability to use it effectively without additional information.

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 no parameter documentation is needed. The description doesn't add parameter semantics, but this is acceptable given the lack of parameters, aligning with the 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 tool's purpose with specific verbs ('check', 'get') and resources ('database connection health', 'server status'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'connect' or 'query', which might also involve database connectivity aspects.

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. With siblings like 'connect' (which might establish connections) and 'query' (which might test connectivity indirectly), there's no indication of when health_check is preferred or what specific scenarios it addresses.

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/nilsir/mcp-server-mysql'

If you have feedback or need assistance with the MCP directory API, please join our Discord server