Skip to main content
Glama

analyze_document_quality

Assess document quality using AI insights to identify issues like duplication, relevance, and completeness. Input a document path to generate targeted analysis.

Instructions

Perform comprehensive quality analysis on documentation with AI insights

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
analysisTypesNoTypes of analysis to perform
documentPathYesPath to the document to analyze
includeAINoInclude AI-powered analysis

Implementation Reference

  • Main handler function that implements the core logic of the analyze_document_quality tool. Handles document validation, AI-powered analysis for specified types (quality, duplicate, completeness, relevance), basic metrics generation, and compiles a comprehensive quality report with scores, insights, and recommendations.
    tools.set('analyze_document_quality', async (args: any) => { try { logger.info(`Analyzing document quality: ${args.documentPath}`); // Check if document exists const documentExists = await checkDocumentExists(args.documentPath); if (!documentExists) { throw new Error(`Document not found: ${args.documentPath}`); } const analyses: any[] = []; const qualityReport: string[] = []; // Perform requested analysis types if (args.includeAI && aiService) { for (const analysisType of args.analysisTypes) { let analysis; switch (analysisType) { case 'quality': analysis = await aiService.analyzeQuality(args.documentPath); break; case 'duplicate': analysis = await aiService.detectDuplicates(args.documentPath); break; case 'completeness': const recentWork = await getRecentWorkContext(args.documentPath, connectionService); analysis = await aiService.calculateRelevance(args.documentPath, recentWork); break; default: continue; } analyses.push(analysis); qualityReport.push(`${analysisType.toUpperCase()} (${Math.round(analysis.score * 100)}%): ${analysis.insights.join(', ')}`); } } // Generate basic quality metrics const basicMetrics = await generateBasicQualityMetrics(args.documentPath); return { success: true, documentPath: args.documentPath, overallScore: analyses.length > 0 ? Math.round(analyses.reduce((sum, a) => sum + a.score, 0) / analyses.length * 100) : null, basicMetrics, qualityReport, recommendations: analyses.flatMap(a => a.suggestions), analyzedAt: localizationService.getCurrentDateTimeString() }; } catch (error) { logger.error('Failed to analyze document quality:', error); throw error; } });
  • Zod input schema for the analyze_document_quality tool, defining validation for documentPath (required), includeAI (boolean, default true), and analysisTypes (array of specific analysis enums, default ['quality']).
    export const AnalyzeDocumentQualitySchema = z.object({ documentPath: z.string(), includeAI: z.boolean().default(true), analysisTypes: z.array(z.enum(['quality', 'duplicate', 'relevance', 'completeness'])).default(['quality']), });
  • MCPTool registration definition including the tool name, description, and inputSchema matching the Zod schema, used in registerEnhancedTools to define the tool for the system.
    { name: 'analyze_document_quality', description: 'Perform comprehensive quality analysis on documentation with AI insights', inputSchema: { type: 'object', properties: { documentPath: { type: 'string', description: 'Path to the document to analyze' }, includeAI: { type: 'boolean', description: 'Include AI-powered analysis', default: true }, analysisTypes: { type: 'array', items: { type: 'string', enum: ['quality', 'duplicate', 'relevance', 'completeness'] }, description: 'Types of analysis to perform', default: ['quality'] } }, required: ['documentPath'] } },
  • Helper function called by the handler to generate basic file-based quality metrics: size, line count, word count, and last modified timestamp.
    async function generateBasicQualityMetrics(documentPath: string): Promise<string[]> { try { const stats = await fs.stat(documentPath); const content = await fs.readFile(documentPath, 'utf-8'); return [ `File Size: ${Math.round(stats.size / 1024)} KB`, `Lines: ${content.split('\n').length}`, `Words: ${content.split(/\s+/).length}`, `Last Modified: ${stats.mtime.toISOString()}` ]; } catch (error) { return [`Error reading file: ${error}`]; } }
  • Helper function used in the handler to verify if the target document file exists before analysis.
    async function checkDocumentExists(documentPath: string): Promise<boolean> { try { await fs.access(documentPath); return true; } catch { return false; } }

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/Ghostseller/CastPlan_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server