Skip to main content
Glama

Get Table Data

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)
                    }]
                };
            }
        }
    });
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions what the tool does but lacks critical behavioral details: no information about permissions required, rate limits, error handling, or what format the retrieved data comes in. For a data retrieval tool with 5 parameters, this leaves significant gaps in understanding how it behaves in practice.

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 purpose and mentions key optional features. Every word earns its place with zero redundancy or unnecessary elaboration. It's appropriately sized for a data retrieval tool with well-documented parameters.

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?

For a data retrieval tool with 5 parameters and no annotations or output schema, the description is insufficient. It doesn't explain what format the data returns in, how errors are handled, what permissions are required, or performance considerations. Given the complexity of database operations and the lack of structured metadata, more contextual information would be valuable for an AI agent.

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 thoroughly. The description adds minimal value beyond the schema by mentioning 'optional filtering, pagination, and ordering' which corresponds to where, first/skip, and orderBy parameters. This provides high-level context but no additional semantic details beyond what's in the parameter descriptions.

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 'retrieves' and resource 'data from a specific table', making the purpose unambiguous. It distinguishes from siblings like 'describe-table' or 'list-tables' by focusing on data retrieval rather than metadata. However, it doesn't explicitly differentiate from 'execute-query' which might also retrieve table data.

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?

No guidance is provided on when to use this tool versus alternatives like 'execute-query' or 'list-tables'. The description mentions optional features (filtering, pagination, ordering) but doesn't specify scenarios where this tool is preferred or contraindicated. Sibling tools include several query-related alternatives without any comparative context.

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

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