Skip to main content
Glama

get-table-data

Retrieve data from Firebird database tables with filtering, pagination, and sorting options to extract specific information efficiently.

Instructions

Retrieves data from a specific table with optional filtering, pagination, and ordering.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableNameYesName of the table to retrieve data from
firstNoNumber of rows to retrieve (FIRST clause in Firebird)
skipNoNumber of rows to skip (SKIP clause in Firebird)
whereNoOptional WHERE clause (without the WHERE keyword)
orderByNoOptional ORDER BY clause (without the ORDER BY keyword)

Implementation Reference

  • The handler function constructs a dynamic SQL SELECT query based on input parameters (tableName, first, skip, where, orderBy) and executes it using executeQuery to retrieve table data.
    handler: async (args: z.infer<typeof GetTableDataArgsSchema>) => { const { tableName, first, skip, where, orderBy } = args; logger.info(`Getting data from table: ${tableName}`); try { let sql = `SELECT * FROM "${tableName}"`; if (where) { sql += ` WHERE ${where}`; } if (orderBy) { sql += ` ORDER BY ${orderBy}`; } if (first !== undefined) { sql = `SELECT FIRST ${first} ${skip ? `SKIP ${skip}` : ''} * FROM "${tableName}"${where ? ` WHERE ${where}` : ''}${orderBy ? ` ORDER BY ${orderBy}` : ''}`; } const result = await executeQuery(sql); logger.info(`Retrieved ${result.length} rows from ${tableName}`); return { content: [{ type: "text", text: formatForClaude({ tableName, rowCount: result.length, data: result }) }] }; } catch (error) { const errorResponse = wrapError(error); logger.error(`Error getting data from ${tableName}: ${errorResponse.error}`); return { content: [{ type: "text", text: formatForClaude(errorResponse) }] }; } }
  • Zod input schema validating the arguments: tableName (required), first/skip (optional pagination), where/orderBy (optional filtering/sorting).
    export const GetTableDataArgsSchema = z.object({ tableName: z.string().min(1).describe("Name of the table to retrieve data from"), first: z.number().int().positive().optional().describe("Number of rows to retrieve (FIRST clause in Firebird)"), skip: z.number().int().min(0).optional().describe("Number of rows to skip (SKIP clause in Firebird)"), where: z.string().optional().describe("Optional WHERE clause (without the WHERE keyword)"), orderBy: z.string().optional().describe("Optional ORDER BY clause (without the ORDER BY keyword)") });
  • Tool registration in the setupDatabaseTools() function, adding 'get-table-data' to the tools Map with name, description, schema, and inline handler.
    tools.set("get-table-data", { name: "get-table-data", title: "Get Table Data", description: "Retrieves data from a specific table with optional filtering, pagination, and ordering.", inputSchema: GetTableDataArgsSchema, handler: async (args: z.infer<typeof GetTableDataArgsSchema>) => { const { tableName, first, skip, where, orderBy } = args; logger.info(`Getting data from table: ${tableName}`); try { let sql = `SELECT * FROM "${tableName}"`; if (where) { sql += ` WHERE ${where}`; } if (orderBy) { sql += ` ORDER BY ${orderBy}`; } if (first !== undefined) { sql = `SELECT FIRST ${first} ${skip ? `SKIP ${skip}` : ''} * FROM "${tableName}"${where ? ` WHERE ${where}` : ''}${orderBy ? ` ORDER BY ${orderBy}` : ''}`; } const result = await executeQuery(sql); logger.info(`Retrieved ${result.length} rows from ${tableName}`); return { content: [{ type: "text", text: formatForClaude({ tableName, rowCount: result.length, data: result }) }] }; } catch (error) { const errorResponse = wrapError(error); logger.error(`Error getting data from ${tableName}: ${errorResponse.error}`); return { content: [{ type: "text", text: formatForClaude(errorResponse) }] }; } } });

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/PuroDelphi/mcpFirebird'

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