AGENTS.md Generator

io.github.nushey由 GitHub 帳號 nushey 發布v0.6.1更新於 Oct 24, 2026

Analyzes codebases with tree-sitter and generates AGENTS.md files for AI coding agents.

已驗證STDIO僅桌面知識與記憶開發者工具

概覽

AI 產生的概覽

使用 tree-sitter 分析本機程式碼庫,為 AI 程式開發代理產生 AGENTS.md 脈絡檔案。

可以做什麼
提供三個工具:generate_agents_md 執行分析流程並回傳分塊的寫入指示以產生 AGENTS.md;scan_codebase 回傳純資料的架構脈絡,不產生檔案;read_payload_chunk 分塊串流讀取該酬載。它用 tree-sitter 解析 Git 追蹤的原始碼檔案,擷取公開符號、進入點、環境變數參照、安裝與測試指令以及慣例。增量掃描只重新解析 SHA-256 雜湊有變動的檔案。
適用情境
適合希望 AI 程式開發用戶端在不讀取每個檔案的情況下了解專案架構、慣例和指令的情境,也適合產生或更新 AGENTS.md 檔案。scan_codebase 工具還可用於需要程式碼庫脈絡的程式碼審查、規劃和問答工作。
執行需求
本機程序;需安裝 Python 3.11+ 和 Git。可透過 pip 安裝 agents-md-generator,或用 uvx 直接執行。需要支援 MCP 的用戶端,例如 Claude Code、Gemini CLI、Cursor、Windsurf 或 Codex CLI。未宣告驗證、API 金鑰或標頭。選用環境變數 AGENTS_MD_LOG_LEVEL 控制日誌詳細程度。
安裝前請注意
此伺服器會讀取你指定專案目錄中的原始碼檔案,包括 .env.example、.env.template 和 .env.sample 檔案,偵測到的環境變數名稱會出現在產生的酬載中。執行時產物寫入儲存庫之外的使用者快取目錄,AGENTS.md 由用戶端而非伺服器寫入。掃描在獨立程序中執行,逾時時間為五分鐘,且同一專案同時只能執行一個掃描。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 AGENTS.md Generator,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

agents-md-generator

MCP server that analyzes codebases with tree-sitter and generates AGENTS.md files.

[PyPI] [Python] [License: MIT] [MCP]

Python · C# · TypeScript · JavaScript · Go

Installation · Usage · Configuration · How It Works · Contributing


Compatible with any MCP-capable client: Claude Code, Gemini CLI, Cursor, Windsurf, Codex CLI, and others.

The server exposes three tools with a clear separation of concerns:

  • generate_agents_md — main entry point. Runs the analysis pipeline internally, embeds writing rules into the payload, and returns chunked read instructions to your client.
  • scan_codebase — standalone context tool for when you want deep codebase understanding without generating any file.
  • read_payload_chunk — streams the payload back in chunks regardless of which tool produced it.

No large data travels over the MCP wire.

Table of Contents


Installation

Requirements: Python 3.11+, Git, and any MCP-compatible client.

See INSTALLATION.md for the full guide including prerequisites and troubleshooting.

Option A — pip install + setup wizard (recommended)

bash
pip install agents-md-generatoragents-md-generator setup

The setup wizard detects your installed clients, asks whether to configure globally or per-project, and patches the config files automatically. Supports Claude Code, Gemini CLI, Cursor, Windsurf, and Codex CLI.

Option B — uvx (no install needed)

If you have uv installed, uvx runs the package without a prior install step. Add the entry manually to your client's MCP config:

json
{  "mcpServers": {    "agents-md": {      "command": "uvx",      "args": ["agents-md-generator"]    }  }}

For Claude Code specifically:

bash
claude mcp add agents-md -- uvx agents-md-generator

claude mcp add defaults to --scope local (current project only). Add -s user to register it for all projects.


Usage

Once registered, ask your AI client:

"Generate the AGENTS.md for this project"

