analyze_document_content
Analyze document content for readability, completeness, structure, and AI optimization to identify areas for improvement and provide actionable suggestions.
Instructions
Perform advanced analysis on document content
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| document_id | Yes | ID of the document to analyze | |
| analysis_types | No | Types of analysis to perform | |
| include_suggestions | No | Whether to include improvement suggestions |
Implementation Reference
- src/tools/documents.ts:721-768 (handler)Main handler function for the analyze_document_content tool. Fetches document by ID, performs specified analyses (readability, completeness, etc.), generates suggestions if requested, computes overall score, and returns results.export const analyzeDocumentContent = requireAuth(async (args: any) => { const { document_id, analysis_types, include_suggestions } = AnalyzeDocumentContentSchema.parse(args) logger.info('Analyzing document content', { document_id, analysis_types }) const document = await supabaseService.getDocument(document_id) if (!document) { throw new Error('Document not found') } const analysis: any = { document_id, title: document.title, analyzed_at: new Date().toISOString(), results: {} } // Perform requested analyses for (const analysisType of analysis_types) { switch (analysisType) { case 'readability': analysis.results.readability = analyzeReadability(document.content) break case 'completeness': analysis.results.completeness = analyzeCompleteness(document) break case 'ai_optimization': analysis.results.ai_optimization = analyzeAIOptimization(document) break case 'link_analysis': analysis.results.link_analysis = analyzeLinkStructure(document.content) break case 'structure_analysis': analysis.results.structure_analysis = analyzeDocumentStructure(document.content) break } } // Generate improvement suggestions if (include_suggestions) { analysis.suggestions = generateImprovementSuggestions(analysis.results, document) } // Calculate overall score analysis.overall_score = calculateOverallDocumentScore(analysis.results) return analysis })
- src/tools/documents.ts:715-719 (schema)Zod schema for input validation of the analyze_document_content tool, defining document_id (required), analysis_types (array of enums, default), and include_suggestions (boolean, default true).const AnalyzeDocumentContentSchema = z.object({ document_id: z.string().min(1), analysis_types: z.array(z.enum(['readability', 'completeness', 'ai_optimization', 'link_analysis', 'structure_analysis'])).default(['readability', 'completeness']), include_suggestions: z.boolean().default(true) })
- src/tools/documents.ts:686-713 (registration)MCPTool registration defining the analyze_document_content tool with name, description, and input schema matching the Zod schema.export const analyzeDocumentContentTool: MCPTool = { name: 'analyze_document_content', description: 'Perform advanced analysis on document content', inputSchema: { type: 'object', properties: { document_id: { type: 'string', description: 'ID of the document to analyze' }, analysis_types: { type: 'array', items: { type: 'string', enum: ['readability', 'completeness', 'ai_optimization', 'link_analysis', 'structure_analysis'] }, default: ['readability', 'completeness'], description: 'Types of analysis to perform' }, include_suggestions: { type: 'boolean', default: true, description: 'Whether to include improvement suggestions' } }, required: ['document_id'] } }
- src/tools/documents.ts:1346-1358 (registration)Registration of the analyzeDocumentContent handler in the documentHandlers object, mapping 'analyze_document_content' to the handler function.export const documentHandlers = { list_documents: listDocuments, create_document: createDocument, get_document: getDocument, update_document: updateDocument, search_documents: searchDocuments, get_document_context: getDocumentContext, add_document_collaborator: addDocumentCollaborator, analyze_document_content: analyzeDocumentContent, get_document_collaboration: getDocumentCollaboration, generate_document_template: generateDocumentTemplate, bulk_document_operations: bulkDocumentOperations }
- src/tools/documents.ts:1361-1373 (registration)Export of all document tools including analyzeDocumentContentTool in the documentTools object.export const documentTools = { listDocumentsTool, createDocumentTool, getDocumentTool, updateDocumentTool, searchDocumentsTool, getDocumentContextTool, addDocumentCollaboratorTool, analyzeDocumentContentTool, getDocumentCollaborationTool, generateDocumentTemplateTool, bulkDocumentOperationsTool }