memory_validate
Validate and ensure the integrity of memory data in the meMCP server, facilitating reliable continuous learning and knowledge retention for Large Language Models (LLMs).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/modules/MemoryManagement.js:128-151 (registration)Registers the memory_validate tool with server, defining its description, input schema, and handler function that delegates to handleValidateregisterValidateTool(server) { server.registerTool( 'memory_validate', 'Validate the integrity of the memory system', { type: 'object', properties: { fixErrors: { type: 'boolean', description: 'Attempt to fix validation errors automatically', default: false, }, checkRelationships: { type: 'boolean', description: 'Validate fact relationships', default: true, }, }, }, async (args) => { return await this.handleValidate(args); } ); }
- The handler function for the memory_validate tool. It extracts arguments, calls validateSystem, formats a detailed response with validation stats and error summary, and handles errors.async handleValidate(args) { try { const { fixErrors = false, checkRelationships = true } = args; const validationResult = await this.validateSystem({ fixErrors, checkRelationships, }); let response = `🔍 **Validation Complete**\n\n**Total Facts:** ${validationResult.totalFacts}\n**Valid Facts:** ${validationResult.validFacts}\n**Errors Found:** ${validationResult.errors.length}`; if (validationResult.errors.length > 0) { response += `\n\n**Error Summary:**\n${validationResult.errorSummary.map(e => `- ${e.type}: ${e.count}`).join('\n')}`; if (fixErrors) { response += `\n\n**Fixed:** ${validationResult.fixed} errors`; } } return { content: [ { type: 'text', text: response, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error validating system: ${error.message}`, }, ], isError: true, }; } }
- Core helper function that implements the validation logic: checks all facts for missing ID, empty content, invalid quality score, and optionally broken relationships. Collects errors and summary.async validateSystem(options = {}) { try { const { fixErrors, checkRelationships } = options; const allFacts = await this.factStore.queryFacts({ query: '', limit: 10000 }); const errors = []; const errorTypes = new Map(); let fixed = 0; for (const fact of allFacts.facts) { if (!fact.id) { errors.push({ type: 'missing_id', factId: 'unknown', message: 'Fact missing ID' }); errorTypes.set('missing_id', (errorTypes.get('missing_id') || 0) + 1); } if (!fact.content || fact.content.trim().length === 0) { errors.push({ type: 'empty_content', factId: fact.id, message: 'Fact has empty content' }); errorTypes.set('empty_content', (errorTypes.get('empty_content') || 0) + 1); } if (fact.qualityScore === undefined || fact.qualityScore < 0 || fact.qualityScore > 100) { errors.push({ type: 'invalid_quality_score', factId: fact.id, message: 'Invalid quality score' }); errorTypes.set('invalid_quality_score', (errorTypes.get('invalid_quality_score') || 0) + 1); } if (checkRelationships && fact.relationships) { for (const rel of fact.relationships) { const relatedFact = allFacts.facts.find(f => f.id === rel.targetId); if (!relatedFact) { errors.push({ type: 'broken_relationship', factId: fact.id, message: `Relationship to ${rel.targetId} is broken` }); errorTypes.set('broken_relationship', (errorTypes.get('broken_relationship') || 0) + 1); } } } } const errorSummary = Array.from(errorTypes.entries()).map(([type, count]) => ({ type, count })); return { totalFacts: allFacts.facts.length, validFacts: allFacts.facts.length - errors.length, errors, errorSummary, fixed, }; } catch (error) { throw new Error(`Failed to validate system: ${error.message}`); } }
- src/tools/MemoryTools.js:23-29 (registration)Higher-level registration in MemoryTools where MemoryManagement.registerTools is called, ultimately registering memory_validateasync registerTools(server) { // Register tools from modular components this.operations.registerTools(server); this.queryHandler.registerTools(server); this.streamingTools.registerTools(server); this.management.registerTools(server); }
- src/core/SequentialGraphitiIntegration.js:82-82 (registration)Top-level call to register all MemoryTools, including memory_validate, in the main integration classawait this.memoryTools.registerTools(server);