ai-readme-mcp 0.4.5 → 0.4.7

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.
Files changed (2) hide show
  1. package/README.md +755 -756
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,756 +1,755 @@
1
- # AI_README MCP Server
2
-
3
- > A smart documentation system that helps AI assistants understand and follow your project's conventions
4
-
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue)](https://www.typescriptlang.org/)
7
- [![Node](https://img.shields.io/badge/Node.js-18+-green)](https://nodejs.org/)
8
-
9
- ## 📑 Quick Navigation
10
-
11
- - [Installation & Setup](#-installation--setup)
12
- - [For Claude Code](#for-claude-code-vscode-extension)
13
- - [For Cursor](#for-cursor)
14
- - [For GitHub Copilot](#for-github-copilot-vscode-1102)
15
- - [For Claude Desktop](#for-claude-desktop-application)
16
- - [Alternative Installation Methods](#alternative-installation-methods)
17
- - [Create Your First AI_README](#create-your-first-ai_readme)
18
- - [Multi-Level AI_README](#multi-level-ai_readme-not-just-for-monorepos)
19
- - [Available MCP Tools](#️-available-mcp-tools)
20
-
21
- ---
22
-
23
- ## 📋 Overview
24
-
25
- **AI_README MCP Server** is a Model Context Protocol (MCP) server that helps AI assistants understand your project conventions through dedicated `AI_README.md` guide files. It automatically discovers, routes, and manages these files so AI can generate consistent, high-quality code that matches your team's standards.
26
-
27
- **Works with:** GitHub Copilot (VSCode 1.102+), Claude Code, Cursor, and other MCP-compatible AI tools.
28
-
29
- ---
30
-
31
- ## 🎯 The Problem
32
-
33
- When working with AI assistants (like Claude, GPT, or other AI coding tools), you've probably experienced:
34
-
35
- - ❌ **Inconsistent code style** - AI generates code that doesn't match your project's conventions
36
- - ❌ **Repeated instructions** - You have to tell the AI the same rules over and over
37
- - ❌ **Team inconsistency** - Different team members get different AI outputs, leading to fragmented code quality
38
- - ❌ **Context loss** - AI forgets your project's specific patterns and best practices
39
- - ❌ **No single source of truth** - Team conventions exist in Slack messages, PRs, and people's heads, not in a format AI can use
40
-
41
- ## 💡 The Solution
42
-
43
- **AI_README.md** - A dedicated guide file specifically designed for AI assistants to read.
44
-
45
- Think of it as:
46
- - 📖 A "style guide" that AI reads before writing code
47
- - 🎓 An "onboarding document" that teaches AI your project's conventions
48
- - 🔧 A "configuration file" for AI behavior in your codebase
49
- - 🤝 A **"team contract"** that ensures every developer's AI assistant follows the same standards
50
-
51
- ### How It Works
52
-
53
- 1. **Create** `AI_README.md` files in your project (root or specific directories)
54
- 2. **Document** your conventions: coding standards, architecture patterns, naming rules, testing requirements
55
- 3. **Commit to git** - Share conventions with your entire team
56
- 4. **AI reads it automatically** before making changes - ensuring every team member's AI follows the same rules
57
- 5. **Keep it in sync** - AI can update the README as your project evolves
58
-
59
- ### What This MCP Server Does
60
-
61
- This MCP (Model Context Protocol) server automates the entire workflow:
62
-
63
- - 🔍 **Auto-discovers** all AI_README.md files in your project
64
- - 🎯 **Routes context** - AI gets the most relevant README for the code it's editing
65
- - 🚀 **Guided initialization** - `init_ai_readme` scans for empty files and guides AI through population
66
- - ✏️ **Updates automatically** - AI can add new conventions it discovers while coding
67
- - ✅ **Validates quality** - Ensures READMEs are concise and optimized for AI consumption
68
-
69
- **Result:** Every AI interaction in your project follows your team's standards and produces consistent, high-quality code.
70
-
71
- ---
72
-
73
- ## ✨ Features
74
-
75
- - 🔍 **Automatic Discovery** - Scan and index all AI_README.md files in your project
76
- - 🎯 **Smart Context Routing** - Find relevant README content based on file paths
77
- - 🤝 **Team Consistency** - Every team member's AI assistant reads the same conventions from git, ensuring uniform code quality
78
- - 🚀 **Guided Initialization** - `init_ai_readme` tool scans for empty files and guides AI through population
79
- - 🔄 **Update & Sync** - AI can both read and update AI_README files
80
- - **Validation & Quality** - Ensure README consistency with token limits and structure checks
81
- - 🏗️ **Monorepo Support** - Place AI_README.md files at different folder levels; the tool automatically finds and uses the most relevant one
82
- - 📦 **Easy Integration** - Works seamlessly with Cursor, Claude Code, and other MCP clients
83
-
84
- ---
85
-
86
- ## 🚀 Installation & Setup
87
-
88
- ### For Claude Code (VSCode Extension)
89
-
90
- **Step 1: Add MCP Server**
91
-
92
- In your project directory, run:
93
-
94
- ```bash
95
- claude mcp add --scope project ai-readme-manager npx -- -y ai-readme-mcp
96
- ```
97
-
98
- This creates a `.mcp.json` file that uses `npx` to run the package - no installation or path configuration needed!
99
-
100
- **Step 2: Enable Project MCP Servers**
101
-
102
- Create or edit `.claude/settings.local.json` in your project:
103
-
104
- ```json
105
- {
106
- "enableAllProjectMcpServers": true
107
- }
108
- ```
109
-
110
- **Step 3: Auto-approve MCP Tools (Optional but Recommended)**
111
-
112
- To avoid "Yes/No" prompts every time and enable "Yes, Do not ask again" option, add the tools to your allow list.
113
-
114
- In `.claude/settings.local.json`, add:
115
-
116
- ```json
117
- {
118
- "permissions": {
119
- "allow": [
120
- "mcp__ai-readme-manager__discover_ai_readmes",
121
- "mcp__ai-readme-manager__get_context_for_file",
122
- "mcp__ai-readme-manager__update_ai_readme",
123
- "mcp__ai-readme-manager__validate_ai_readmes",
124
- "mcp__ai-readme-manager__init_ai_readme"
125
- ]
126
- },
127
- "enableAllProjectMcpServers": true
128
- }
129
- ```
130
-
131
- > **Note:** Without this configuration, you'll be prompted for approval every time Claude uses these tools, and the "Do not ask again" option won't appear.
132
-
133
- **Step 4: Verify Installation**
134
-
135
- ```bash
136
- claude mcp get ai-readme-manager
137
- ```
138
-
139
- You should see `Status: ✓ Connected`
140
-
141
- ### For Cursor
142
-
143
- Add to Cursor's MCP configuration file:
144
- - **Windows:** `%APPDATA%\Cursor\User\mcp.json`
145
- - **macOS/Linux:** `~/.cursor/mcp.json`
146
-
147
- ```json
148
- {
149
- "mcpServers": {
150
- "ai-readme-manager": {
151
- "command": "npx",
152
- "args": ["-y", "ai-readme-mcp"]
153
- }
154
- }
155
- }
156
- ```
157
-
158
- After configuring, restart Cursor completely.
159
-
160
- ### For GitHub Copilot (VSCode 1.102+)
161
-
162
- **Requirements:**
163
- - VSCode 1.102 or later
164
- - GitHub Copilot & Copilot Chat extensions installed
165
-
166
- **Option 1: Using VSCode Settings UI**
167
-
168
- 1. Open VSCode Settings (Ctrl+,)
169
- 2. Search for "MCP"
170
- 3. Click "Edit in settings.json"
171
- 4. Add the MCP server configuration
172
-
173
- **Option 2: Manual Configuration**
174
-
175
- Add to your VSCode `settings.json`:
176
-
177
- ```json
178
- {
179
- "github.copilot.chat.mcp.servers": {
180
- "ai-readme-manager": {
181
- "command": "npx",
182
- "args": ["-y", "ai-readme-mcp"]
183
- }
184
- }
185
- }
186
- ```
187
-
188
- After configuring, restart VSCode and you'll see the MCP tools available in GitHub Copilot Chat!
189
-
190
- ### For Claude Desktop Application
191
-
192
- Add to `claude_desktop_config.json`:
193
- - **Windows:** `%APPDATA%\claude\claude_desktop_config.json`
194
- - **macOS:** `~/Library/Application Support/Claude/config.json`
195
- - **Linux:** `~/.config/claude/config.json`
196
-
197
- ```json
198
- {
199
- "mcpServers": {
200
- "ai-readme-manager": {
201
- "command": "npx",
202
- "args": ["-y", "ai-readme-mcp"]
203
- }
204
- }
205
- }
206
- ```
207
-
208
- ### Alternative Installation Methods
209
-
210
- The above methods use `npx` (recommended). If you prefer other approaches, you can use these configurations in your MCP config file:
211
- - **Claude Code:** `.mcp.json` (project root)
212
- - **Cursor:** `%APPDATA%\Cursor\User\mcp.json` (Windows) or `~/.cursor/mcp.json` (macOS/Linux)
213
- - **Claude Desktop:** `claude_desktop_config.json` (see paths above)
214
-
215
- **Option 1: Using npx (Recommended)**
216
-
217
- No installation needed! Just configure and use via npx:
218
-
219
- ```json
220
- {
221
- "mcpServers": {
222
- "ai-readme-manager": {
223
- "command": "npx",
224
- "args": ["-y", "ai-readme-mcp"]
225
- }
226
- }
227
- }
228
- ```
229
-
230
- > The `-y` flag automatically accepts the npx prompt.
231
-
232
- **Option 2: Global Installation**
233
-
234
- Install once globally, use everywhere:
235
-
236
- ```bash
237
- npm install -g ai-readme-mcp
238
- ```
239
-
240
- Then configure:
241
-
242
- ```json
243
- {
244
- "mcpServers": {
245
- "ai-readme-manager": {
246
- "command": "ai-readme-mcp"
247
- }
248
- }
249
- }
250
- ```
251
-
252
- > **Pros:** Faster startup (no npx download). **Cons:** Need to manually update when new versions release.
253
-
254
- ---
255
-
256
- ## Create Your First AI_README
257
-
258
- You have two main approaches to create and populate AI_README files:
259
-
260
- ### Option 1: Automated Initialization (Recommended)
261
-
262
- Use the `init_ai_readme` tool to automatically scan and populate empty AI_README files:
263
-
264
- **Step 1:** Create empty AI_README.md files where needed
265
-
266
- ```bash
267
- # Example: Create empty AI_READMEs in different directories
268
- touch AI_README.md
269
- touch apps/backend/AI_README.md
270
- touch apps/frontend/AI_README.md
271
- ```
272
-
273
- **Step 2:** Trigger the initialization
274
-
275
- In your AI assistant (Claude Code, Cursor, etc.), simply say:
276
-
277
- > "Please run init_ai_readme for this project"
278
-
279
- Or more explicitly:
280
-
281
- > "Initialize AI_README files"
282
- > "Help me populate the empty AI_README files"
283
-
284
- **What happens:**
285
- - 🔍 Scans your project for empty AI_README files
286
- - 📝 Creates root-level AI_README if none exist
287
- - 📋 Provides detailed step-by-step instructions for each file
288
- - 🤖 AI assistant will then:
289
- - Explore relevant directories
290
- - Analyze your codebase (tech stack, patterns, conventions)
291
- - Populate each AI_README with relevant documentation
292
-
293
- **When to use `init_ai_readme`:**
294
- - First time setting up AI_README in your project
295
- - After creating new empty AI_README.md files in subdirectories
296
- - When `get_context_for_file` detects empty AI_README files
297
- - To batch-process multiple empty AI_README files
298
-
299
- ### Option 2: Manual Creation
300
-
301
- Create and write AI_README.md files yourself:
302
-
303
- ```markdown
304
- # My Project
305
-
306
- ## Tech Stack
307
- - Framework: React + Express
308
- - Database: PostgreSQL
309
- - Testing: Jest + Vitest
310
-
311
- ## Architecture Patterns
312
- - Follows MVC pattern for backend
313
- - Component-based architecture for frontend
314
- - RESTful API design
315
-
316
- ## Coding Conventions
317
- - Use TypeScript for all files
318
- - Components in PascalCase
319
- - Functions and variables in camelCase
320
- - Test coverage: 80%+ required
321
-
322
- ## Testing
323
- Run tests with: `npm test`
324
- Write tests alongside source files
325
- ```
326
-
327
- **Best Practices:**
328
- - Keep it concise (< 400 tokens is ideal)
329
- - Focus on conventions, not documentation
330
- - Update as your project evolves
331
- - Use AI to help maintain it
332
-
333
- ---
334
-
335
- ## Multi-Level AI_README (Not Just for Monorepos!)
336
-
337
- **The power of this tool is multi-level documentation** - not just for monorepos, but for **any project** that wants to organize conventions by module or feature.
338
-
339
- **Why multi-level?**
340
- - 🎯 **Avoid bloated root README** - Keep each README focused and concise
341
- - 📍 **Precise context** - AI gets only the relevant conventions for the code it's working on
342
- - 🔧 **Flexible organization** - Organize by feature, module, or any structure that makes sense
343
-
344
- Simply place `AI_README.md` files at different folder levels:
345
-
346
- ```
347
- my-monorepo/
348
- ├── AI_README.md # Root-level conventions (applies to all)
349
- ├── apps/
350
- │ ├── frontend/
351
- │ │ ├── AI_README.md # Frontend-specific conventions
352
- └── src/components/Button.tsx
353
- └── backend/
354
- ├── AI_README.md # Backend-specific conventions
355
- └── src/api/users.ts
356
- └── packages/
357
- └── shared/
358
- ├── AI_README.md # Shared library conventions
359
- └── src/utils.ts
360
- ```
361
-
362
- **Smart Empty README Handling:**
363
- - 📝 Create empty `AI_README.md` files in subdirectories where you need specific conventions
364
- - 🚀 Run `init_ai_readme` tool (just tell your AI: "Please initialize AI_README files")
365
- - 🤖 AI automatically analyzes each directory and populates conventions
366
- - 🔗 For subdirectories with parent READMEs, generates differential content (only module-specific conventions)
367
- - 📋 For root directories, generates full project analysis
368
-
369
- When AI works on a file, it automatically gets:
370
- - The **most relevant** AI_README (closest parent directory)
371
- - Plus the **root-level** AI_README (for project-wide standards)
372
-
373
- For example, when editing `apps/frontend/src/components/Button.tsx`:
374
- - ✅ Gets `apps/frontend/AI_README.md` (React component standards)
375
- - ✅ Gets root `AI_README.md` (project-wide Git, testing conventions)
376
-
377
- ### Test the Integration
378
-
379
- Restart your IDE, then ask your AI assistant:
380
-
381
- > "I'm about to create a new component. What conventions should I follow?"
382
-
383
- The AI will automatically retrieve your AI_README context!
384
-
385
- For detailed setup instructions, see [Quick Start Guide](./docs/QUICK_START.md).
386
-
387
- ---
388
-
389
- ## 🏗️ Project Structure
390
-
391
- ```
392
- ai-readme-mcp/
393
- ├── src/
394
- │ ├── index.ts # MCP Server entry point
395
- │ ├── tools/ # MCP Tools implementation
396
- │ ├── core/ # Core logic (scanner, router, updater)
397
- ├── types/ # TypeScript type definitions
398
- │ └── utils/ # Utility functions
399
- ├── tests/
400
- │ ├── unit/ # Unit tests
401
- ├── integration/ # Integration tests
402
- └── fixtures/ # Test fixtures
403
- └── docs/ # Documentation
404
- ```
405
-
406
- ## 🛠️ Development
407
-
408
- ### Prerequisites
409
-
410
- - Node.js 18+
411
- - npm/pnpm/yarn
412
- - TypeScript 5+
413
-
414
- ### Setup
415
-
416
- ```bash
417
- # Clone the repository
418
- git clone https://github.com/Draco-Cheng/ai-readme-mcp.git
419
- cd ai-readme-mcp
420
-
421
- # Install dependencies
422
- npm install
423
-
424
- # Run type checking
425
- npm run typecheck
426
-
427
- # Run tests
428
- npm test
429
-
430
- # Build the project
431
- npm run build
432
-
433
- # Development mode with watch
434
- npm run dev
435
- ```
436
-
437
- ### Local Development Configuration
438
-
439
- If you're developing or modifying the source code, configure your MCP client to use your local build:
440
-
441
- **For Claude Code - Add with CLI:**
442
-
443
- ```bash
444
- # Linux/macOS:
445
- claude mcp add --transport stdio ai-readme-manager --scope project -- node ~/ai-readme-mcp/dist/index.js
446
-
447
- # Windows:
448
- claude mcp add --transport stdio ai-readme-manager --scope project -- node C:\Users\YourName\ai-readme-mcp\dist\index.js
449
- ```
450
-
451
- **For Claude Code - Manual `.mcp.json`:**
452
-
453
- ```json
454
- {
455
- "mcpServers": {
456
- "ai-readme-manager": {
457
- "type": "stdio",
458
- "command": "node",
459
- "args": ["/absolute/path/to/ai-readme-mcp/dist/index.js"]
460
- }
461
- }
462
- }
463
- ```
464
-
465
- **For Cursor or Claude Desktop:**
466
-
467
- ```json
468
- {
469
- "mcpServers": {
470
- "ai-readme-manager": {
471
- "command": "node",
472
- "args": ["/absolute/path/to/ai-readme-mcp/dist/index.js"]
473
- }
474
- }
475
- }
476
- ```
477
-
478
- **Path examples:**
479
- - **Windows:** `"C:\\Users\\YourName\\ai-readme-mcp\\dist\\index.js"` (use `\\` for escaping)
480
- - **macOS/Linux:** `"/home/username/ai-readme-mcp/dist/index.js"`
481
-
482
- ---
483
-
484
- ## 📚 Documentation
485
-
486
- - **[Quick Start Guide](./docs/QUICK_START.md)** - Get started in 10 minutes
487
- - **[Contributing Guide](./CONTRIBUTING.md)** - How to contribute
488
- - [Project Specification](./docs/SPEC.md) - Complete technical specification
489
-
490
- ---
491
-
492
- ## 🛠️ Available MCP Tools
493
-
494
- ### `discover_ai_readmes`
495
-
496
- Scans your project and discovers all AI_README.md files.
497
-
498
- ```typescript
499
- // Parameters
500
- {
501
- projectRoot: string; // Required: Project root directory
502
- excludePatterns?: string[]; // Optional: Glob patterns to exclude
503
- }
504
-
505
- // Returns
506
- {
507
- projectRoot: string;
508
- totalFound: number;
509
- readmeFiles: Array<{
510
- path: string;
511
- scope: string;
512
- level: number;
513
- patterns: string[];
514
- }>;
515
- lastUpdated: string;
516
- }
517
- ```
518
-
519
- ### `get_context_for_file`
520
-
521
- Gets relevant AI_README context for a specific file path.
522
-
523
- ```typescript
524
- // Parameters
525
- {
526
- projectRoot: string; // Required: Project root directory
527
- filePath: string; // Required: File path relative to root
528
- includeRoot?: boolean; // Optional: Include root README (default: true)
529
- excludePatterns?: string[]; // Optional: Glob patterns to exclude
530
- }
531
-
532
- // Returns
533
- {
534
- filePath: string;
535
- totalContexts: number;
536
- contexts: Array<{
537
- path: string;
538
- relevance: 'root' | 'direct' | 'parent';
539
- distance: number;
540
- content: string;
541
- }>;
542
- formattedPrompt: string; // Ready-to-use formatted context
543
- }
544
- ```
545
-
546
- ### `update_ai_readme`
547
-
548
- Update an AI_README.md file with specified operations.
549
-
550
- ```typescript
551
- // Parameters
552
- {
553
- readmePath: string; // Required: Path to AI_README.md file
554
- operations: Array<{ // Required: Update operations to perform
555
- type: 'append' | 'prepend' | 'replace' | 'insert-after' | 'insert-before';
556
- content: string; // Content to add or replace
557
- section?: string; // Section heading (for insert operations)
558
- searchText?: string; // Text to search for (for replace)
559
- }>;
560
- }
561
-
562
- // Returns
563
- {
564
- success: boolean;
565
- readmePath: string;
566
- changes: Array<{
567
- operation: string;
568
- section?: string;
569
- linesAdded: number;
570
- linesRemoved: number;
571
- }>;
572
- summary: string; // Includes reminder to use git diff
573
- error?: string; // Error message if failed
574
- }
575
- ```
576
-
577
- **Note:** Changes are written directly to the file. Use Git for version control:
578
- - Review changes: `git diff AI_README.md`
579
- - Undo changes: `git checkout AI_README.md`
580
- - Commit changes: `git add AI_README.md && git commit -m "Update AI_README"`
581
- ```
582
-
583
- **Example Usage:**
584
-
585
- ```typescript
586
- // Append new section
587
- {
588
- readmePath: "apps/frontend/AI_README.md",
589
- operations: [{
590
- type: "append",
591
- content: "## Performance\n- Use React.memo for expensive components"
592
- }]
593
- }
594
-
595
- // Insert after specific section
596
- {
597
- readmePath: "AI_README.md",
598
- operations: [{
599
- type: "insert-after",
600
- section: "## Coding Conventions",
601
- content: "### Code Style\n- Use TypeScript strict mode\n- Prefer const over let"
602
- }]
603
- }
604
-
605
- // Replace specific text
606
- {
607
- readmePath: "AI_README.md",
608
- operations: [{
609
- type: "replace",
610
- searchText: "Run tests with npm test",
611
- content: "Run tests with: `npm test` or `npm run test:watch`"
612
- }]
613
- }
614
- ```
615
-
616
- ### `init_ai_readme`
617
-
618
- Initialize and populate empty AI_README files in your project.
619
-
620
- ```typescript
621
- // Parameters
622
- {
623
- projectRoot: string; // Required: Project root directory
624
- excludePatterns?: string[]; // Optional: Glob patterns to exclude
625
- targetPath?: string; // Optional: Specific directory to initialize
626
- }
627
-
628
- // Returns
629
- {
630
- success: boolean;
631
- message: string;
632
- readmesToInitialize: string[]; // Paths to empty AI_README files
633
- instructions: string; // Detailed step-by-step guide for populating
634
- }
635
- ```
636
-
637
- **Features:**
638
- - 🔍 Scans project for empty or missing AI_README files
639
- - 📝 Creates root-level AI_README if none exist
640
- - 📋 Generates detailed step-by-step instructions for each file
641
- - 🎯 Can target specific directories with `targetPath` parameter
642
- - 🤖 Guides AI through analysis: tech stack, patterns, conventions
643
-
644
- **Example Usage:**
645
-
646
- ```typescript
647
- // Initialize all empty AI_READMEs in project
648
- {
649
- projectRoot: "/path/to/project"
650
- }
651
-
652
- // Initialize only in specific directory
653
- {
654
- projectRoot: "/path/to/project",
655
- targetPath: "apps/backend"
656
- }
657
- ```
658
-
659
- **Typical Workflow:**
660
- 1. AI assistant runs `init_ai_readme`
661
- 2. Receives detailed instructions for each empty file
662
- 3. Follows instructions:
663
- - Uses `Glob` to scan directory
664
- - Reads 2-5 key source files
665
- - Analyzes tech stack, patterns, conventions
666
- 4. Uses `update_ai_readme` to populate each file
667
- 5. Verifies with `get_context_for_file` or `validate_ai_readmes`
668
-
669
- ### `validate_ai_readmes`
670
-
671
- Validate all AI_README.md files in your project for quality and token efficiency.
672
-
673
- ```typescript
674
- // Parameters
675
- {
676
- projectRoot: string; // Required: Project root directory
677
- excludePatterns?: string[]; // Optional: Glob patterns to exclude
678
- config?: { // Optional: Custom validation config
679
- maxTokens?: number;
680
- rules?: {
681
- requireH1?: boolean;
682
- requireSections?: string[];
683
- allowCodeBlocks?: boolean;
684
- maxLineLength?: number;
685
- };
686
- tokenLimits?: {
687
- excellent?: number; // Default: 200
688
- good?: number; // Default: 400
689
- warning?: number; // Default: 600
690
- error?: number; // Default: 1000
691
- };
692
- };
693
- }
694
-
695
- // Returns
696
- {
697
- valid: boolean;
698
- totalFiles: number;
699
- results: Array<{
700
- path: string;
701
- valid: boolean;
702
- tokens: number;
703
- rating: 'excellent' | 'good' | 'needs-improvement' | 'too-long';
704
- issues: string[];
705
- suggestions: string[];
706
- }>;
707
- summary: string;
708
- }
709
- ```
710
-
711
- **Validation Features**:
712
- - Token counting for AI consumption optimization
713
- - Structure validation (H1 heading, sections)
714
- - Line length checks (default: 100 chars)
715
- - Code block detection (disabled by default for strict mode)
716
- - Quality ratings based on token count
717
-
718
- **Default Token Limits (Strict Mode)**:
719
- - 🌟 Excellent: < 200 tokens
720
- - Good: < 400 tokens
721
- - ⚠️ Needs improvement: < 600 tokens
722
- - ❌ Too long: > 1000 tokens
723
-
724
- ---
725
-
726
- ## 🚀 What's Next
727
-
728
- We're actively working on new features:
729
-
730
- - **Auto-populate Empty AI_README** - Automatically generate AI_README content when `get_context_for_file` detects empty files, reducing manual initialization steps
731
- - **Enhanced Tool Triggering** - Improve tool descriptions and prompts to ensure AI assistants trigger tools at the right moments with better precision and reliability
732
- - **CI/CD Integration** - GitHub Actions for automated README validation
733
- - **VSCode Extension** - Native VSCode extension with visual UI for managing AI_README files, offering a more integrated experience alongside the current MCP server
734
-
735
- Want to contribute? Check out our [Contributing Guide](./CONTRIBUTING.md)!
736
-
737
- ---
738
-
739
- ## 🤝 Contributing
740
-
741
- Contributions are welcome! Please feel free to submit a Pull Request.
742
-
743
- ## 📄 License
744
-
745
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
746
-
747
- ## 🔗 Related Resources
748
-
749
- - [Model Context Protocol Specification](https://spec.modelcontextprotocol.io/)
750
- - [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk)
751
- - [Claude Code MCP Documentation](https://docs.claude.com/en/docs/claude-code/mcp)
752
-
753
- ## 📧 Contact
754
-
755
- - GitHub Issues: https://github.com/Draco-Cheng/ai-readme-mcp/issues
756
- - Project Link: https://github.com/Draco-Cheng/ai-readme-mcp
1
+ # AI_README MCP Server
2
+
3
+ > A smart documentation system that helps AI assistants understand and follow your project's conventions
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue)](https://www.typescriptlang.org/)
7
+ [![Node](https://img.shields.io/badge/Node.js-18+-green)](https://nodejs.org/)
8
+
9
+ ## 📑 Quick Navigation
10
+
11
+ - Installation & Setup
12
+ - [For Claude Code](#for-claude-code-vscode-extension)
13
+ - [For Cursor](#for-cursor)
14
+ - [For GitHub Copilot](#for-github-copilot-vscode-1102)
15
+ - [For Claude Desktop](#for-claude-desktop-application)
16
+ - [Alternative Installation Methods](#alternative-installation-methods)
17
+ - [Create Your First AI_README](#create-your-first-ai_readme)
18
+ - [Multi-Level AI_README](#multi-level-ai_readme-not-just-for-monorepos)
19
+
20
+ ---
21
+
22
+ ## 📋 Overview
23
+
24
+ **AI_README MCP Server** is a Model Context Protocol (MCP) server that helps AI assistants understand your project conventions through dedicated `AI_README.md` guide files. It automatically discovers, routes, and manages these files so AI can generate consistent, high-quality code that matches your team's standards.
25
+
26
+ **Works with:** GitHub Copilot (VSCode 1.102+), Claude Code, Cursor, and other MCP-compatible AI tools.
27
+
28
+ ---
29
+
30
+ ## 🎯 The Problem
31
+
32
+ When working with AI assistants (like Claude, GPT, or other AI coding tools), you've probably experienced:
33
+
34
+ - ❌ **Inconsistent code style** - AI generates code that doesn't match your project's conventions
35
+ - ❌ **Repeated instructions** - You have to tell the AI the same rules over and over
36
+ - ❌ **Team inconsistency** - Different team members get different AI outputs, leading to fragmented code quality
37
+ - ❌ **Context loss** - AI forgets your project's specific patterns and best practices
38
+ - ❌ **No single source of truth** - Team conventions exist in Slack messages, PRs, and people's heads, not in a format AI can use
39
+
40
+ ## 💡 The Solution
41
+
42
+ **AI_README.md** - A dedicated guide file specifically designed for AI assistants to read.
43
+
44
+ Think of it as:
45
+ - 📖 A "style guide" that AI reads before writing code
46
+ - 🎓 An "onboarding document" that teaches AI your project's conventions
47
+ - 🔧 A "configuration file" for AI behavior in your codebase
48
+ - 🤝 A **"team contract"** that ensures every developer's AI assistant follows the same standards
49
+
50
+ ### How It Works
51
+
52
+ 1. **Create** `AI_README.md` files in your project (root or specific directories)
53
+ 2. **Document** your conventions: coding standards, architecture patterns, naming rules, testing requirements
54
+ 3. **Commit to git** - Share conventions with your entire team
55
+ 4. **AI reads it automatically** before making changes - ensuring every team member's AI follows the same rules
56
+ 5. **Keep it in sync** - AI can update the README as your project evolves
57
+
58
+ ### What This MCP Server Does
59
+
60
+ This MCP (Model Context Protocol) server automates the entire workflow:
61
+
62
+ - 🔍 **Auto-discovers** all AI_README.md files in your project
63
+ - 🎯 **Routes context** - AI gets the most relevant README for the code it's editing
64
+ - 🚀 **Guided initialization** - `init_ai_readme` scans for empty files and guides AI through population
65
+ - ✏️ **Updates automatically** - AI can add new conventions it discovers while coding
66
+ - **Validates quality** - Ensures READMEs are concise and optimized for AI consumption
67
+
68
+ **Result:** Every AI interaction in your project follows your team's standards and produces consistent, high-quality code.
69
+
70
+ ---
71
+
72
+ ## ✨ Features
73
+
74
+ - 🔍 **Automatic Discovery** - Scan and index all AI_README.md files in your project
75
+ - 🎯 **Smart Context Routing** - Find relevant README content based on file paths
76
+ - 🤝 **Team Consistency** - Every team member's AI assistant reads the same conventions from git, ensuring uniform code quality
77
+ - 🚀 **Guided Initialization** - `init_ai_readme` tool scans for empty files and guides AI through population
78
+ - 🔄 **Update & Sync** - AI can both read and update AI_README files
79
+ - **Validation & Quality** - Ensure README consistency with token limits and structure checks
80
+ - 🏗️ **Monorepo Support** - Place AI_README.md files at different folder levels; the tool automatically finds and uses the most relevant one
81
+ - 📦 **Easy Integration** - Works seamlessly with Cursor, Claude Code, and other MCP clients
82
+
83
+ ---
84
+
85
+ ## 🚀 Installation & Setup
86
+
87
+ ### For Claude Code (VSCode Extension)
88
+
89
+ **Step 1: Add MCP Server**
90
+
91
+ In your project directory, run:
92
+
93
+ ```bash
94
+ claude mcp add --scope project ai-readme-manager npx -- -y ai-readme-mcp
95
+ ```
96
+
97
+ This creates a `.mcp.json` file that uses `npx` to run the package - no installation or path configuration needed!
98
+
99
+ **Step 2: Enable Project MCP Servers**
100
+
101
+ Create or edit `.claude/settings.local.json` in your project:
102
+
103
+ ```json
104
+ {
105
+ "enableAllProjectMcpServers": true
106
+ }
107
+ ```
108
+
109
+ **Step 3: Auto-approve MCP Tools (Optional but Recommended)**
110
+
111
+ To avoid "Yes/No" prompts every time and enable "Yes, Do not ask again" option, add the tools to your allow list.
112
+
113
+ In `.claude/settings.local.json`, add:
114
+
115
+ ```json
116
+ {
117
+ "permissions": {
118
+ "allow": [
119
+ "mcp__ai-readme-manager__discover_ai_readmes",
120
+ "mcp__ai-readme-manager__get_context_for_file",
121
+ "mcp__ai-readme-manager__update_ai_readme",
122
+ "mcp__ai-readme-manager__validate_ai_readmes",
123
+ "mcp__ai-readme-manager__init_ai_readme"
124
+ ]
125
+ },
126
+ "enableAllProjectMcpServers": true
127
+ }
128
+ ```
129
+
130
+ > **Note:** Without this configuration, you'll be prompted for approval every time Claude uses these tools, and the "Do not ask again" option won't appear.
131
+
132
+ **Step 4: Verify Installation**
133
+
134
+ ```bash
135
+ claude mcp get ai-readme-manager
136
+ ```
137
+
138
+ You should see `Status: ✓ Connected`
139
+
140
+ ### For Cursor
141
+
142
+ Add to Cursor's MCP configuration file:
143
+ - **Windows:** `%APPDATA%\Cursor\User\mcp.json`
144
+ - **macOS/Linux:** `~/.cursor/mcp.json`
145
+
146
+ ```json
147
+ {
148
+ "mcpServers": {
149
+ "ai-readme-manager": {
150
+ "command": "npx",
151
+ "args": ["-y", "ai-readme-mcp"]
152
+ }
153
+ }
154
+ }
155
+ ```
156
+
157
+ After configuring, restart Cursor completely.
158
+
159
+ ### For GitHub Copilot (VSCode 1.102+)
160
+
161
+ **Requirements:**
162
+ - VSCode 1.102 or later
163
+ - GitHub Copilot & Copilot Chat extensions installed
164
+
165
+ **Option 1: Using VSCode Settings UI**
166
+
167
+ 1. Open VSCode Settings (Ctrl+,)
168
+ 2. Search for "MCP"
169
+ 3. Click "Edit in settings.json"
170
+ 4. Add the MCP server configuration
171
+
172
+ **Option 2: Manual Configuration**
173
+
174
+ Add to your VSCode `settings.json`:
175
+
176
+ ```json
177
+ {
178
+ "github.copilot.chat.mcp.servers": {
179
+ "ai-readme-manager": {
180
+ "command": "npx",
181
+ "args": ["-y", "ai-readme-mcp"]
182
+ }
183
+ }
184
+ }
185
+ ```
186
+
187
+ After configuring, restart VSCode and you'll see the MCP tools available in GitHub Copilot Chat!
188
+
189
+ ### For Claude Desktop Application
190
+
191
+ Add to `claude_desktop_config.json`:
192
+ - **Windows:** `%APPDATA%\claude\claude_desktop_config.json`
193
+ - **macOS:** `~/Library/Application Support/Claude/config.json`
194
+ - **Linux:** `~/.config/claude/config.json`
195
+
196
+ ```json
197
+ {
198
+ "mcpServers": {
199
+ "ai-readme-manager": {
200
+ "command": "npx",
201
+ "args": ["-y", "ai-readme-mcp"]
202
+ }
203
+ }
204
+ }
205
+ ```
206
+
207
+ ### Alternative Installation Methods
208
+
209
+ The above methods use `npx` (recommended). If you prefer other approaches, you can use these configurations in your MCP config file:
210
+ - **Claude Code:** `.mcp.json` (project root)
211
+ - **Cursor:** `%APPDATA%\Cursor\User\mcp.json` (Windows) or `~/.cursor/mcp.json` (macOS/Linux)
212
+ - **Claude Desktop:** `claude_desktop_config.json` (see paths above)
213
+
214
+ **Option 1: Using npx (Recommended)**
215
+
216
+ No installation needed! Just configure and use via npx:
217
+
218
+ ```json
219
+ {
220
+ "mcpServers": {
221
+ "ai-readme-manager": {
222
+ "command": "npx",
223
+ "args": ["-y", "ai-readme-mcp"]
224
+ }
225
+ }
226
+ }
227
+ ```
228
+
229
+ > The `-y` flag automatically accepts the npx prompt.
230
+
231
+ **Option 2: Global Installation**
232
+
233
+ Install once globally, use everywhere:
234
+
235
+ ```bash
236
+ npm install -g ai-readme-mcp
237
+ ```
238
+
239
+ Then configure:
240
+
241
+ ```json
242
+ {
243
+ "mcpServers": {
244
+ "ai-readme-manager": {
245
+ "command": "ai-readme-mcp"
246
+ }
247
+ }
248
+ }
249
+ ```
250
+
251
+ > **Pros:** Faster startup (no npx download). **Cons:** Need to manually update when new versions release.
252
+
253
+ ---
254
+
255
+ ## Create Your First AI_README
256
+
257
+ You have two main approaches to create and populate AI_README files:
258
+
259
+ ### Option 1: Automated Initialization (Recommended)
260
+
261
+ Use the `init_ai_readme` tool to automatically scan and populate empty AI_README files:
262
+
263
+ **Step 1:** Create empty AI_README.md files where needed
264
+
265
+ ```bash
266
+ # Example: Create empty AI_READMEs in different directories
267
+ touch AI_README.md
268
+ touch apps/backend/AI_README.md
269
+ touch apps/frontend/AI_README.md
270
+ ```
271
+
272
+ **Step 2:** Trigger the initialization
273
+
274
+ In your AI assistant (Claude Code, Cursor, etc.), simply say:
275
+
276
+ > "Please run init_ai_readme for this project"
277
+
278
+ Or more explicitly:
279
+
280
+ > "Initialize AI_README files"
281
+ > "Help me populate the empty AI_README files"
282
+
283
+ **What happens:**
284
+ - 🔍 Scans your project for empty AI_README files
285
+ - 📝 Creates root-level AI_README if none exist
286
+ - 📋 Provides detailed step-by-step instructions for each file
287
+ - 🤖 AI assistant will then:
288
+ - Explore relevant directories
289
+ - Analyze your codebase (tech stack, patterns, conventions)
290
+ - Populate each AI_README with relevant documentation
291
+
292
+ **When to use `init_ai_readme`:**
293
+ - First time setting up AI_README in your project
294
+ - After creating new empty AI_README.md files in subdirectories
295
+ - When `get_context_for_file` detects empty AI_README files
296
+ - To batch-process multiple empty AI_README files
297
+
298
+ ### Option 2: Manual Creation
299
+
300
+ Create and write AI_README.md files yourself:
301
+
302
+ ```markdown
303
+ # My Project
304
+
305
+ ## Tech Stack
306
+ - Framework: React + Express
307
+ - Database: PostgreSQL
308
+ - Testing: Jest + Vitest
309
+
310
+ ## Architecture Patterns
311
+ - Follows MVC pattern for backend
312
+ - Component-based architecture for frontend
313
+ - RESTful API design
314
+
315
+ ## Coding Conventions
316
+ - Use TypeScript for all files
317
+ - Components in PascalCase
318
+ - Functions and variables in camelCase
319
+ - Test coverage: 80%+ required
320
+
321
+ ## Testing
322
+ Run tests with: `npm test`
323
+ Write tests alongside source files
324
+ ```
325
+
326
+ **Best Practices:**
327
+ - Keep it concise (< 400 tokens is ideal)
328
+ - Focus on conventions, not documentation
329
+ - Update as your project evolves
330
+ - Use AI to help maintain it
331
+
332
+ ---
333
+
334
+ ## Multi-Level AI_README (Not Just for Monorepos!)
335
+
336
+ **The power of this tool is multi-level documentation** - not just for monorepos, but for **any project** that wants to organize conventions by module or feature.
337
+
338
+ **Why multi-level?**
339
+ - 🎯 **Avoid bloated root README** - Keep each README focused and concise
340
+ - 📍 **Precise context** - AI gets only the relevant conventions for the code it's working on
341
+ - 🔧 **Flexible organization** - Organize by feature, module, or any structure that makes sense
342
+
343
+ Simply place `AI_README.md` files at different folder levels:
344
+
345
+ ```
346
+ my-monorepo/
347
+ ├── AI_README.md # Root-level conventions (applies to all)
348
+ ├── apps/
349
+ ├── frontend/
350
+ ├── AI_README.md # Frontend-specific conventions
351
+ │ │ └── src/components/Button.tsx
352
+ │ └── backend/
353
+ ├── AI_README.md # Backend-specific conventions
354
+ └── src/api/users.ts
355
+ └── packages/
356
+ └── shared/
357
+ ├── AI_README.md # Shared library conventions
358
+ └── src/utils.ts
359
+ ```
360
+
361
+ **Smart Empty README Handling:**
362
+ - 📝 Create empty `AI_README.md` files in subdirectories where you need specific conventions
363
+ - 🚀 Run `init_ai_readme` tool (just tell your AI: "Please initialize AI_README files")
364
+ - 🤖 AI automatically analyzes each directory and populates conventions
365
+ - 🔗 For subdirectories with parent READMEs, generates differential content (only module-specific conventions)
366
+ - 📋 For root directories, generates full project analysis
367
+
368
+ When AI works on a file, it automatically gets:
369
+ - The **most relevant** AI_README (closest parent directory)
370
+ - Plus the **root-level** AI_README (for project-wide standards)
371
+
372
+ For example, when editing `apps/frontend/src/components/Button.tsx`:
373
+ - Gets `apps/frontend/AI_README.md` (React component standards)
374
+ - ✅ Gets root `AI_README.md` (project-wide Git, testing conventions)
375
+
376
+ ### Test the Integration
377
+
378
+ Restart your IDE, then ask your AI assistant:
379
+
380
+ > "I'm about to create a new component. What conventions should I follow?"
381
+
382
+ The AI will automatically retrieve your AI_README context!
383
+
384
+ For detailed setup instructions, see [Quick Start Guide](./docs/QUICK_START.md).
385
+
386
+ ---
387
+
388
+ ## 🏗️ Project Structure
389
+
390
+ ```
391
+ ai-readme-mcp/
392
+ ├── src/
393
+ ├── index.ts # MCP Server entry point
394
+ │ ├── tools/ # MCP Tools implementation
395
+ │ ├── core/ # Core logic (scanner, router, updater)
396
+ │ ├── types/ # TypeScript type definitions
397
+ └── utils/ # Utility functions
398
+ ├── tests/
399
+ ├── unit/ # Unit tests
400
+ │ ├── integration/ # Integration tests
401
+ └── fixtures/ # Test fixtures
402
+ └── docs/ # Documentation
403
+ ```
404
+
405
+ ## 🛠️ Development
406
+
407
+ ### Prerequisites
408
+
409
+ - Node.js 18+
410
+ - npm/pnpm/yarn
411
+ - TypeScript 5+
412
+
413
+ ### Setup
414
+
415
+ ```bash
416
+ # Clone the repository
417
+ git clone https://github.com/Draco-Cheng/ai-readme-mcp.git
418
+ cd ai-readme-mcp
419
+
420
+ # Install dependencies
421
+ npm install
422
+
423
+ # Run type checking
424
+ npm run typecheck
425
+
426
+ # Run tests
427
+ npm test
428
+
429
+ # Build the project
430
+ npm run build
431
+
432
+ # Development mode with watch
433
+ npm run dev
434
+ ```
435
+
436
+ ### Local Development Configuration
437
+
438
+ If you're developing or modifying the source code, configure your MCP client to use your local build:
439
+
440
+ **For Claude Code - Add with CLI:**
441
+
442
+ ```bash
443
+ # Linux/macOS:
444
+ claude mcp add --transport stdio ai-readme-manager --scope project -- node ~/ai-readme-mcp/dist/index.js
445
+
446
+ # Windows:
447
+ claude mcp add --transport stdio ai-readme-manager --scope project -- node C:\Users\YourName\ai-readme-mcp\dist\index.js
448
+ ```
449
+
450
+ **For Claude Code - Manual `.mcp.json`:**
451
+
452
+ ```json
453
+ {
454
+ "mcpServers": {
455
+ "ai-readme-manager": {
456
+ "type": "stdio",
457
+ "command": "node",
458
+ "args": ["/absolute/path/to/ai-readme-mcp/dist/index.js"]
459
+ }
460
+ }
461
+ }
462
+ ```
463
+
464
+ **For Cursor or Claude Desktop:**
465
+
466
+ ```json
467
+ {
468
+ "mcpServers": {
469
+ "ai-readme-manager": {
470
+ "command": "node",
471
+ "args": ["/absolute/path/to/ai-readme-mcp/dist/index.js"]
472
+ }
473
+ }
474
+ }
475
+ ```
476
+
477
+ **Path examples:**
478
+ - **Windows:** `"C:\\Users\\YourName\\ai-readme-mcp\\dist\\index.js"` (use `\\` for escaping)
479
+ - **macOS/Linux:** `"/home/username/ai-readme-mcp/dist/index.js"`
480
+
481
+ ---
482
+
483
+ ## 📚 Documentation
484
+
485
+ - **[Quick Start Guide](./docs/QUICK_START.md)** - Get started in 10 minutes
486
+ - **[Contributing Guide](./CONTRIBUTING.md)** - How to contribute
487
+ - [Project Specification](./docs/SPEC.md) - Complete technical specification
488
+
489
+ ---
490
+
491
+ ## 🛠️ Available MCP Tools
492
+
493
+ ### `discover_ai_readmes`
494
+
495
+ Scans your project and discovers all AI_README.md files.
496
+
497
+ ```typescript
498
+ // Parameters
499
+ {
500
+ projectRoot: string; // Required: Project root directory
501
+ excludePatterns?: string[]; // Optional: Glob patterns to exclude
502
+ }
503
+
504
+ // Returns
505
+ {
506
+ projectRoot: string;
507
+ totalFound: number;
508
+ readmeFiles: Array<{
509
+ path: string;
510
+ scope: string;
511
+ level: number;
512
+ patterns: string[];
513
+ }>;
514
+ lastUpdated: string;
515
+ }
516
+ ```
517
+
518
+ ### `get_context_for_file`
519
+
520
+ Gets relevant AI_README context for a specific file path.
521
+
522
+ ```typescript
523
+ // Parameters
524
+ {
525
+ projectRoot: string; // Required: Project root directory
526
+ filePath: string; // Required: File path relative to root
527
+ includeRoot?: boolean; // Optional: Include root README (default: true)
528
+ excludePatterns?: string[]; // Optional: Glob patterns to exclude
529
+ }
530
+
531
+ // Returns
532
+ {
533
+ filePath: string;
534
+ totalContexts: number;
535
+ contexts: Array<{
536
+ path: string;
537
+ relevance: 'root' | 'direct' | 'parent';
538
+ distance: number;
539
+ content: string;
540
+ }>;
541
+ formattedPrompt: string; // Ready-to-use formatted context
542
+ }
543
+ ```
544
+
545
+ ### `update_ai_readme`
546
+
547
+ Update an AI_README.md file with specified operations.
548
+
549
+ ```typescript
550
+ // Parameters
551
+ {
552
+ readmePath: string; // Required: Path to AI_README.md file
553
+ operations: Array<{ // Required: Update operations to perform
554
+ type: 'append' | 'prepend' | 'replace' | 'insert-after' | 'insert-before';
555
+ content: string; // Content to add or replace
556
+ section?: string; // Section heading (for insert operations)
557
+ searchText?: string; // Text to search for (for replace)
558
+ }>;
559
+ }
560
+
561
+ // Returns
562
+ {
563
+ success: boolean;
564
+ readmePath: string;
565
+ changes: Array<{
566
+ operation: string;
567
+ section?: string;
568
+ linesAdded: number;
569
+ linesRemoved: number;
570
+ }>;
571
+ summary: string; // Includes reminder to use git diff
572
+ error?: string; // Error message if failed
573
+ }
574
+ ```
575
+
576
+ **Note:** Changes are written directly to the file. Use Git for version control:
577
+ - Review changes: `git diff AI_README.md`
578
+ - Undo changes: `git checkout AI_README.md`
579
+ - Commit changes: `git add AI_README.md && git commit -m "Update AI_README"`
580
+ ```
581
+
582
+ **Example Usage:**
583
+
584
+ ```typescript
585
+ // Append new section
586
+ {
587
+ readmePath: "apps/frontend/AI_README.md",
588
+ operations: [{
589
+ type: "append",
590
+ content: "## Performance\n- Use React.memo for expensive components"
591
+ }]
592
+ }
593
+
594
+ // Insert after specific section
595
+ {
596
+ readmePath: "AI_README.md",
597
+ operations: [{
598
+ type: "insert-after",
599
+ section: "## Coding Conventions",
600
+ content: "### Code Style\n- Use TypeScript strict mode\n- Prefer const over let"
601
+ }]
602
+ }
603
+
604
+ // Replace specific text
605
+ {
606
+ readmePath: "AI_README.md",
607
+ operations: [{
608
+ type: "replace",
609
+ searchText: "Run tests with npm test",
610
+ content: "Run tests with: `npm test` or `npm run test:watch`"
611
+ }]
612
+ }
613
+ ```
614
+
615
+ ### `init_ai_readme`
616
+
617
+ Initialize and populate empty AI_README files in your project.
618
+
619
+ ```typescript
620
+ // Parameters
621
+ {
622
+ projectRoot: string; // Required: Project root directory
623
+ excludePatterns?: string[]; // Optional: Glob patterns to exclude
624
+ targetPath?: string; // Optional: Specific directory to initialize
625
+ }
626
+
627
+ // Returns
628
+ {
629
+ success: boolean;
630
+ message: string;
631
+ readmesToInitialize: string[]; // Paths to empty AI_README files
632
+ instructions: string; // Detailed step-by-step guide for populating
633
+ }
634
+ ```
635
+
636
+ **Features:**
637
+ - 🔍 Scans project for empty or missing AI_README files
638
+ - 📝 Creates root-level AI_README if none exist
639
+ - 📋 Generates detailed step-by-step instructions for each file
640
+ - 🎯 Can target specific directories with `targetPath` parameter
641
+ - 🤖 Guides AI through analysis: tech stack, patterns, conventions
642
+
643
+ **Example Usage:**
644
+
645
+ ```typescript
646
+ // Initialize all empty AI_READMEs in project
647
+ {
648
+ projectRoot: "/path/to/project"
649
+ }
650
+
651
+ // Initialize only in specific directory
652
+ {
653
+ projectRoot: "/path/to/project",
654
+ targetPath: "apps/backend"
655
+ }
656
+ ```
657
+
658
+ **Typical Workflow:**
659
+ 1. AI assistant runs `init_ai_readme`
660
+ 2. Receives detailed instructions for each empty file
661
+ 3. Follows instructions:
662
+ - Uses `Glob` to scan directory
663
+ - Reads 2-5 key source files
664
+ - Analyzes tech stack, patterns, conventions
665
+ 4. Uses `update_ai_readme` to populate each file
666
+ 5. Verifies with `get_context_for_file` or `validate_ai_readmes`
667
+
668
+ ### `validate_ai_readmes`
669
+
670
+ Validate all AI_README.md files in your project for quality and token efficiency.
671
+
672
+ ```typescript
673
+ // Parameters
674
+ {
675
+ projectRoot: string; // Required: Project root directory
676
+ excludePatterns?: string[]; // Optional: Glob patterns to exclude
677
+ config?: { // Optional: Custom validation config
678
+ maxTokens?: number;
679
+ rules?: {
680
+ requireH1?: boolean;
681
+ requireSections?: string[];
682
+ allowCodeBlocks?: boolean;
683
+ maxLineLength?: number;
684
+ };
685
+ tokenLimits?: {
686
+ excellent?: number; // Default: 200
687
+ good?: number; // Default: 400
688
+ warning?: number; // Default: 600
689
+ error?: number; // Default: 1000
690
+ };
691
+ };
692
+ }
693
+
694
+ // Returns
695
+ {
696
+ valid: boolean;
697
+ totalFiles: number;
698
+ results: Array<{
699
+ path: string;
700
+ valid: boolean;
701
+ tokens: number;
702
+ rating: 'excellent' | 'good' | 'needs-improvement' | 'too-long';
703
+ issues: string[];
704
+ suggestions: string[];
705
+ }>;
706
+ summary: string;
707
+ }
708
+ ```
709
+
710
+ **Validation Features**:
711
+ - Token counting for AI consumption optimization
712
+ - Structure validation (H1 heading, sections)
713
+ - Line length checks (default: 100 chars)
714
+ - Code block detection (disabled by default for strict mode)
715
+ - Quality ratings based on token count
716
+
717
+ **Default Token Limits (Strict Mode)**:
718
+ - 🌟 Excellent: < 200 tokens
719
+ - Good: < 400 tokens
720
+ - ⚠️ Needs improvement: < 600 tokens
721
+ - Too long: > 1000 tokens
722
+
723
+ ---
724
+
725
+ ## 🚀 What's Next
726
+
727
+ We're actively working on new features:
728
+
729
+ - **Auto-populate Empty AI_README** - Automatically generate AI_README content when `get_context_for_file` detects empty files, reducing manual initialization steps
730
+ - **Enhanced Tool Triggering** - Improve tool descriptions and prompts to ensure AI assistants trigger tools at the right moments with better precision and reliability
731
+ - **CI/CD Integration** - GitHub Actions for automated README validation
732
+ - **VSCode Extension** - Native VSCode extension with visual UI for managing AI_README files, offering a more integrated experience alongside the current MCP server
733
+
734
+ Want to contribute? Check out our [Contributing Guide](./CONTRIBUTING.md)!
735
+
736
+ ---
737
+
738
+ ## 🤝 Contributing
739
+
740
+ Contributions are welcome! Please feel free to submit a Pull Request.
741
+
742
+ ## 📄 License
743
+
744
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
745
+
746
+ ## 🔗 Related Resources
747
+
748
+ - [Model Context Protocol Specification](https://spec.modelcontextprotocol.io/)
749
+ - [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk)
750
+ - [Claude Code MCP Documentation](https://docs.claude.com/en/docs/claude-code/mcp)
751
+
752
+ ## 📧 Contact
753
+
754
+ - GitHub Issues: https://github.com/Draco-Cheng/ai-readme-mcp/issues
755
+ - Project Link: https://github.com/Draco-Cheng/ai-readme-mcp