get-field-descriptions
Retrieve stored field descriptions for a specific table in Firebird SQL databases. Input the table name to access metadata, simplifying data analysis and manipulation in MCP Firebird environments.
Instructions
Gets the stored descriptions for fields of a specific table (if they exist).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tableName | Yes | Name of the table to get field descriptions for |
Implementation Reference
- src/tools/database.ts:86-88 (schema)Zod input schema defining the required 'tableName' parameter for the tool.export const GetFieldDescriptionsArgsSchema = z.object({ tableName: z.string().min(1).describe("Name of the table to get field descriptions for") });
- src/tools/database.ts:240-270 (registration)Registers the 'get-field-descriptions' tool, including its name, description, input schema, and handler function that calls the core getFieldDescriptions implementation with logging and error handling.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) }] }; } } });
- src/db/queries.ts:295-346 (handler)Core handler function that executes the SQL query against RDB$RELATION_FIELDS to retrieve field names and descriptions for the specified table, including 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); } };