ctx-gen-mcp
Generates progressive-disclosure code context documentation (L0/L1/L2/L3) for large projects, helping AI coding agents understand codebases efficiently.
README
ctx-gen-mcp
Code context wiki generator -- MCP Server + OpenCode plugin for navigable, progressive-disclosure code docs with domain grouping, tags, and dependency graph.
What It Does
Generates a navigable Code Wiki for large projects, so AI coding agents can quickly locate and understand any module without reading the entire codebase.
Instead of dumping flat documentation, ctx-gen produces:
- INDEX.md -- single entry point with domain table, tag index, and module list
- Cross-linked wiki pages -- each module has its own
.wiki.mdwith YAML front-matter, summary, dependency links, and detailed content - Domain grouping -- modules auto-grouped by directory structure
- Tag-based lookup -- find modules by language, architecture level, tech feature
- Dependency graph -- shallow
#include/importanalysis with cross-links
Progressive Disclosure
The wiki is designed so AI agents read the minimum to locate what they need:
- INDEX.md (~50-100 lines) -- scan domains and tags
- lookup MCP tool -- find modules by keyword without reading the INDEX
- Module wiki page -- full context for one module with cross-links to related modules
- Follow links --
Depends:/Used by:links for impact analysis
One-Click Install
# 1. Install the pip package
pip install ctx-gen-mcp
# 2. Run one-click setup (installs skill + agent + MCP config)
ctx-gen-setup
That's it. OpenCode will now have:
- A
ctx-genskill (loadable via/ctx-gen) - A
ctx-genagent (switchable in agent panel) - MCP server config in
opencode.json AGENTS.mdin your project root
Usage
In OpenCode (recommended)
- Open your project in OpenCode
- Say:
"use the ctx-gen skill to generate context wiki" - Or switch to the
ctx-genagent in the agent panel - The agent will: scan -> generate per-module JSON -> validate -> assemble wiki
MCP Tools (any MCP-compatible agent)
The package exposes 4 deterministic MCP tools:
| Tool | What it does |
|---|---|
scan_skeleton |
Scan repo -> skeleton with domains, tags, dependency graph |
lookup |
Find modules by tag/domain/keyword (no need to read full INDEX) |
validate_coverage |
Check all modules have context, detect stale ones |
assemble_docs |
Build wiki INDEX.md + cross-linked .wiki.md pages |
CLI
# Run MCP server directly (for testing)
ctx-gen-server
# Or:
python -m ctx_gen_mcp.server
# Re-run setup (e.g. after moving project)
ctx-gen-setup --project-dir /path/to/project
# Install globally (all projects)
ctx-gen-setup --global
# Uninstall
ctx-gen-setup --uninstall
Output
After running, you'll have:
.ctx-cache/
skeleton.json # repo structure with domains/tags/deps (deterministic)
ctx/
<module_id>.json # per-module structured context
docs/
wiki/
INDEX.md # single entry point
domains/
<domain>/
<module>.wiki.md # cross-linked per-module wiki page
Add these to .gitignore:
.ctx-cache/
docs/wiki/
Architecture
Core Insight: Separate Deterministic from LLM Operations
| Operation | Who does it | Why |
|---|---|---|
| Repo scanning + domain grouping | scan_skeleton (deterministic) |
Glob + regex never hallucinates |
| Module lookup by tag/keyword | lookup (deterministic) |
String matching is exact |
| Per-module description | LLM (via Agent) | Needs semantic understanding |
| Coverage validation | validate_coverage (deterministic) |
Hash comparison is exact |
| Wiki assembly | assemble_docs (deterministic) |
Template + cross-link generation |
Domain Grouping (Hybrid Strategy)
- Directory-based first:
src/engine/-> domain "engine" - If a domain has >10 modules, flagged for potential LLM subdivision
- Domains are reflected in the output directory structure
Tag Inference (Automatic)
Tags are inferred from file names, directory names, and shallow content analysis:
| Dimension | Examples | Detection Method |
|---|---|---|
| Language | cpp, python, c |
File extension statistics |
| Architecture | kernel-mode, user-mode, shared-lib |
Filename + content keywords |
| Tech feature | driver, crypto, network, async, ipc |
Filename + content keywords |
| Build target | static-lib, shared-lib, exe |
Build system analysis |
Dependency Detection (Shallow)
Only direct #include, import, require statements are analyzed.
This covers ~80% of real dependencies with zero parser overhead.
Requirements
- Python >= 3.10
- OpenCode >= 1.0 (for skill/agent support)
- Or any MCP-compatible agent (Claude Code, etc.)
License
MIT
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。