Skip to main content
Glama
chenkumi

easy-mysql-mcp

by chenkumi

mysql_query

Execute a read-only SQL query to retrieve data from a MySQL database. Use when fetching data without modifications.

Instructions

Execute a read-only SQL query (e.g., SELECT). Use this for data retrieval.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesThe SQL query to execute.

Implementation Reference

  • The async handler function for the 'mysql_query' tool. It receives an object with a 'sql' string, calls db.query(sql), and returns the results as JSON text content.
    async ({ sql }) => {
      const results = await db.query(sql);
      return {
        content: [{ type: 'text', text: JSON.stringify(results, null, 2) }],
      };
    }
  • Input schema definition for the 'mysql_query' tool using Zod. It defines a single required 'sql' parameter of type string.
    {
      description: 'Execute a read-only SQL query (e.g., SELECT). Use this for data retrieval.',
      inputSchema: z.object({
        sql: z.string().describe('The SQL query to execute.'),
      }),
    },
  • src/index.ts:16-30 (registration)
    Registration of the 'mysql_query' tool using server.registerTool() with its name, schema, and handler callback.
    server.registerTool(
      'mysql_query',
      {
        description: 'Execute a read-only SQL query (e.g., SELECT). Use this for data retrieval.',
        inputSchema: z.object({
          sql: z.string().describe('The SQL query to execute.'),
        }),
      },
      async ({ sql }) => {
        const results = await db.query(sql);
        return {
          content: [{ type: 'text', text: JSON.stringify(results, null, 2) }],
        };
      }
    );
  • The db.query() helper function used by the mysql_query handler. Executes a SQL query on the MySQL connection pool and returns the rows.
    export async function query(sql: string, params?: any[]) {
      const [rows] = await pool.query(sql, params);
      return rows;
Behavior4/5

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

With no annotations, description carries the burden. It explicitly states 'read-only', which is a critical behavioral trait, but does not mention potential errors, auth requirements, or return format.

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?

Single sentence with no unnecessary words, front-loading the core purpose and usage context.

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?

For a simple read-only query tool with one parameter and no output schema, the description is adequate. It covers the essential constraint (read-only) and usage scenario.

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?

Input schema has 100% coverage for the single parameter 'sql' with description. Description adds no extra meaning beyond the schema, so baseline 3 is appropriate.

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?

Description clearly states the tool executes a read-only SQL query for data retrieval, and the sibling mysql_execute implies write operations, distinguishing it effectively.

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

Usage Guidelines4/5

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

Description specifies 'read-only' and 'use for data retrieval', implying it should not be used for mutations, but does not explicitly mention alternatives or when not to use.

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/chenkumi/easy-mysql-mcp'

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