Skip to main content
Glama

describe-table

describe-table

Retrieve the detailed schema of a Firebird database table, including column names, data types, and structure information for data analysis and query planning.

Instructions

Gets the detailed schema (columns, types, etc.) of a specific table.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableNameYesName of the table to describe

Implementation Reference

  • Zod schema defining the input for the describe-table tool: requires a tableName string.
    export const DescribeTableArgsSchema = z.object({
        tableName: z.string().min(1).describe("Name of the table to describe")
    });
  • Registration of the 'describe-table' MCP tool within setupDatabaseTools(), including the inline handler function that calls describeTable() from db/queries.ts and formats the response.
    tools.set("describe-table", {
        name: "describe-table",
        description: "Gets the detailed schema (columns, types, etc.) of a specific table.",
        inputSchema: DescribeTableArgsSchema,
        handler: async (args: z.infer<typeof DescribeTableArgsSchema>) => {
            const { tableName } = args;
            logger.info(`Describing table: ${tableName}`);
    
            try {
                const schema = await describeTable(tableName);
                logger.info(`Schema obtained for table ${tableName}, ${schema.length} columns found`);
    
                return {
                    content: [{
                        type: "text",
                        text: formatForClaude({ schema })
                    }]
                };
            } catch (error) {
                const errorResponse = wrapError(error);
                logger.error(`Error describiendo tabla ${tableName}: ${errorResponse.error} [${errorResponse.errorType || 'UNKNOWN'}]`);
                return {
                    content: [{
                        type: "text",
                        text: formatForClaude(errorResponse)
                    }]
                };
            }
        }
    });
  • Core implementation of describeTable function that executes the SQL query against RDB$RELATION_FIELDS and RDB$FIELDS to retrieve detailed column information for the specified table.
    export const describeTable = async (tableName: string, config = DEFAULT_CONFIG): Promise<ColumnInfo[]> => {
        // Try to load config from global variable first
        const globalConfig = getGlobalConfig();
        if (globalConfig && globalConfig.database) {
            logger.info(`Using global configuration for describeTable: ${globalConfig.database}`);
            config = globalConfig;
        }
        try {
            logger.info(`Obteniendo estructura de la tabla: ${tableName}`);
    
            if (!validateSql(tableName)) {
                throw new FirebirdError(
                    `Nombre de tabla inválido: ${tableName}`,
                    'VALIDATION_ERROR'
                );
            }
    
            // Consulta para obtener información de las columnas
            const sql = `
                SELECT
                    TRIM(rf.RDB$FIELD_NAME) as FIELD_NAME,
                    CASE f.RDB$FIELD_TYPE
                        WHEN 7 THEN 'SMALLINT'
                        WHEN 8 THEN 'INTEGER'
                        WHEN 10 THEN 'FLOAT'
                        WHEN 12 THEN 'DATE'
                        WHEN 13 THEN 'TIME'
                        WHEN 14 THEN 'CHAR'
                        WHEN 16 THEN 'BIGINT'
                        WHEN 27 THEN 'DOUBLE PRECISION'
                        WHEN 35 THEN 'TIMESTAMP'
                        WHEN 37 THEN 'VARCHAR'
                        WHEN 261 THEN 'BLOB'
                        ELSE 'UNKNOWN'
                    END as FIELD_TYPE,
                    f.RDB$FIELD_LENGTH as FIELD_LENGTH,
                    f.RDB$FIELD_SCALE as FIELD_SCALE,
                    CASE rf.RDB$NULL_FLAG
                        WHEN 1 THEN 0
                        ELSE 1
                    END as NULLABLE,
                    rf.RDB$DEFAULT_SOURCE as DEFAULT_VALUE,
                    CASE
                        WHEN EXISTS (
                            SELECT 1 FROM RDB$RELATION_CONSTRAINTS rc
                            JOIN RDB$INDEX_SEGMENTS isg ON rc.RDB$INDEX_NAME = isg.RDB$INDEX_NAME
                            WHERE rc.RDB$RELATION_NAME = rf.RDB$RELATION_NAME
                            AND rc.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY'
                            AND isg.RDB$FIELD_NAME = rf.RDB$FIELD_NAME
                        ) THEN 1
                        ELSE 0
                    END as PRIMARY_KEY,
                    CAST(rf.RDB$DESCRIPTION AS VARCHAR(500)) as DESCRIPTION
                FROM RDB$RELATION_FIELDS rf
                JOIN RDB$FIELDS f ON rf.RDB$FIELD_SOURCE = f.RDB$FIELD_NAME
                WHERE rf.RDB$RELATION_NAME = ?
                ORDER BY rf.RDB$FIELD_POSITION
            `;
    
            const columns = await executeQuery(sql, [tableName], config);
    
            if (columns.length === 0) {
                logger.warn(`No se encontraron columnas para la tabla: ${tableName}`);
                throw new FirebirdError(
                    `No se encontraron columnas para la tabla: ${tableName}. Es posible que la tabla no exista.`,
                    'TABLE_NOT_FOUND'
                );
            }
    
            logger.info(`Se encontraron ${columns.length} columnas para la tabla: ${tableName}`);
    
            return columns.map((col: any) => ({
                field_name: col.FIELD_NAME,
                field_type: col.FIELD_TYPE,
                field_length: col.FIELD_LENGTH,
                field_scale: col.FIELD_SCALE !== null ? -1 * col.FIELD_SCALE : undefined,
                nullable: Boolean(col.NULLABLE),
                default_value: col.DEFAULT_VALUE,
                primary_key: Boolean(col.PRIMARY_KEY),
                description: col.DESCRIPTION || null
            }));
        } catch (error: any) {
            // Propagar el error si ya es un FirebirdError
            if (error instanceof FirebirdError) {
                throw error;
            }
    
            const errorMessage = `Error describiendo la tabla ${tableName}: ${error.message || error}`;
            logger.error(errorMessage);
            throw new FirebirdError(errorMessage, 'TABLE_DESCRIBE_ERROR', error);
        }
    };
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'Gets' schema details, implying a read-only operation, but doesn't cover aspects like permissions needed, error handling, rate limits, or what the output format looks like (e.g., structured data or raw text). This leaves significant gaps for a tool with no annotation support.

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 without unnecessary words. Every part of the sentence contributes directly to understanding what the tool does, 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.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is minimally adequate but incomplete. It explains the basic purpose but lacks details on behavioral traits and usage context, which are important for an AI agent to invoke it correctly without additional structured data.

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%, with the single parameter 'tableName' fully documented in the input schema. The description adds no additional parameter semantics beyond implying it's for a 'specific table', which is already clear from the schema. This meets the baseline of 3 when the schema handles most of the documentation.

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 'Gets' and the resource 'detailed schema (columns, types, etc.) of a specific table', making the purpose explicit. However, it doesn't distinguish this tool from similar siblings like 'get-field-descriptions' or 'list-tables', which could also provide schema-related information, so it misses full differentiation.

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. With siblings like 'get-field-descriptions' and 'list-tables' that might overlap in functionality, there's no indication of specific contexts, prerequisites, or exclusions for using 'describe-table'.

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