Skip to main content
Glama
bretoreta

MariaDB MCP Server

by bretoreta

list_databases

Retrieve a list of all accessible databases on a MariaDB server to identify available data sources for exploration or querying.

Instructions

List all accessible databases on the MariaDB server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list_databases' tool. It executes the SQL query 'SHOW DATABASES' using the executeQuery helper and returns the result rows as a formatted JSON text block.
    case "list_databases": {
      const { rows } = await executeQuery("SHOW DATABASES");
      return {
        content: [{ type: "text", text: JSON.stringify(rows, null, 2) }],
      };
    }
  • src/index.ts:82-86 (registration)
    Registration of the 'list_databases' tool in the MCP server's listTools response, including its name, description, and input schema (empty object, no parameters).
    {
      name: "list_databases",
      description: "List all databases",
      inputSchema: { type: "object" },
    },
  • Input schema for the list_databases tool, specifying an empty object (no input parameters required).
    inputSchema: { type: "object" },
  • The executeQuery helper function called by the list_databases handler to perform the actual database query.
    export async function executeQuery(
      sql: string,
      params: any[] = [],
      database?: string
    ): Promise<{ rows: any; fields: mariadb.FieldInfo[] }> {
      console.error(`[Query] Executing: ${sql}`);
      // Create connection pool if not already created
      if (!pool) {
        console.error("[Setup] Connection pool not found, creating a new one");
        pool = createConnectionPool();
      }
      try {
        // Get connection from pool
        if (connection) {
          console.error("[Query] Reusing existing connection");
        } else {
          console.error("[Query] Creating new connection");
          connection = await pool.getConnection();
        }
    
        // Use specific database if provided
        if (database) {
          console.error(`[Query] Using database: ${database}`);
          await connection.query(`USE \`${database}\``);
        }
        if (!isAlloowedQuery(sql)) {
          throw new Error("Query not allowed");
        }
        // Execute query with timeout
        const [rows, fields] = await connection.query({
          metaAsArray: true,
          namedPlaceholders: true,
          sql,
          ...params,
          timeout: DEFAULT_TIMEOUT,
        });
    
        // Apply row limit if result is an array
        const limitedRows =
          Array.isArray(rows) && rows.length > DEFAULT_ROW_LIMIT
            ? rows.slice(0, DEFAULT_ROW_LIMIT)
            : rows;
    
        // Log result summary
        console.error(
          `[Query] Success: ${
            Array.isArray(rows) ? rows.length : 1
          } rows returned with ${JSON.stringify(params)}`
        );
    
        return { rows: limitedRows, fields };
      } catch (error) {
        if (connection) {
          connection.release();
          console.error("[Query] Connection released with error");
        }
        console.error("[Error] Query execution failed:", error);
        throw error;
      } finally {
        // Release connection back to pool
        if (connection) {
          connection.release();
          console.error("[Query] Connection released");
        }
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't mention important traits like whether this is a read-only operation, if it requires specific permissions, potential rate limits, or what the output format looks like. This leaves significant gaps for a tool that interacts with a database server.

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 function without any unnecessary words. It's perfectly front-loaded and wastes no space, making it easy for an agent 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 that this is a database interaction tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what 'accessible' means in terms of permissions, doesn't describe the return format (e.g., list of strings, structured objects), and provides no behavioral context beyond the basic action.

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 zero parameters, and the schema description coverage is 100%, so there's no need for parameter documentation in the description. The description appropriately focuses on the tool's purpose without redundant parameter information, earning a high baseline score for this dimension.

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 verb ('List') and resource ('all accessible databases on the MariaDB server'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_tables' or 'describe_table', which prevents a perfect 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 'list_tables' or 'describe_table'. It lacks any context about prerequisites, timing, or exclusions, leaving the agent to infer usage based on tool names alone.

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/bretoreta/mariadb-mcp-server'

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