AGENTS.md Generator
Analyzes codebases with tree-sitter and generates AGENTS.md files for AI coding agents.
★ 3MITfilesystems
Install
Config snippet generator goes here (5 client tabs)
README
<!-- mcp-name: io.github.nushey/agents-md-generator -->
# agents-md-generator
MCP server that analyzes codebases with [tree-sitter](https://tree-sitter.github.io/) and generates [`AGENTS.md`](https://agents.md/) files.
Compatible with any MCP-capable client: Claude Code, Gemini CLI, Cursor, Windsurf, and others.
**How it works:** The server does all the heavy lifting locally — AST parsing, incremental change detection, environment variable scanning, entry point detection. It writes a compact structured payload to disk and returns step-by-step instructions to your AI client. The client reads the payload and writes `AGENTS.md`. No large data travels over the MCP wire.
## Supported Languages
Python · C# · TypeScript · JavaScript · Go
---
## Installation
See [INSTALLATION.md](https://github.com/nushey/agents-md-generator/blob/main/INSTALLATION.md) for the full guide including prerequisites and troubleshooting.
**Requirements:** Python 3.11+, [uv](https://github.com/astral-sh/uv), Git, and any MCP-compatible client.
### Claude Code
```bash
claude mcp add agents-md uvx agents-md-generator
```
Or add it manually to `~/.claude.json` (Linux/macOS) or `%USERPROFILE%\.claude.json` (Windows):
```json
{
"mcpServers": {
"agents-md": {
"command": "uvx",
"args": ["agents-md-generator"]
}
}
}
```
### Gemini CLI
Add it to `~/.gemini/settings.json`:
```json
{
"mcpServers": {
"agents-md": {
"command": "uvx",
"args": ["agents-md-generator"]
}
}
}
```
### Other MCP clients (Cursor, Windsurf, etc.)
The server uses stdio transport. Add this entry to your client's MCP config under `mcpServers`:
```json
"agents-md": {
"command": "uvx",
"args": ["agents-md-generator"]
}
```
Restart your client — `uvx` downloads the package automatically on first run.
---
## Usage
Once registered, ask your AI client:
> "Generate the AGENTS.md for this project"
The client will call `generate_agents_md` automatically.
### Tool Parameters
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `project_path` | string | `"."` | Path to the project root |
| `force_full_scan` | boolean | `false` | Ignore cache and rescan everything from scratch |
> **Note on `force_full_scan`:** Use this only when explicitly requested. When asking Claude to _improve_ or _update_ an existing `AGENTS.md`, leave it as `false` — the incremental scan already provides all the data needed.
---
## What Gets Generated
The generated `AGENTS.md` follows the [agents.md](https://agents.md/) open standard. It is written as a **README for AI agents**, not as documentation for humans. Sections include:
- **Project Overview** — tech stack and top-level architecture shape
- **Architecture & Data Flow** — detected layers or domains with data flow direction
- **Conventions & Patterns** — naming rules, export contracts, import rules, and how to add new entities end-to-end
- **Environment Variables** — variables detected in source files and `.env.example`
- **Setup Commands** — exact install and run commands from `package.json`, `Makefile`, etc.
- **Development Workflow** — build, watch, and dev server commands
- **Testing Instructions** — test commands and framework info (if detected)
- **Code Style** — lint/format commands (if config files detected)
- **Build and Deployment** — CI pipeline info (if detected)
Sections with no detected data are omitted entirely.
---
## How Incremental Scanning Works
1. **First run (cold start):** All git-tracked source files are parsed with tree-sitter and cached
2. **Subsequent runs:** Only files whose SHA-256 hash changed since the last scan are re-parsed
3. **Semantic diff:** For modified files, only changed public symbols are included in the payload
4. **No source changes?** The tool stops and asks whether you want to improve the existing `AGENTS.md` content anyway
5. **Private symbols and test file internals** are excluded from both cache and payload — only the public API surface matters for `AGENTS.md`
### How Large Payloads Are Streamed
For large codebases the analysis payload can be too big to return inline over the MCP wire. The server handles this transparently through a second tool: `get_payload_chunk`.
**Flow:**
1. `generate_agents_md` runs the full analysis, writes the payload to disk, and returns a small response with `total_chunks` and instructions
2. The client calls `get_payload_chunk(project_path, chunk_index=0)`, then increments `chunk_index` until the response contains `has_more: false`
3. The client concatenates all `data` fields in order and parses the result as JSON
4. The payload file is automatically deleted after the last chunk is read
This flow is pure MCP — no filesystem access required from the client side. Any MCP-compatible client can follow it.
### Cache and Payload Location
All runtime artifacts are stored **outside your project**, in the user cache directory:
```
~/.cache/agents-md-generator/<projec