check_readability
Analyze content readability by calculating Flesch-Kincaid scores, grade levels, sentence statistics, and reading time to optimize text clarity.
Instructions
Analyze content readability. Returns Flesch-Kincaid score, grade level, sentence stats, and reading time.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The content to analyze |
Implementation Reference
- mcp-server/src/index.ts:452-495 (handler)The implementation of the check_readability tool, including input schema definition, readability score calculation, and result construction.
server.tool( "check_readability", "Analyze content readability. Returns Flesch-Kincaid score, grade level, sentence stats, and reading time.", { content: z.string().describe("The content to analyze"), }, async ({ content }) => { const words = countWords(content); const sentences = countSentences(content); const paragraphs = content.split(/\n\n+/).filter((p) => p.trim().length > 0).length; const { score, gradeLevel } = fleschKincaidScore(content); const avgSentenceLength = words / sentences; const allWords = content.split(/\s+/).filter((w) => w.length > 0); const avgWordLength = allWords.reduce((sum, w) => sum + w.replace(/[^a-zA-Z]/g, "").length, 0) / Math.max(allWords.length, 1); const readingTime = Math.ceil(words / 250); let level: string; if (score >= 80) level = "Very Easy — suitable for 5th graders and above"; else if (score >= 70) level = "Easy — conversational English"; else if (score >= 60) level = "Standard — suitable for most web content"; else if (score >= 50) level = "Fairly Difficult — may lose casual readers"; else if (score >= 30) level = "Difficult — college-level reading"; else level = "Very Difficult — academic or technical writing"; return { content: [ { type: "text" as const, text: JSON.stringify({ fleschKincaidScore: score, gradeLevel, readabilityLevel: level, avgSentenceLength: Math.round(avgSentenceLength * 10) / 10, avgWordLength: Math.round(avgWordLength * 10) / 10, wordCount: words, sentenceCount: sentences, paragraphCount: paragraphs, readingTime: `${readingTime} min`, suggestions: [ ...(avgSentenceLength > 20 ? ["Shorten sentences — aim for 15-20 words per sentence."] : []), ...(score < 60 ? ["Use simpler vocabulary and shorter sentences to improve readability."] : []), ...(gradeLevel > 10 ? [`Grade level ${gradeLevel} is high for web content. Target grade 8-10.`] : []), ...(paragraphs < 3 ? ["Break content into more paragraphs (1-3 sentences each)."] : []), ],