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