Skip to main content
Glama

get-field-descriptions

Retrieve stored descriptions for table fields in Firebird databases to understand data structure and column purposes.

Instructions

Gets the stored descriptions for fields of a specific table (if they exist).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableNameYesName of the table to get field descriptions for

Implementation Reference

  • Zod input schema for the get-field-descriptions tool, requiring a tableName string.
    export const GetFieldDescriptionsArgsSchema = z.object({
        tableName: z.string().min(1).describe("Name of the table to get field descriptions for")
    });
  • Registers the get-field-descriptions MCP tool in the tools map, including name, description, input schema, and handler function that delegates to getFieldDescriptions and formats the response.
    tools.set("get-field-descriptions", {
        name: "get-field-descriptions",
        description: "Gets the stored descriptions for fields of a specific table (if they exist).",
        inputSchema: GetFieldDescriptionsArgsSchema,
        handler: async (args: z.infer<typeof GetFieldDescriptionsArgsSchema>) => {
            const { tableName } = args;
            logger.info(`Getting field descriptions for table: ${tableName}`);
    
            try {
                const fieldDescriptions = await getFieldDescriptions(tableName);
                logger.info(`Descriptions obtained for ${fieldDescriptions.length} fields in table ${tableName}`);
    
                return {
                    content: [{
                        type: "text",
                        text: formatForClaude({ fieldDescriptions })
                    }]
                };
            } catch (error) {
                const errorResponse = wrapError(error);
                logger.error(`Error getting field descriptions for table ${tableName}: ${errorResponse.error} [${errorResponse.errorType || 'UNKNOWN'}]`);
    
                return {
                    content: [{
                        type: "text",
                        text: formatForClaude(errorResponse)
                    }]
                };
            }
        }
    });
  • Core handler function that executes a SQL query against Firebird system table RDB$RELATION_FIELDS to retrieve field names and their descriptions (RDB$DESCRIPTION) for the specified table, with validation, logging, and error handling.
    export const getFieldDescriptions = async (tableName: string, config = DEFAULT_CONFIG): Promise<FieldInfo[]> => {
        // Try to load config from global variable first
        const globalConfig = getGlobalConfig();
        if (globalConfig && globalConfig.database) {
            logger.info(`Using global configuration for getFieldDescriptions: ${globalConfig.database}`);
            config = globalConfig;
        }
        try {
            logger.info(`Obteniendo descripciones de campos para la tabla: ${tableName}`);
    
            if (!validateSql(tableName)) {
                throw new FirebirdError(
                    `Nombre de tabla inválido: ${tableName}`,
                    'VALIDATION_ERROR'
                );
            }
    
            const sql = `
                SELECT
                    TRIM(RF.RDB$FIELD_NAME) AS FIELD_NAME,
                    CAST(RF.RDB$DESCRIPTION AS VARCHAR(500)) AS DESCRIPTION
                FROM
                    RDB$RELATION_FIELDS RF
                WHERE
                    RF.RDB$RELATION_NAME = ?
                ORDER BY
                    RF.RDB$FIELD_POSITION
            `;
    
            const fields = await executeQuery(sql, [tableName], config);
    
            if (fields.length === 0) {
                logger.warn(`No se encontraron campos para la tabla: ${tableName}`);
            } else {
                logger.info(`Se encontraron ${fields.length} campos para la tabla: ${tableName}`);
            }
    
            return fields.map((field: any) => ({
                name: field.FIELD_NAME,
                description: field.DESCRIPTION || null
            }));
        } catch (error: any) {
            // Propagar el error si ya es un FirebirdError
            if (error instanceof FirebirdError) {
                throw error;
            }
    
            const errorMessage = `Error obteniendo descripciones de campos para ${tableName}: ${error.message || error}`;
            logger.error(errorMessage);
            throw new FirebirdError(errorMessage, 'FIELD_DESCRIPTION_ERROR', error);
        }
    };

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