Skip to main content
Glama

validate-database

Ensure the integrity of Firebird databases by validating data and indexes, with options to fix errors and monitor detailed progress during the process.

Instructions

Validates the integrity of the Firebird database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
optionsNo

Implementation Reference

  • Core handler function that executes the 'gfix' Firebird tool to validate database integrity, check data and indexes, parse output for issues, and return structured results.
    export const validateDatabase = async ( options: ValidateOptions = {}, config = DEFAULT_CONFIG ): Promise<ValidationResult> => { const startTime = Date.now(); try { // Check if Firebird tools are installed const toolsCheck = await checkFirebirdTools(); if (!toolsCheck.installed) { throw new FirebirdError( `Firebird client tools are not installed. ${toolsCheck.installInstructions}`, 'MISSING_FIREBIRD_TOOLS' ); } // Try to find Firebird bin directory const firebirdBinPath = await findFirebirdBinPath(); // Use GFIX for validation const command = firebirdBinPath ? path.join(firebirdBinPath, 'gfix') : 'gfix'; let args: string[] = [ '-user', config.user || 'SYSDBA', '-password', config.password || 'masterkey' ]; // Add validation options if (options.checkData) { args.push('-v'); // Validate database } if (options.checkIndexes) { args.push('-i'); // Validate indexes } if (options.fixErrors) { args.push('-mend'); // Fix errors } // Add database path args.push(config.database); logger.info(`Starting database validation for ${config.database}`); if (options.verbose) { logger.debug(`Validation command: ${command} ${args.join(' ')}`); } // Execute the validation command const result = await executeCommand(command, args, options.verbose); // Parse the result to determine if the database is valid const issues: string[] = []; const lines = result.split('\n'); for (const line of lines) { if (line.includes('error') || line.includes('corrupt') || line.includes('invalid')) { issues.push(line.trim()); } } const valid = issues.length === 0; const duration = Date.now() - startTime; logger.info(`Validation completed in ${duration}ms, valid: ${valid}, issues: ${issues.length}`); return { success: true, valid, issues, details: result }; } catch (error: any) { const duration = Date.now() - startTime; const errorMessage = `Error validating database: ${error.message || error}`; logger.error(errorMessage); return { success: false, valid: false, issues: [errorMessage], details: error.details || '', error: errorMessage }; } };
  • MCP tool registration in setupDatabaseTools(), defining name, description, input schema, and wrapper handler that calls the core validateDatabase function.
    // Add validate-database tool tools.set("validate-database", { name: "validate-database", description: "Validates the integrity of the Firebird database", inputSchema: ValidateDatabaseArgsSchema, handler: async (request) => { const { options } = request; logger.info(`Executing validate-database tool`); try { const result = await validateDatabase(options); return { content: [{ type: "text", text: formatForClaude(result) }] }; } catch (error) { const errorResponse = wrapError(error); logger.error(`Error validating database: ${errorResponse.error} [${errorResponse.errorType || 'UNKNOWN'}]`); return { content: [{ type: "text", text: formatForClaude(errorResponse) }] }; } } });
  • Zod input schema for the validate-database tool, defining optional validation options passed to the handler.
    export const ValidateDatabaseArgsSchema = z.object({ options: z.object({ checkData: z.boolean().default(true).describe("Whether to validate data integrity"), checkIndexes: z.boolean().default(true).describe("Whether to validate indexes"), fixErrors: z.boolean().default(false).describe("Whether to attempt to fix errors"), verbose: z.boolean().default(false).describe("Whether to show detailed progress") }).optional() });

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