The client will call generate_agents_md automatically. To scan a different directory:

"Generate the AGENTS.md for the project at /path/to/project"

Tools

ToolPurpose
generate_agents_mdMain entry point. Runs the pipeline internally, embeds writing rules into the payload, and returns chunked read instructions. Use this to create or update AGENTS.md.
scan_codebaseStandalone context tool. Analyzes the codebase and returns a pure data payload with no AGENTS.md mandate. Use this when you need architectural context for any other task.
read_payload_chunkStreams the payload written by either tool in chunks until has_more is false.

Tool Parameters

generate_agents_md
ParameterTypeDefaultDescription
project_pathstring"."Path to the project root
scan_codebase
ParameterTypeDefaultDescription
project_pathstring"."Path to the project root
force_full_scanbooleanfalseIgnore cache and rescan everything when explicitly set to true.
read_payload_chunk
ParameterTypeDefaultDescription
project_pathstring"."Must match the path used in the preceding tool call
chunk_indexinteger—Zero-based chunk index. Increment until has_more is false

What Gets Generated

The generated AGENTS.md follows the agents.md open standard. It is written as a README for AI agents, not as documentation for humans. Sections include:

SectionContents
Project OverviewTech stack and top-level architecture shape
Architecture & Data FlowDetected layers or domains with data flow direction
Conventions & PatternsNaming rules, export contracts, import rules, how to add new entities end-to-end
Environment VariablesVariables detected in source files and .env.example
Setup CommandsExact install and run commands from package.json, Makefile, etc.
Development WorkflowBuild, watch, and dev server commands
Testing InstructionsTest commands and framework info (if detected)
Code StyleLint/format commands (if config files detected)
Build and DeploymentCI 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 read_payload_chunk.

Scans run in a separate process with stage progress notifications and a five-minute timeout. Cancellation stops the scan worker. Only one scan per project can run at a time in a server instance; use .agents-config.json to narrow repositories that exceed the time limit.

Generation always assembles a current snapshot, reusing cached symbols for unchanged source files. An interrupted generation can be retried even after its payload was consumed or another scan ran. The client remains responsible for writing AGENTS.md.

Serialized payloads are capped at 300,000 characters. Dropped analysis sections are recorded in metadata.degradations and metadata.truncated_sections. Existing AGENTS.md content and writing instructions are preserved; if these alone exceed the budget, the tool returns an error instead of truncating the document.

generate_agents_md flow
  1. generate_agents_md runs the pipeline internally, writes the payload to disk (including AGENTS.md writing rules), and returns total_chunks with read instructions
  2. The client calls read_payload_chunk(project_path, chunk_index=0), then increments chunk_index until has_more is false
  3. The client concatenates all data fields — the payload contains the rules and analysis data needed to write AGENTS.md
  4. The payload file is automatically deleted after the last chunk is read
scan_codebase flow (pure context, no AGENTS.md mandate)
  1. scan_codebase runs the analysis and writes a pure data payload to disk
  2. Same chunked read via read_payload_chunk
  3. The client uses the payload for any purpose — code review, planning, Q&A

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/<project-hash>/cache.json  ← incremental scan cache

The <project-hash> is a SHA-256 of the project's absolute path — unique per project. Nothing is written to your repository.

Note: The server also writes a temporary payload.json to this directory during analysis, but it is managed entirely by the read_payload_chunk tool and deleted automatically after the last chunk is read. You never need to access it directly.


Project Configuration

Create .agents-config.json at your project root to customize behavior. This file is optional — all fields have defaults, and you can commit it to share settings with your team.

Full default configuration
json
{  "project_size": "medium",  "exclude": [    "**/node_modules/**",    "**/bin/**",    "**/obj/**",    "**/.git/**",    "**/dist/**",    "**/build/**",    "**/__pycache__/**",    "**/*.min.js",    "**/*.min.css",    "**/*.bundle.js",    "**/vendor/**",    "**/packages/**",    "**/.venv/**",    "**/venv/**",    "**/bower_components/**",    "**/app/lib/**",    "**/wwwroot/lib/**",    "**/wwwroot/libs/**",    "**/static/vendor/**",    "**/public/vendor/**",    "**/assets/vendor/**",    "**/site-packages/**"  ],  "include": [],  "languages": "auto",  "agents_md_path": "./AGENTS.md",  "max_file_size_bytes": 1048576}

