ai-readme-mcp 0.4.6 → 0.4.8

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