Skip to main content
Glama
moosin76

MariaDB Reader MCP Server

by moosin76

query_table

Retrieve data from a specified table in a MariaDB database with a customizable row limit, enabling efficient data exploration and analysis for AI assistants.

Instructions

특정 테이블에서 데이터를 조회합니다 (제한된 행 반환).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseYes데이터베이스의 이름입니다.
limitNo반환할 최대 행 수 (기본값 100).
tableYes테이블의 이름입니다.

Implementation Reference

  • The execution handler for the 'query_table' tool. It validates inputs, connects to the specified database, executes a SELECT * query with LIMIT on the table, and returns the results as a JSON string.
    case "query_table": {
      const dbName = args.database as string; // 데이터베이스 이름 추출
      const tableName = args.table as string; // 테이블 이름 추출
      // 반환할 행 수 제한 (기본값 100)
      const limit = typeof args.limit === 'number' && args.limit > 0 ? args.limit : 100;
      if (!dbName) throw new McpError(ErrorCode.InvalidParams, "필수 파라미터 누락: database");
      if (!tableName) throw new McpError(ErrorCode.InvalidParams, "필수 파라미터 누락: table");
      connection = await createDbConnection(dbName); // 지정된 DB로 연결
      // 데이터 조회 쿼리 (안전을 위해 백틱 사용 및 LIMIT 적용)
      const query = `SELECT * FROM \`${tableName}\` LIMIT ?;`;
      const [rows] = await connection.query(query, [limit]); // 쿼리 실행 (limit 값 바인딩)
      return { content: [{ type: "text", text: JSON.stringify(rows, null, 2) }] };
    }
  • src/index.ts:103-116 (registration)
    Registration of the 'query_table' tool in the listTools response, including its name, description, and input schema.
    {
      name: "query_table",
      description: "특정 테이블에서 데이터를 조회합니다 (제한된 행 반환).",
      inputSchema: {
        type: "object",
        properties: {
          database: { type: "string", description: "데이터베이스의 이름입니다." },
          table: { type: "string", description: "테이블의 이름입니다." },
          limit: { type: "number", description: "반환할 최대 행 수 (기본값 100).", default: 100 },
          // 향후 개선: where_clause, columns, order_by 등 추가
        },
        required: ["database", "table"]
      }
    }
  • Input schema definition for the 'query_table' tool, specifying required database and table parameters, optional limit, with descriptions.
    inputSchema: {
      type: "object",
      properties: {
        database: { type: "string", description: "데이터베이스의 이름입니다." },
        table: { type: "string", description: "테이블의 이름입니다." },
        limit: { type: "number", description: "반환할 최대 행 수 (기본값 100).", default: 100 },
        // 향후 개선: where_clause, columns, order_by 등 추가
      },
      required: ["database", "table"]
    }
  • Helper function to create a MySQL/MariaDB connection, used by the query_table handler to connect to the specified database.
    async function createDbConnection(dbName?: string) {
      try {
        const connection = await mysql.createConnection({
          ...dbConfig,
          database: dbName || dbConfig.database, // 특정 DB가 제공되면 사용, 아니면 기본값 사용
        });
        return connection;
      } catch (error: any) {
        console.error("데이터베이스 연결 오류:", error.message);
        // MCP 클라이언트에게 더 구체적인 오류 제공
        throw new McpError(ErrorCode.InternalError, `데이터베이스 연결 실패: ${error.message}`);
      }
    }
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 mentions 'limited rows returned', which hints at a constraint, but fails to cover critical aspects like read-only status, potential permissions needed, error handling, or response format. This is inadequate for a query tool with zero annotation coverage.

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 in Korean that directly states the tool's purpose and a key constraint ('limited rows returned'). It is front-loaded with no wasted words, making it highly concise and well-structured.

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 complexity of a database query tool with no annotations and no output schema, the description is insufficient. It lacks details on behavior, error cases, return values, and usage context, leaving significant gaps for an agent to operate effectively.

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?

Schema description coverage is 100%, so the schema already documents all parameters ('database', 'table', 'limit') with clear descriptions. The description adds no additional meaning beyond what the schema provides, such as query syntax or examples, resulting in a baseline score of 3.

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 action ('query_table' translates to 'retrieve data from a specific table') and the resource ('table'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_table_schema' (which might return metadata) or 'list_tables' (which lists tables rather than querying data), missing full sibling distinction.

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 'get_table_schema' or 'list_tables'. It mentions 'limited rows returned', but this doesn't clarify usage context, exclusions, or prerequisites, leaving the agent without explicit 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

Related 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/moosin76/mcp_server_mariadb_reader'

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