codemap
Auto-generates and refreshes a budget-bounded codebase map inside AGENTS.md for MCP-enabled coding agents, with tools to return, update, and check the map.
README
codemap
Auto-generated, budget-bounded codebase maps inside AGENTS.md — so coding agents stop re-exploring your repo at the start of every session.
Coding agents don't fail at finding code; they fail at knowing the shape
of a system in the first minutes of a session. Codemap keeps a small
(≤ 2,000-token) machine-generated map inside AGENTS.md
— the context file agents already read — and keeps it provably fresh.
- Compass, not encyclopedia — three layers under a hard token budget:
L0annotated directory layout ·L1key files ranked by import graph ·L2public signatures. - Freshness contract — deterministic output,
checkwith CI-friendly exit codes, a pre-commit hook so the map travels in the same commit as the change, and an MCP server that refreshes the map at session start. - Zero dependencies — single stdlib-only Python package (≥ 3.9), 40+ languages, local-only, no network, never fails on unknown file types.
- A format, not just a tool — the block layout and freshness rules are a spec (codemap-spec.md); any generator can implement it.
Install
pipx install codemap-agents # PyPI (or: uv tool install codemap-agents)
pipx install git+https://github.com/xenitV1/codemap # bleeding edge
# or, from a clone: python3 bin/codemap ... / pipx install .
The installed command is codemap in all cases.
Always-latest, npx-style (no install)
For MCP configs that should track the newest release automatically — the
Python equivalent of npx some-server@latest:
uvx --from codemap-agents@latest codemap mcp --no-cache # PyPI
uvx --refresh --from git+https://github.com/xenitV1/codemap codemap mcp --no-cache # git HEAD
Trade-off: the launcher checks for updates at every server start (a few
seconds cold). Pin a version or use pipx install if session startup
latency matters more than freshness.
Quickstart
cd your-project
codemap update # writes the map block into ./AGENTS.md (creates skeleton if missing)
codemap check # exit 0 fresh / 1 drift / 2 no map — wire this into CI
codemap install --ci # pre-commit hook + GitHub Actions freshness gate
Everything between <!-- codemap:begin --> and <!-- codemap:end --> is
machine-owned; everything outside is yours (architecture notes, conventions,
warnings — the parts only humans can write).
Exclude vendored or irrelevant directories with gitignore-like globs in a
repo-local .codemapignore (travels with the repo, CI sees it) or a
user-global ~/.codemapignore (every repo on your machine).
Automatic mode (MCP)
codemap mcp is a stdio MCP server. Registered once at user scope, it starts
automatically with every agent session, refreshes AGENTS.md for the project it
opens in (git repos only), and exposes on-demand tools: codemap (return a
fresh map without writing files), codemap_update, codemap_check.
# Claude Code
claude mcp add --scope user codemap -- codemap mcp --no-cache
# Codex CLI — ~/.codex/config.toml
[mcp_servers.codemap]
command = "codemap"
args = ["mcp", "--no-cache"]
# opencode — ~/.config/opencode/opencode.json
"mcp": { "codemap": { "enabled": true, "type": "local",
"command": ["codemap", "mcp", "--no-cache"] } }
Any other MCP client: stdio transport, command codemap mcp --no-cache.
Agent skill
codemap skill # installs SKILL.md into ~/.agents/skills/codemap and ~/.claude/skills/codemap
Skill-aware agents (Claude Code, Codex, …) then know when and how to use the tool without extra prompting.
All commands
| Command | What it does |
|---|---|
codemap update |
(Re)generate the map block in ./AGENTS.md |
codemap check |
Freshness: exit 0 fresh / 1 drift / 2 missing |
codemap print |
Write the block to stdout, touch nothing |
codemap install [--ci] |
Pre-commit hook (+ CI workflow) for this repo |
codemap watch |
Regenerate on every source change while you work |
codemap mcp |
MCP stdio server with session-start auto-refresh |
codemap skill |
Install the agent SKILL.md |
Options: --root PATH · --file AGENTS.md · --budget 2000 · --no-cache ·
--quiet · --interval N · --include-ext .foo,.bar
How it works
A full tree walk every run (adds/deletes reflected by construction), regex
import/symbol extraction per language, import-graph PageRank for L1 ranking,
and budget-driven degradation (drop L2 first, then L1, then collapse L0).
Output is deterministic — same tree, same bytes — which is what makes check
and reviewable map diffs possible. An incremental content-hash cache makes
warm runs fast and is semantically invisible.
Measured: ~130-file repo ≈ 0.2 s · ~900-file repo ≈ 0.4 s cold.
Tests
python3 -m unittest discover -s tests -v
License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。