Options

KeyDefaultDescription
project_size"medium"Project scale — tunes all internal caps and thresholds (see Project Size Profiles)
exclude(see above)Glob patterns to exclude from analysis
include[]If non-empty, only analyze files matching these patterns
languages"auto""auto" detects all supported languages, or pass a list like ["typescript", "python"]
agents_md_path"./AGENTS.md"Output path for the generated file
max_file_size_bytes1048576Files larger than this are skipped (default: 1 MB)

Environment Variables

VariableDefaultDescription
AGENTS_MD_LOG_LEVELINFOServer log verbosity. Set to DEBUG to see per-file analysis details. Valid values: DEBUG, INFO, WARNING, ERROR

Project Size Profiles

The project_size setting controls how aggressively the payload is compressed. A single knob tunes all internal caps — methods per class, symbols per file, directory aggregation, route caps, tree depth, and impact filtering.

ProfileLines (guidance)Impact filterDescription
"small"0–15kmediumGenerous caps — nearly everything is included. Best for small projects where full visibility matters.
"medium" (default)15k–50kmediumBalanced caps suitable for most projects.
"large"50k+highAggressive compression — only structural/breaking changes in diffs, more directory collapsing, tighter symbol caps.
Detailed profile values
ConstantSmallMediumLarge
Methods per class30128
Symbols per file402010
Dir aggregation threshold20105
Files per layer (before overflow)1585
Aggregation sample size543
Route controllers cap301510
Routes per controller1585
Go handlers cap1585
Directory tree depth432
Impact filtermediummediumhigh

What the Analysis Detects

Environment Variables

The server scans all source files for environment variable references using language-specific patterns:

LanguagePattern detected
JavaScript / TypeScriptprocess.env.VAR_NAME
Pythonos.environ['VAR'], os.getenv('VAR')
Goos.Getenv("VAR")
RubyENV['VAR']
Rustenv!("VAR"), var("VAR")

It also parses .env.example, .env.template, and .env.sample files at the project root.

Entry Points

Files named index, main, app, server, program, bootstrap, or startup (with any supported extension) are detected as entry points and annotated with their inferred role (e.g., "HTTP server bootstrap", "Electron main process").

Public API Surface

Tree-sitter parses each source file and extracts public symbols — classes, functions, methods, interfaces — filtering out private/protected members and underscore-prefixed symbols. For classes and structs, constructors (when they have parameters) and public properties are also included, revealing dependency injection patterns and data shapes. Interface methods are always included as they define the public contract. These are used to detect naming conventions, DI patterns, and export contracts across layers.

Architectural Distillation

For large codebases, the tool applies several heuristics to ensure the payload remains high-signal:

  • Boilerplate Suppression — common directories like Migrations, bin, obj, and Properties are automatically flagged and collapsed in the project structure, preventing them from bloating the directory listing.
  • Low-Entropy Summarization — files that primarily contain data structures (DTOs, Entities) with no logic methods are "minified". Instead of listing every property, the tool provides a high-level summary (e.g., "Contains 25 DTO classes").
  • Semantic Clustering — the aggregator groups these minified summaries at the directory level, allowing the consuming AI to understand entire data layers through a single line of signal.
  • Instruction Embedding — when called via generate_agents_md, writing rules are embedded directly in the payload so the AI agent reads the "Rules of Engagement" before processing the code architecture. Direct scan_codebase calls return pure data with no mandate.

Credits

AGENTS.md format based on the open agents.md standard.

Back to top

Licensed under the MIT License

來源:README.md,提交 156c70c

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.6.1最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分