essay-stats-mcp 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1
4
+
5
+ - Tool descriptions now include example prompts, so clients can show what to ask each tool.
6
+ - New tool word_frequency lists the most used words, with counts and share of the text, to spot overused terms.
7
+ - style_flags now returns a sentence_list with the number of each passive or long sentence, and says that sentence numbers follow the order of the text.
8
+ - Error messages for empty or wordless text and for a minimum above the limit now include a worked example call so a client can fix its input.
9
+
10
+ ## 0.1.0
11
+
12
+ - First version.
13
+ - count_text counts words, characters, sentences and paragraphs, and estimates pages for a font, font size and line spacing.
14
+ - readability_scores returns Flesch Kincaid grade, Flesch reading ease, Gunning Fog and SMOG.
15
+ - style_flags finds passive voice, repeated sentence openers, filler words and long sentences.
16
+ - check_word_limit compares a text with a word limit, with an optional minimum, a tolerance, and the option to leave out references and quotes.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AnonymousOnyx22
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,113 @@
1
- # Temporary Holding Version
1
+ # Essay Stats MCP
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ You are about to hand in an essay and you are not sure if it is over the word limit, or how many pages it is. A chat assistant tends to guess at word counts. This server counts them properly, on your computer, so your assistant can give you real numbers.
4
+
5
+ Install it in Claude Code with one line:
6
+
7
+ ```
8
+ claude mcp add essay-stats -- npx -y essay-stats-mcp
9
+ ```
10
+
11
+ Then ask things like:
12
+
13
+ - "My limit is 1500 words, not counting the works cited or quotes. Am I over?"
14
+ - "How many pages is this essay in Arial 11 point with 1.5 spacing?"
15
+ - "Find the passive voice and filler words in my draft."
16
+
17
+ Essay Stats MCP is an essay word counter and writing checker that runs offline. It counts words and pages, gives a readability score, and flags passive voice, filler words, long sentences and repeated sentence openers. It also gives the reading time.
18
+
19
+ There is no account, no API key and no network call. Your essay text never leaves your machine.
20
+
21
+ ## Quick start
22
+
23
+ For Claude Code, use the one line above. For other apps, add this to the MCP config:
24
+
25
+ ```json
26
+ {
27
+ "mcpServers": {
28
+ "essay-stats": {
29
+ "command": "npx",
30
+ "args": ["-y", "essay-stats-mcp"]
31
+ }
32
+ }
33
+ }
34
+ ```
35
+
36
+ It needs Node.js 20 or newer.
37
+
38
+ Where the config lives:
39
+
40
+ - Claude Desktop: Settings, Developer, Edit Config (`claude_desktop_config.json`).
41
+ - Cursor: Settings, MCP, or `.cursor/mcp.json` in your project.
42
+ - VS Code: `.vscode/mcp.json`. VS Code uses a `servers` key instead of `mcpServers`.
43
+ - Windsurf: `~/.codeium/windsurf/mcp_config.json`.
44
+
45
+ ## Tools
46
+
47
+ | Tool | What it does |
48
+ | --- | --- |
49
+ | `count_text` | Words, characters, sentences, paragraphs, reading time and an estimated page count for a font, size and line spacing. |
50
+ | `readability_scores` | Flesch Kincaid grade, Flesch reading ease, Gunning Fog and SMOG. |
51
+ | `style_flags` | Passive voice, repeated sentence openers, filler words and long sentences. |
52
+ | `check_word_limit` | Compares the text with a word limit. Optional minimum, tolerance, and leaving out references and quotes. |
53
+ | `word_frequency` | The words used most often, with counts and share of the text, to spot overused terms. |
54
+
55
+ All five tools only read the text you give them. Each one returns a short written answer and the same numbers as structured fields.
56
+
57
+ ### count_text
58
+
59
+ Inputs: `text`, and optional `font` (times new roman, arial, calibri, georgia, courier new or verdana), `font_size` in points (default 12) and `spacing` (single, 1.5 or double, default double). The page count is an estimate from typical words per page, so Word or Google Docs may differ by a little.
60
+
61
+ ### readability_scores
62
+
63
+ Input: `text`. The grades are roughly US school grades, so 12 is the end of high school. SMOG is designed for 30 sentences or more, so on a short text the result is marked as less reliable.
64
+
65
+ ### style_flags
66
+
67
+ Inputs: `text` and optional `max_sentence_words` (default 30). The checks are simple pattern rules. Use them as a prompt to reread a sentence, not as proof of a mistake.
68
+
69
+ Sentence numbers start at 1 and follow the order of the text. The `sentence_list` field gives each passive or long sentence with its number, and the text summary ends with a line listing those numbers, so a reply can point you to the right sentence.
70
+
71
+ ### word_frequency
72
+
73
+ Inputs: `text`, and optional `top` (how many words to list, default 10), `min_count` (fewest uses for a word to be listed, default 2) and `include_common_words` (also count small words such as the, and, of and to, default false). Case is ignored, and words under 3 letters are skipped unless `include_common_words` is true.
74
+
75
+ ### check_word_limit
76
+
77
+ Inputs: `text`, `limit`, and optional `minimum`, `tolerance_percent`, `exclude_references` and `exclude_quotes`. References are cut from a heading line such as References, Works Cited or Bibliography to the end. Quotes are lines starting with `>` and text inside double quotes.
78
+
79
+ ## Example prompts
80
+
81
+ - "Count the words in this essay and tell me how many pages it is in Arial 11 point with 1.5 spacing."
82
+ - "What reading level is this essay? Give me the Flesch Kincaid, Gunning Fog and SMOG scores."
83
+ - "Find the passive voice and filler words in my draft."
84
+ - "My limit is 1500 words, not counting the works cited or quotes. Am I over?"
85
+ - "Which sentences are over 25 words long?"
86
+ - "Which words do I overuse in this essay?"
87
+
88
+ ## Works well with
89
+
90
+ If your school uses Brightspace, you can run [brightspace-d2l-mcp](https://www.npmjs.com/package/brightspace-d2l-mcp) next to Essay Stats MCP in the same app. That server has its own setup, so follow its README to install and sign in. Essay Stats MCP does not talk to it and does not need it.
91
+
92
+ With both added to your MCP config, you can ask your assistant to look up the word limit in your assignment details, then pass that number to `check_word_limit` along with your draft. For example:
93
+
94
+ - "Find the word limit for my history essay in Brightspace, then check this draft against it, leaving out the works cited."
95
+ - "Look up my assignment instructions, then tell me if this draft is under the limit and how many pages it is."
96
+
97
+ The assignment details come from the other server. The counting and checking happen here, on your machine, and Essay Stats MCP makes no network calls.
98
+
99
+ ## Privacy
100
+
101
+ Everything is calculated locally by a small Node.js program talking to your app over standard input and output. It makes no network requests, stores nothing and needs no keys or passwords. The text you paste is used for the one call and then dropped.
102
+
103
+ ## Development
104
+
105
+ ```
106
+ npm install
107
+ npm run build
108
+ npm test
109
+ ```
110
+
111
+ ## License
112
+
113
+ MIT
@@ -0,0 +1,21 @@
1
+ export function runTool(tool, args) {
2
+ try {
3
+ const out = tool.run(args);
4
+ return { content: [{ type: "text", text: out.text }], structuredContent: out.structured };
5
+ }
6
+ catch (err) {
7
+ const msg = err instanceof Error ? err.message : String(err);
8
+ return { content: [{ type: "text", text: msg }], isError: true };
9
+ }
10
+ }
11
+ export function registerTools(server, tools) {
12
+ for (const tool of tools) {
13
+ server.registerTool(tool.name, {
14
+ title: tool.title,
15
+ description: tool.description,
16
+ inputSchema: tool.inputSchema,
17
+ outputSchema: tool.outputSchema,
18
+ annotations: { readOnlyHint: true, openWorldHint: false },
19
+ }, async (args) => runTool(tool, args));
20
+ }
21
+ }
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { createServer, VERSION } from "./server.js";
4
+ function usage() {
5
+ console.log(`essay-stats-mcp ${VERSION}
6
+
7
+ Offline writing metrics for essays: word and page counts, readability, style flags and word limit checks.
8
+
9
+ Add it to your MCP app's config with command "npx" and args ["-y", "essay-stats-mcp"].
10
+
11
+ --help, --version`);
12
+ }
13
+ async function main() {
14
+ const cmd = process.argv[2];
15
+ if (cmd === "--help" || cmd === "-h")
16
+ return usage();
17
+ if (cmd === "--version" || cmd === "-v")
18
+ return console.log(VERSION);
19
+ await createServer().connect(new StdioServerTransport());
20
+ console.error(`essay-stats-mcp ${VERSION} running`);
21
+ }
22
+ main().catch((e) => {
23
+ console.error(e);
24
+ process.exit(1);
25
+ });
@@ -0,0 +1,9 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { registerTools } from "./core/tools.js";
3
+ import { tools } from "./tools.js";
4
+ export const VERSION = "0.1.1";
5
+ export function createServer() {
6
+ const server = new McpServer({ name: "essay-stats-mcp", version: VERSION });
7
+ registerTools(server, tools);
8
+ return server;
9
+ }
@@ -0,0 +1,209 @@
1
+ /** Text analysis helpers. Everything here is pure and works offline. */
2
+ const ABBREVIATIONS = new Set([
3
+ "mr", "mrs", "ms", "dr", "prof", "sr", "jr", "st", "vs", "etc", "e.g", "i.e", "fig", "no", "al",
4
+ ]);
5
+ export function words(text) {
6
+ return text.match(/[A-Za-z0-9]+(?:['’][A-Za-z]+)*(?:-[A-Za-z0-9]+)*/g) ?? [];
7
+ }
8
+ /** Whitespace separated word count, which is how word processors count. */
9
+ export function wordCount(text) {
10
+ const t = text.trim();
11
+ return t === "" ? 0 : t.split(/\s+/).filter((w) => /[A-Za-z0-9]/.test(w)).length;
12
+ }
13
+ export function splitSentences(text) {
14
+ const out = [];
15
+ const flat = text.replace(/\s+/g, " ").trim();
16
+ if (!flat)
17
+ return out;
18
+ let start = 0;
19
+ const re = /[.!?]+["'”’)\]]*\s+/g;
20
+ let m;
21
+ while ((m = re.exec(flat))) {
22
+ const end = m.index + m[0].length;
23
+ const before = flat.slice(start, m.index + 1);
24
+ const lastWord = (before.match(/([A-Za-z.]+)\.$/)?.[1] ?? "").toLowerCase().replace(/\.$/, "");
25
+ const next = flat[end] ?? "";
26
+ const isAbbrev = m[0].startsWith(".") && ABBREVIATIONS.has(lastWord);
27
+ const isInitial = /(^|\s)[A-Z]\.$/.test(before.trim());
28
+ if (isAbbrev || isInitial || (m[0].startsWith(".") && /[a-z]/.test(next)))
29
+ continue;
30
+ out.push(flat.slice(start, end).trim());
31
+ start = end;
32
+ }
33
+ const rest = flat.slice(start).trim();
34
+ if (rest)
35
+ out.push(rest);
36
+ return out.filter((s) => /[A-Za-z0-9]/.test(s));
37
+ }
38
+ export function splitParagraphs(text) {
39
+ return text
40
+ .split(/\r?\n\s*\r?\n/)
41
+ .map((p) => p.trim())
42
+ .filter((p) => /[A-Za-z0-9]/.test(p));
43
+ }
44
+ export function syllables(word) {
45
+ let w = word.toLowerCase().replace(/[^a-z]/g, "");
46
+ if (!w)
47
+ return 0;
48
+ if (w.length <= 3)
49
+ return 1;
50
+ w = w.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/, "").replace(/^y/, "");
51
+ const groups = w.match(/[aeiouy]{1,2}/g);
52
+ return Math.max(1, groups ? groups.length : 1);
53
+ }
54
+ export const round = (n, places = 1) => {
55
+ const f = 10 ** places;
56
+ return Math.round(n * f) / f;
57
+ };
58
+ /** Words per page for double and single spacing at common fonts and sizes. */
59
+ const FONT_WORDS_PER_PAGE = {
60
+ "times new roman": 550,
61
+ arial: 500,
62
+ calibri: 520,
63
+ georgia: 480,
64
+ "courier new": 400,
65
+ verdana: 430,
66
+ };
67
+ export const FONTS = Object.keys(FONT_WORDS_PER_PAGE);
68
+ export function pageEstimate(wordTotal, font, fontSize, spacing) {
69
+ const base = FONT_WORDS_PER_PAGE[font.trim().toLowerCase()];
70
+ if (base === undefined) {
71
+ throw new Error(`Unknown font "${font}". Use one of: ${FONTS.join(", ")}.`);
72
+ }
73
+ const sizeFactor = 12 / fontSize;
74
+ const spacingFactor = spacing === "single" ? 1 : spacing === "1.5" ? 1 / 1.5 : 0.5;
75
+ const perPage = base * sizeFactor * sizeFactor * spacingFactor;
76
+ return wordTotal / perPage;
77
+ }
78
+ export function counts(text) {
79
+ const ws = words(text);
80
+ let syl = 0;
81
+ let complex = 0;
82
+ for (const w of ws) {
83
+ const s = syllables(w);
84
+ syl += s;
85
+ if (s >= 3)
86
+ complex += 1;
87
+ }
88
+ return {
89
+ words: ws.length,
90
+ sentences: splitSentences(text).length,
91
+ syllables: syl,
92
+ complexWords: complex,
93
+ polysyllables: complex,
94
+ };
95
+ }
96
+ const IRREGULAR_PARTICIPLES = new Set([
97
+ "done", "made", "given", "taken", "seen", "known", "shown", "written", "chosen", "found", "held",
98
+ "built", "sent", "kept", "left", "lost", "paid", "read", "said", "sold", "told", "thought",
99
+ "brought", "caught", "taught", "bought", "begun", "broken", "driven", "eaten", "fallen", "forgotten",
100
+ "gotten", "grown", "hidden", "ridden", "spoken", "stolen", "thrown", "worn", "won", "set", "put",
101
+ "cut", "hit", "let", "led", "met", "understood", "drawn", "born", "run", "become", "gone",
102
+ ]);
103
+ const NOT_PARTICIPLES = new Set([
104
+ "need", "indeed", "speed", "feed", "seed", "red", "bed", "hundred", "embed",
105
+ // Adjectives that look like participles and usually describe a state.
106
+ "tired", "excited", "interested", "worried", "bored", "scared", "surprised", "pleased", "concerned",
107
+ "confused", "relaxed", "exhausted", "satisfied", "disappointed", "amazed", "shocked", "annoyed",
108
+ "supposed", "used", "married", "prepared", "ashamed", "afraid", "determined", "talented", "advanced",
109
+ ]);
110
+ export function findPassive(sentences) {
111
+ const hits = [];
112
+ const re = /\b(am|is|are|was|were|be|been|being)\s+(?:(?:not|also|often|always|never|already|still|just|really|then|even|first|later|usually|generally)\s+)*([a-z]+)\b/gi;
113
+ for (const s of sentences) {
114
+ re.lastIndex = 0;
115
+ let m;
116
+ while ((m = re.exec(s))) {
117
+ const part = m[2].toLowerCase();
118
+ if (NOT_PARTICIPLES.has(part))
119
+ continue;
120
+ const regular = part.length > 3 && part.endsWith("ed");
121
+ if (regular || IRREGULAR_PARTICIPLES.has(part)) {
122
+ hits.push({ sentence: s, phrase: m[0] });
123
+ break;
124
+ }
125
+ }
126
+ }
127
+ return hits;
128
+ }
129
+ const FILLER_WORDS = [
130
+ "very", "really", "just", "quite", "actually", "basically", "literally", "totally", "simply",
131
+ "rather", "somewhat", "definitely", "extremely", "certainly", "essentially", "virtually",
132
+ ];
133
+ const FILLER_PHRASES = [
134
+ "in order to", "due to the fact that", "at the end of the day", "it is important to note that",
135
+ "in my opinion", "a lot of", "kind of", "sort of", "needless to say", "for all intents and purposes",
136
+ "the fact that", "in the event that", "at this point in time",
137
+ ];
138
+ export function findFiller(text) {
139
+ const lower = text.toLowerCase();
140
+ const found = [];
141
+ for (const item of [...FILLER_PHRASES, ...FILLER_WORDS]) {
142
+ const re = new RegExp(`\\b${item.replace(/ /g, "\\s+")}\\b`, "g");
143
+ const n = (lower.match(re) ?? []).length;
144
+ if (n > 0)
145
+ found.push({ text: item, count: n });
146
+ }
147
+ return found.sort((a, b) => b.count - a.count || a.text.localeCompare(b.text));
148
+ }
149
+ /** Words that start 3 or more sentences, or 2 or more in a row. */
150
+ export function findRepeatedOpeners(sentences, minRun = 2) {
151
+ const openers = sentences.map((s) => (words(s)[0] ?? "").toLowerCase());
152
+ const byWord = new Map();
153
+ openers.forEach((w, i) => {
154
+ if (!w)
155
+ return;
156
+ byWord.set(w, [...(byWord.get(w) ?? []), i + 1]);
157
+ });
158
+ const hits = [];
159
+ for (const [word, idx] of byWord) {
160
+ let run = 1;
161
+ let longest = 1;
162
+ for (let i = 1; i < idx.length; i++) {
163
+ run = idx[i] === idx[i - 1] + 1 ? run + 1 : 1;
164
+ longest = Math.max(longest, run);
165
+ }
166
+ if (idx.length >= 3 || longest >= minRun)
167
+ hits.push({ word, count: idx.length, sentences: idx });
168
+ }
169
+ return hits.sort((a, b) => b.count - a.count || a.word.localeCompare(b.word));
170
+ }
171
+ /**
172
+ * Cuts out a references section (everything from a heading such as "References",
173
+ * "Works Cited" or "Bibliography" on its own line) and returns what is left.
174
+ */
175
+ export function stripReferences(text) {
176
+ const re = /^[ \t]*(references|works cited|bibliography|reference list|sources)[ \t]*:?[ \t]*$/im;
177
+ const m = re.exec(text);
178
+ if (!m)
179
+ return { body: text, removed: "" };
180
+ return { body: text.slice(0, m.index), removed: text.slice(m.index) };
181
+ }
182
+ /** Removes quoted passages: block quotes starting with ">" and text inside double quotes. */
183
+ export function stripQuotes(text) {
184
+ const removed = [];
185
+ let body = text.replace(/^[ \t]*>.*$/gm, (m) => {
186
+ removed.push(m);
187
+ return "";
188
+ });
189
+ body = body.replace(/["“]([^"“”\n]{2,}?)["”]/g, (m) => {
190
+ removed.push(m);
191
+ return " ";
192
+ });
193
+ return { body, removed: removed.join("\n") };
194
+ }
195
+ const COMMON_WORDS = new Set("a about after all also an and any are as at be because been but by can could did do does for from had has have he her his how i if in into is it its may more most my no not of on one or our out she so some than that the their them then there these they this to up was we were what when which who will with would you your".split(" "));
196
+ /** Counts how often each word is used, ignoring case. Common small words are skipped unless asked for. */
197
+ export function wordFrequency(text, includeCommon = false) {
198
+ const all = words(text).map((w) => w.toLowerCase().replace(/['’]s$/, ""));
199
+ const counted = new Map();
200
+ for (const w of all) {
201
+ if (!includeCommon && (COMMON_WORDS.has(w) || w.length < 3))
202
+ continue;
203
+ counted.set(w, (counted.get(w) ?? 0) + 1);
204
+ }
205
+ const hits = [...counted.entries()]
206
+ .map(([word, count]) => ({ word, count, percent: round((count / all.length) * 100, 2) }))
207
+ .sort((a, b) => b.count - a.count || a.word.localeCompare(b.word));
208
+ return { total: all.length, unique: new Set(all).size, hits };
209
+ }
@@ -0,0 +1,297 @@
1
+ import { z } from "zod";
2
+ import { counts, findFiller, findPassive, findRepeatedOpeners, pageEstimate, round, splitParagraphs, splitSentences, stripQuotes, stripReferences, wordCount, wordFrequency, } from "./text.js";
3
+ const EMPTY_TEXT_HINT = `text is empty. Paste the essay text to analyse. Worked example: { "text": "Your essay content here." }`;
4
+ const textInput = z.string().min(1, EMPTY_TEXT_HINT);
5
+ function requireText(text, toolName) {
6
+ if (!/[A-Za-z0-9]/.test(text)) {
7
+ const example = toolName === "check_word_limit"
8
+ ? `{ "text": "Your essay content here.", "limit": 1500, "exclude_references": true }`
9
+ : `{ "text": "Your essay content here." }`;
10
+ throw new Error(`The text has no words in it. Paste the essay text and try again. Worked example for ${toolName}: ${example}`);
11
+ }
12
+ }
13
+ const countText = {
14
+ name: "count_text",
15
+ title: "Count words, sentences and pages",
16
+ description: "Count the words, characters, sentences and paragraphs in a text, and estimate how many pages it fills at a given font, font size and line spacing. Inputs: text, and optional font (times new roman, arial, calibri, georgia, courier new or verdana, default times new roman), font_size in points (default 12) and spacing (single, 1.5 or double, default double). The page count is an estimate from typical words per page, so a word processor may differ by a little. Also returns an estimated reading time at 238 words per minute. Example: \"Count the words in this essay and estimate the pages in Times New Roman 12 double spaced.",
17
+ inputSchema: {
18
+ text: textInput,
19
+ font: z.string().optional().describe("Font name. Default times new roman."),
20
+ font_size: z.number().min(6).max(72).optional().describe("Font size in points. Default 12."),
21
+ spacing: z.enum(["single", "1.5", "double"]).optional().describe("Line spacing. Default double."),
22
+ },
23
+ outputSchema: {
24
+ words: z.number(),
25
+ characters: z.number(),
26
+ characters_no_spaces: z.number(),
27
+ sentences: z.number(),
28
+ paragraphs: z.number(),
29
+ estimated_pages: z.number(),
30
+ font: z.string(),
31
+ font_size: z.number(),
32
+ spacing: z.string(),
33
+ reading_minutes: z.number(),
34
+ },
35
+ run: ({ text, font = "times new roman", font_size = 12, spacing = "double" }) => {
36
+ requireText(text, "count_text");
37
+ const w = wordCount(text);
38
+ const pages = round(pageEstimate(w, font, font_size, spacing), 1);
39
+ const minutes = round(w / 238, 1);
40
+ const result = {
41
+ words: w,
42
+ characters: text.length,
43
+ characters_no_spaces: text.replace(/\s/g, "").length,
44
+ sentences: splitSentences(text).length,
45
+ paragraphs: splitParagraphs(text).length,
46
+ estimated_pages: pages,
47
+ font: font.trim().toLowerCase(),
48
+ font_size,
49
+ spacing,
50
+ reading_minutes: minutes,
51
+ };
52
+ return {
53
+ text: `${w} words, ${result.characters} characters (${result.characters_no_spaces} without spaces), ${result.sentences} sentences and ${result.paragraphs} paragraphs. About ${pages} pages in ${result.font} ${font_size} point with ${spacing} spacing. Reading time is about ${minutes} minutes.`,
54
+ structured: result,
55
+ };
56
+ },
57
+ };
58
+ function fleschLabel(score) {
59
+ if (score >= 90)
60
+ return "very easy";
61
+ if (score >= 80)
62
+ return "easy";
63
+ if (score >= 70)
64
+ return "fairly easy";
65
+ if (score >= 60)
66
+ return "plain English";
67
+ if (score >= 50)
68
+ return "fairly hard";
69
+ if (score >= 30)
70
+ return "hard";
71
+ return "very hard";
72
+ }
73
+ const readabilityScores = {
74
+ name: "readability_scores",
75
+ title: "Readability scores",
76
+ description: "Score how hard a text is to read with three standard formulas: Flesch Kincaid grade level (plus the Flesch reading ease score), Gunning Fog index and SMOG index. Each grade is roughly a US school grade, so 12 is the end of high school and 16 is a college degree. Input: text. SMOG is built for samples of 30 sentences or more, so on shorter text the tool still returns a number but marks it as less reliable. Example: \"Give me the Flesch Kincaid, Gunning Fog and SMOG scores for this paper.",
77
+ inputSchema: { text: textInput },
78
+ outputSchema: {
79
+ words: z.number(),
80
+ sentences: z.number(),
81
+ syllables: z.number(),
82
+ complex_words: z.number(),
83
+ flesch_kincaid_grade: z.number(),
84
+ flesch_reading_ease: z.number(),
85
+ reading_ease_label: z.string(),
86
+ gunning_fog: z.number(),
87
+ smog: z.number(),
88
+ smog_reliable: z.boolean(),
89
+ },
90
+ run: ({ text }) => {
91
+ requireText(text, "readability_scores");
92
+ const c = counts(text);
93
+ if (c.words === 0 || c.sentences === 0) {
94
+ throw new Error("The text needs at least one word and one sentence to score.");
95
+ }
96
+ const wps = c.words / c.sentences;
97
+ const spw = c.syllables / c.words;
98
+ const fk = 0.39 * wps + 11.8 * spw - 15.59;
99
+ const ease = 206.835 - 1.015 * wps - 84.6 * spw;
100
+ const fog = 0.4 * (wps + 100 * (c.complexWords / c.words));
101
+ const smog = 1.043 * Math.sqrt(c.polysyllables * (30 / c.sentences)) + 3.1291;
102
+ const reliable = c.sentences >= 30;
103
+ const result = {
104
+ words: c.words,
105
+ sentences: c.sentences,
106
+ syllables: c.syllables,
107
+ complex_words: c.complexWords,
108
+ flesch_kincaid_grade: round(fk),
109
+ flesch_reading_ease: round(ease),
110
+ reading_ease_label: fleschLabel(ease),
111
+ gunning_fog: round(fog),
112
+ smog: round(smog),
113
+ smog_reliable: reliable,
114
+ };
115
+ return {
116
+ text: `Flesch Kincaid grade ${result.flesch_kincaid_grade} (reading ease ${result.flesch_reading_ease}, ${result.reading_ease_label}). Gunning Fog ${result.gunning_fog}. SMOG ${result.smog}${reliable ? "" : ", less reliable because the text has fewer than 30 sentences"}. Based on ${c.words} words, ${c.sentences} sentences and ${c.complexWords} complex words.`,
117
+ structured: result,
118
+ };
119
+ },
120
+ };
121
+ const styleFlags = {
122
+ name: "style_flags",
123
+ title: "Style flags",
124
+ description: "Flag common style problems in an essay: sentences in the passive voice, sentences that start with the same word as a neighbour (or three or more times), filler words and phrases such as very, just, in order to, and sentences that are too long. Inputs: text, and optional max_sentence_words (default 30), the length above which a sentence counts as long. Sentence numbers start at 1 and follow the order of the text, so number 3 is the third sentence. The sentence_list field gives each passive or long sentence with its number, and the text summary ends with a line listing those numbers. The checks are simple pattern rules, so treat them as prompts to reread, not as errors. Example: \"Flag passive voice and filler words in my draft.",
125
+ inputSchema: {
126
+ text: textInput,
127
+ max_sentence_words: z.number().int().min(5).max(200).optional().describe("Sentence length that counts as long. Default 30."),
128
+ },
129
+ outputSchema: {
130
+ sentences: z.number(),
131
+ passive_count: z.number(),
132
+ passive_sentences: z.array(z.object({ phrase: z.string(), sentence: z.string() })),
133
+ repeated_openers: z.array(z.object({ word: z.string(), count: z.number(), sentences: z.array(z.number()) })),
134
+ filler: z.array(z.object({ text: z.string(), count: z.number() })),
135
+ filler_count: z.number(),
136
+ long_sentences: z.array(z.object({ number: z.number(), words: z.number(), sentence: z.string() })),
137
+ max_sentence_words: z.number(),
138
+ sentence_list: z.array(z.object({ number: z.number(), passive: z.boolean(), long: z.boolean(), sentence: z.string() })),
139
+ },
140
+ run: ({ text, max_sentence_words = 30 }) => {
141
+ requireText(text, "style_flags");
142
+ const sentences = splitSentences(text);
143
+ const passive = findPassive(sentences);
144
+ const openers = findRepeatedOpeners(sentences);
145
+ const filler = findFiller(text);
146
+ const long = sentences
147
+ .map((s, i) => ({ number: i + 1, words: wordCount(s), sentence: s }))
148
+ .filter((s) => s.words > max_sentence_words);
149
+ const fillerCount = filler.reduce((n, f) => n + f.count, 0);
150
+ let next = 0;
151
+ const longNumbers = new Set(long.map((l) => l.number));
152
+ const sentenceList = sentences
153
+ .map((s, i) => {
154
+ const isPassive = next < passive.length && passive[next].sentence === s;
155
+ if (isPassive)
156
+ next++;
157
+ return { number: i + 1, passive: isPassive, long: longNumbers.has(i + 1), sentence: s };
158
+ })
159
+ .filter((s) => s.passive || s.long);
160
+ const lines = [
161
+ `${sentences.length} sentences checked.`,
162
+ `Passive voice: ${passive.length}${passive.length ? " (" + passive.slice(0, 3).map((p) => `"${p.phrase}"`).join(", ") + (passive.length > 3 ? ", ..." : "") + ")" : ""}.`,
163
+ `Repeated openers: ${openers.length ? openers.map((o) => `"${o.word}" x${o.count}`).join(", ") : "none"}.`,
164
+ `Filler: ${fillerCount ? filler.map((f) => `"${f.text}" x${f.count}`).join(", ") : "none"}.`,
165
+ `Long sentences over ${max_sentence_words} words: ${long.length ? long.map((l) => `#${l.number} (${l.words} words)`).join(", ") : "none"}.`,
166
+ `Passive or long sentence numbers, in text order: ${sentenceList.length ? sentenceList.map((s) => s.number).join(", ") : "none"}.`,
167
+ ];
168
+ return {
169
+ text: lines.join("\n"),
170
+ structured: {
171
+ sentences: sentences.length,
172
+ passive_count: passive.length,
173
+ passive_sentences: passive.map((p) => ({ phrase: p.phrase, sentence: p.sentence })),
174
+ repeated_openers: openers,
175
+ filler,
176
+ filler_count: fillerCount,
177
+ long_sentences: long,
178
+ max_sentence_words,
179
+ sentence_list: sentenceList,
180
+ },
181
+ };
182
+ },
183
+ };
184
+ const checkWordLimit = {
185
+ name: "check_word_limit",
186
+ title: "Check a word limit",
187
+ description: "Compare an essay against a word limit. Inputs: text, limit (the maximum word count), optional minimum (a lower bound), optional tolerance_percent (how far over the limit is still acceptable, default 0, a common rule is 10), optional exclude_references (cut everything from a heading line such as References, Works Cited or Bibliography to the end) and optional exclude_quotes (leave out block quotes that start with > and text inside double quotes). Returns the counted words, how many are left or over, and what was excluded. Example: \"Is this under 2000 words if I leave out the works cited and quotes?.",
188
+ inputSchema: {
189
+ text: textInput,
190
+ limit: z.number().int().positive().describe("Maximum number of words."),
191
+ minimum: z.number().int().min(0).optional().describe("Minimum number of words."),
192
+ tolerance_percent: z.number().min(0).max(100).optional().describe("Percent over the limit that is still fine. Default 0."),
193
+ exclude_references: z.boolean().optional().describe("Leave out the references section. Default false."),
194
+ exclude_quotes: z.boolean().optional().describe("Leave out quoted passages. Default false."),
195
+ },
196
+ outputSchema: {
197
+ status: z.enum(["under_minimum", "within_limit", "within_tolerance", "over_limit"]),
198
+ total_words: z.number(),
199
+ counted_words: z.number(),
200
+ excluded_reference_words: z.number(),
201
+ excluded_quote_words: z.number(),
202
+ limit: z.number(),
203
+ minimum: z.number().nullable(),
204
+ allowed_maximum: z.number(),
205
+ words_remaining: z.number(),
206
+ words_over: z.number(),
207
+ },
208
+ run: ({ text, limit, minimum, tolerance_percent = 0, exclude_references = false, exclude_quotes = false }) => {
209
+ requireText(text, "check_word_limit");
210
+ if (minimum !== undefined && minimum > limit) {
211
+ throw new Error(`minimum (${minimum}) is above limit (${limit}). Set minimum to at most the limit. Worked example: { "text": "Your essay content here.", "limit": 1500, "minimum": 1200 }`);
212
+ }
213
+ const total = wordCount(text);
214
+ let body = text;
215
+ let refWords = 0;
216
+ let quoteWords = 0;
217
+ if (exclude_references) {
218
+ const r = stripReferences(body);
219
+ body = r.body;
220
+ refWords = wordCount(r.removed);
221
+ }
222
+ if (exclude_quotes) {
223
+ const q = stripQuotes(body);
224
+ body = q.body;
225
+ quoteWords = wordCount(q.removed);
226
+ }
227
+ const counted = wordCount(body);
228
+ const allowed = Math.floor(limit * (1 + tolerance_percent / 100));
229
+ let status;
230
+ if (minimum !== undefined && counted < minimum)
231
+ status = "under_minimum";
232
+ else if (counted <= limit)
233
+ status = "within_limit";
234
+ else if (counted <= allowed)
235
+ status = "within_tolerance";
236
+ else
237
+ status = "over_limit";
238
+ const remaining = Math.max(0, limit - counted);
239
+ const over = Math.max(0, counted - limit);
240
+ const summary = {
241
+ under_minimum: `Under the minimum. ${counted} words counted, ${minimum - counted} short of ${minimum}.`,
242
+ within_limit: `Within the limit. ${counted} of ${limit} words, ${remaining} left.`,
243
+ within_tolerance: `Over the limit of ${limit} by ${over} words, but inside the ${tolerance_percent} percent tolerance (up to ${allowed}).`,
244
+ over_limit: `Over the limit. ${counted} words counted against ${limit}, so ${over} to cut${tolerance_percent ? ` (tolerance allows up to ${allowed})` : ""}.`,
245
+ };
246
+ const excluded = [
247
+ exclude_references ? `${refWords} reference words left out` : "",
248
+ exclude_quotes ? `${quoteWords} quote words left out` : "",
249
+ ].filter(Boolean);
250
+ return {
251
+ text: summary[status] + (excluded.length ? ` (${total} words in total, ${excluded.join(", ")}.)` : ""),
252
+ structured: {
253
+ status,
254
+ total_words: total,
255
+ counted_words: counted,
256
+ excluded_reference_words: refWords,
257
+ excluded_quote_words: quoteWords,
258
+ limit,
259
+ minimum: minimum ?? null,
260
+ allowed_maximum: allowed,
261
+ words_remaining: remaining,
262
+ words_over: over,
263
+ },
264
+ };
265
+ },
266
+ };
267
+ const wordFrequencyTool = {
268
+ name: "word_frequency",
269
+ title: "Word frequency",
270
+ description: "Find the words an essay uses most, to spot overused or repeated terms. Inputs: text, and optional top (how many words to list, default 10), min_count (fewest uses for a word to be listed, default 2) and include_common_words (also count small words such as the, and, of and to, default false). Case is ignored, and words under 3 letters are skipped unless include_common_words is true. Each word comes with its count and its share of all the words in the text. Example: \"Which words do I overuse in this essay?.",
271
+ inputSchema: {
272
+ text: textInput,
273
+ top: z.number().int().min(1).max(100).optional().describe("How many words to list. Default 10."),
274
+ min_count: z.number().int().min(1).optional().describe("Fewest uses for a word to be listed. Default 2."),
275
+ include_common_words: z.boolean().optional().describe("Also count small common words. Default false."),
276
+ },
277
+ outputSchema: {
278
+ total_words: z.number(),
279
+ unique_words: z.number(),
280
+ words: z.array(z.object({ word: z.string(), count: z.number(), percent: z.number() })),
281
+ top: z.number(),
282
+ min_count: z.number(),
283
+ },
284
+ run: ({ text, top = 10, min_count = 2, include_common_words = false }) => {
285
+ requireText(text, "word_frequency");
286
+ const f = wordFrequency(text, include_common_words);
287
+ const list = f.hits.filter((h) => h.count >= min_count).slice(0, top);
288
+ const summary = list.length
289
+ ? `Most used words: ${list.map((h) => `"${h.word}" x${h.count} (${h.percent} percent)`).join(", ")}.`
290
+ : `No word is used ${min_count} or more times.`;
291
+ return {
292
+ text: `${f.total} words, ${f.unique} different. ${summary}`,
293
+ structured: { total_words: f.total, unique_words: f.unique, words: list, top, min_count },
294
+ };
295
+ },
296
+ };
297
+ export const tools = [countText, readabilityScores, styleFlags, checkWordLimit, wordFrequencyTool];
package/llms.txt ADDED
@@ -0,0 +1,49 @@
1
+ # Essay Stats MCP
2
+
3
+ > An MCP server with offline writing metrics for essays. It counts words and pages, scores readability, flags style problems and checks word limits. No account, no API key, no network.
4
+
5
+ Package: essay-stats-mcp (npm). Registry name: io.github.AnonymousOnyx22/essay-stats-mcp. Runs over stdio. Needs Node.js 20 or newer.
6
+
7
+ ## Install
8
+
9
+ Add this to the MCP config of Claude Desktop, Claude Code, Cursor, VS Code or Windsurf:
10
+
11
+ ```json
12
+ {
13
+ "mcpServers": {
14
+ "essay-stats": {
15
+ "command": "npx",
16
+ "args": ["-y", "essay-stats-mcp"]
17
+ }
18
+ }
19
+ }
20
+ ```
21
+
22
+ VS Code uses a `servers` key instead of `mcpServers`.
23
+
24
+ ## Tools
25
+
26
+ All tools are read only and work on text passed in the call.
27
+
28
+ - count_text: words, characters, sentences, paragraphs, reading time and estimated pages. Inputs: text, optional font (times new roman, arial, calibri, georgia, courier new, verdana), font_size (default 12) and spacing (single, 1.5, double; default double).
29
+ - readability_scores: Flesch Kincaid grade, Flesch reading ease, Gunning Fog and SMOG. Input: text. SMOG is marked less reliable under 30 sentences.
30
+ - style_flags: passive voice, repeated sentence openers, filler words and long sentences. Inputs: text, optional max_sentence_words (default 30).
31
+ - word_frequency: the most used words with counts and share of the text, to spot overused terms. Inputs: text, optional top (default 10), min_count (default 2) and include_common_words (default false).
32
+ - check_word_limit: compares text with a limit. Inputs: text, limit, optional minimum, tolerance_percent, exclude_references and exclude_quotes. Returns a status of under_minimum, within_limit, within_tolerance or over_limit.
33
+
34
+ ## Example prompts
35
+
36
+ - "Count the words in this essay and estimate the pages in Times New Roman 12 double spaced."
37
+ - "Give me the Flesch Kincaid, Gunning Fog and SMOG scores for this paper."
38
+ - "Flag passive voice and filler words in my draft."
39
+ - "Which words do I overuse in this essay?"
40
+ - "Is this under 2000 words if I leave out the works cited and quotes?"
41
+
42
+ ## Privacy
43
+
44
+ Everything runs locally. The server makes no network requests and stores nothing. No keys or passwords are needed.
45
+
46
+ ## Links
47
+
48
+ - Source: https://github.com/AnonymousOnyx22/essay-stats-mcp
49
+ - License: MIT
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "essay-stats-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Essay Stats MCP counts words and pages offline for essays, scores readability, flags passive voice and filler words, and checks word limits against assignment requirements. No account, no network.",
5
+ "type": "module",
6
+ "main": "build/src/index.js",
7
+ "bin": {
8
+ "essay-stats-mcp": "build/src/index.js"
9
+ },
10
+ "files": [
11
+ "build/src",
12
+ "README.md",
13
+ "llms.txt",
14
+ "CHANGELOG.md",
15
+ "LICENSE"
16
+ ],
17
+ "engines": {
18
+ "node": ">=20"
19
+ },
20
+ "scripts": {
21
+ "build": "tsc && node -e \"require('fs').chmodSync('build/src/index.js', 0o755)\"",
22
+ "test": "vitest run",
23
+ "start": "node build/src/index.js",
24
+ "prepublishOnly": "npm run build && npm test"
25
+ },
26
+ "keywords": [
27
+ "essay stats mcp",
28
+ "essay stats",
29
+ "essay word counter",
30
+ "word counter",
31
+ "word count",
32
+ "page count",
33
+ "readability",
34
+ "readability score",
35
+ "flesch kincaid",
36
+ "gunning fog",
37
+ "smog index",
38
+ "passive voice",
39
+ "writing metrics",
40
+ "word limit",
41
+ "word frequency",
42
+ "reading time",
43
+ "style checker",
44
+ "student writing",
45
+ "mcp",
46
+ "mcp server",
47
+ "model context protocol",
48
+ "claude desktop",
49
+ "cursor"
50
+ ],
51
+ "author": "AnonymousOnyx22",
52
+ "license": "MIT",
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/AnonymousOnyx22/essay-stats-mcp.git"
56
+ },
57
+ "homepage": "https://github.com/AnonymousOnyx22/essay-stats-mcp#readme",
58
+ "bugs": {
59
+ "url": "https://github.com/AnonymousOnyx22/essay-stats-mcp/issues"
60
+ },
61
+ "mcpName": "io.github.AnonymousOnyx22/essay-stats-mcp",
62
+ "dependencies": {
63
+ "@modelcontextprotocol/sdk": "^1.32.1",
64
+ "zod": "^4.6.7"
65
+ },
66
+ "devDependencies": {
67
+ "@types/node": "^26.6.5",
68
+ "typescript": "^7.0.2",
69
+ "vitest": "^5.0.5"
70
+ }
71
+ }