# UnrealDocGenerator
Generates compact, agent-readable Markdown documentation from Unreal Engine C++ header files and exposes it to Claude via an MCP server for item-granularity lookups.
## How it works
1. **Parse** — `ue_parser.py` scans UE headers into dataclasses using a position-based scanner (handles nested braces, macros, delegates, namespaces).
2. **Render** — `ue_markdown.py` emits one `.md` per header: only items with C++ doc comments, no deprecated functions, compact enum format.
3. **Index** — `generate.py` produces `type-index.txt`: a flat `TypeName: path/to/File.md` lookup for instant type resolution.
4. **Serve** — `ue_mcp_server.py` exposes the docs to Claude as callable MCP tools.
## Usage
```bash
python generate.py [input2 ...]
# Examples
python generate.py /path/to/UnrealEngine/Engine/Source/ docs/
python generate.py Runtime/Engine/ Runtime/AIModule/ Runtime/GameplayTags/ docs/
python generate.py Runtime/Engine/Classes/GameFramework/Actor.h docs/
```
The last argument is always the output directory. All preceding arguments are inputs (files or directories, processed recursively). Output: one `.md` per `.h` + `docs/type-index.txt`.
## MCP Server
`ue_mcp_server.py` is a Claude Code MCP server that gives Claude item-granularity access to the generated docs — fetching one class overview or one function instead of an entire file.
### Setup
```bash
pip install mcp
```
```bash
export UE_DOCS_PATH=/path/to/your/generated/docs
export UE_ENGINE_ROOT=/path/to/UnrealEngine # optional, for search_source
```
The `.mcp.json` at the repo root registers the server automatically when you open the project in Claude Code.
### Available tools
| Tool | Purpose |
|---|---|
| `search_types(pattern)` | Regex search over `type-index.txt` — locate a type |
| `get_class_overview(class_name)` | Description + base classes + property/function name lists |
| `get_member(class_name, member_name)` | Full doc for one function or property (all overloads) |
| `get_file(relative_path)` | Full `.md` file — for delegates, enums, or multiple classes |
| `search_source(pattern, path_hint)` | Grep UE source `.h` files via `$UE_ENGINE_ROOT` |
### Typical query flow
```
search_types("AIController") → resolves to AIController.md
get_class_overview("AAIController") → description + list of 40 function names
get_member("AAIController", "MoveToActor") → full signature + doc
```
3 tool calls, ~15 lines of content — vs reading an entire 100-line file.
## Output format
- Functions: `` ##### `Name(params)` → `ReturnType` *(flags)* ``
- Properties: `` - `name` `type` *(flags)* — description ``
- Enums: table when values have descriptions, inline `Values: A, B, C` otherwise
- Inheritance: `*Inherits*: [BaseClass](relative/path.md)` with corpus links