get_writing_stats
Analyze writing projects to track progress, check quality, and maintain consistency across chapters, dates, or tags in markdown manuscripts.
Instructions
Overall project statistics
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_path | No | Path to manuscript directory (defaults to current directory) | |
| scope | No | File scope pattern | |
| breakdown_by | No | Breakdown method |
Implementation Reference
- src/tools/WriterToolHandlers.ts:287-291 (handler)MCP tool handler function for 'get_writing_stats' that extracts scope from input args and delegates to WritersAid.getStats method.private async getWritingStats(args: Record<string, unknown>) { const scope = args.scope as string | undefined; return this.writersAid.getStats({ scope }); }
- src/WritersAid.ts:270-285 (helper)Core helper method in WritersAid that computes project writing statistics by querying storage for all files and aggregating word counts, file counts, averages, and per-file details.async getStats(_options?: { scope?: string }) { const files = await this.storage.getAllFiles(); const totalWords = files.reduce((sum, f) => sum + (f.word_count || 0), 0); const totalFiles = files.length; return { totalWords, totalFiles, averageWordsPerFile: totalFiles > 0 ? Math.round(totalWords / totalFiles) : 0, files: files.map((f) => ({ path: f.file_path, words: f.word_count || 0, lastModified: f.last_modified, })), }; }
- JSON schema definition for the get_writing_stats tool, including input properties and descriptions.{ name: "get_writing_stats", description: "Overall project statistics", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Path to manuscript directory (defaults to current directory)" }, scope: { type: "string", description: "File scope pattern" }, breakdown_by: { type: "string", enum: ["chapter", "date", "tag"], description: "Breakdown method", }, }, }, },
- src/index.ts:73-75 (registration)MCP server registration for listing available tools, which includes the get_writing_stats tool schema from writerToolDefinitions.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: writerToolDefinitions, }));
- src/index.ts:86-91 (registration)MCP server tool call handler registration that instantiates WritersAid and WriterToolHandlers, then dispatches to the specific tool handler via handleTool.const writersAid = new WritersAid({ projectPath }); const handlers = new WriterToolHandlers(writersAid); // Call the tool const result = await handlers.handleTool(name, args || {});