非真实源mcp
通过深度虚幻引擎源代码智能进行人工智能开发 模型上下文协议.
将所有UE C++和HLSL源代码索引到本地SQLite数据库中,并公开结构化查询——类层次结构、调用图、交叉引用和80k+文件和1M+符号的全文搜索——作为用于Claude code等AI编码助手的MCP工具。
为什么?
人工智能助手产生了引擎API的幻觉,猜测了实现模式,却看不到Epic是如何构建的。该服务器为他们提供了对真实引擎源的深度结构化访问,因此他们编写的代码与UE的实际工作方式相匹配,而不是他们想象的工作方式。
补足物 (不代替):
- 虚幻项目mcp --项目级源代码智能(您的C++代码)
- 虚幻编辑器mcp --构建诊断和编辑器日志工具(实时编码、错误解析、日志搜索)
- 虚幻蓝图mcp --蓝图图读取(节点、引脚、连接、执行流)
- 虚幻蓝图阅读器 --C++编辑器插件,将蓝图图序列化为JSON,用于AI工具
- 虚幻材料mcp --材料图智能、编辑和程序创建(46个工具:表达式、参数、实例、图构建、模板、C++插件)
- 虚幻配置mcp --配置/INI智能(解析继承链、搜索设置、与默认值的差异、解释CVars)
- 虚幻动画mcp --动画数据检查器和编辑器(序列、蒙太奇、混合空间、ABP、骨架、62个工具)
- 虚幻的尼亚加拉mcp --Niagara VFX智能和编辑(发射器、模块、HLSL生成、程序创建、70个工具)
这些服务器一起为AI代理提供了全方位的UE理解:引擎内部、API表面、您的项目代码、构建/运行时反馈、蓝图图数据、config/INI智能、材质图检查+编辑、动画数据检查+编辑,以及Niagara VFX检查+创建。
快速开始
从GitHub安装
uvx --from git+https://github.com/tumourlove/unreal-source-mcp.git unreal-source-mcp --indexClaude代码配置
添加到您的项目 .mcp.json:
{
"mcpServers": {
"unreal-source": {
"command": "uvx",
"args": ["--from", "git+https://github.com/tumourlove/unreal-source-mcp.git", "unreal-source-mcp"],
"env": {
"UE_SOURCE_PATH": "C:/Path/To/UE_5.x/Engine/Source",
"UE_SHADER_PATH": "C:/Path/To/UE_5.x/Engine/Shaders"
}
}
}
}或者在开发过程中从本地来源运行:
{
"mcpServers": {
"unreal-source": {
"command": "uv",
"args": ["run", "--directory", "/path/to/unreal-source-mcp", "python", "-m", "unreal_source_mcp"],
"env": {
"UE_SOURCE_PATH": "C:/Path/To/UE_5.x/Engine/Source",
"UE_SHADER_PATH": "C:/Path/To/UE_5.x/Engine/Shaders"
}
}
}
}服务器在第一次运行时自动索引(约10-15分钟)。所有后续查询都是即时的。
工具
| 工具 | 说明 |
|---|---|
read_source | 获取带有行号的符号的实现源代码。同时显示.h和.cpp。 |
find_references | 查找符号的所有使用站点(调用、包含、类型引用)。 |
find_callers | 查找调用给定函数的所有函数。 |
find_callees | 查找给定函数调用的所有函数。 |
search_source | 跨C++和/或着色器源进行全文搜索。支持FTS、正则表达式和子字符串模式。 |
get_class_hierarchy | 显示类(祖先、后代或两者)的继承树。 |
get_module_info | 模块统计:文件计数、按种类的符号计数、关键类。 |
get_symbol_context | 带有周围上下文和文档注释的符号定义。 |
read_file | 按路径从文件中读取源代码行。 |
命令行界面
# Index engine source (first time)
unreal-source-mcp --index
# Rebuild from scratch
unreal-source-mcp --reindex
# Run as MCP server (default, used by Claude Code)
unreal-source-mcp环境变量
| 变量 | 必填 | 描述 |
|---|---|---|
UE_SOURCE_PATH | 是 | 路径 Engine/Source 在UE安装中 |
UE_SHADER_PATH | 否 | 路径 Engine/Shaders (启用着色器索引) |
UE_VERSION | 否 | 覆盖版本检测(例如。 5.7) |
运作原理
- 发现 --步行
Engine/Source/适用于所有运行时、编辑器、开发人员和插件模块。可选索引Engine/Shaders/对于HLSL(usf/ush)。
- 解析 --用途 树保姆 使用C++语法构建AST。处理UE宏(UCLASS、UFUNCTION、UPROPERTY等),并使用正则表达式回退来处理错误解析的节点。
- 存储 --SQLite支持FTS5全文搜索。80k+个文件,1M+个符号索引。数据库按UE版本进行版本控制
~/.unreal-source-mcp/ue_{version}.db.
- 服务 --FastMCP服务器通过stdio公开了9个工具。Claude Code自动管理服务器生命周期。
什么被索引
- 所有引擎C++源代码(运行时、编辑器、开发人员、内置插件)
- HLSL着色器源(usf/ush文件)
- 类、结构、具有继承的枚举和UE宏元数据
- 函数(带限定名的声明和定义)
- 调用引用、类型引用、包含关系
- 文档字符串和符号上下文
添加到您的CLAUDE.md
## Unreal Engine Source Intelligence (unreal-source MCP)
Use `unreal-source` MCP tools to read actual engine source code, trace call graphs,
and explore class hierarchies. **Use this when you need to understand HOW something
works, not just its API signature.**
| Tool | When |
|------|------|
| `read_source` | Read the actual implementation of a class/function |
| `find_references` | Find all usage sites of a symbol |
| `find_callers` | What calls this function? |
| `find_callees` | What does this function call? |
| `search_source` | Full-text search across C++ and shader source |
| `get_class_hierarchy` | Inheritance tree (ancestors/descendants) |
| `get_module_info` | Module stats, file counts, key classes |
| `get_symbol_context` | Symbol definition with surrounding context |
**Rules:** Use `read_source` to understand engine internals before reimplementing
patterns. Use `find_callers` to see how Epic uses their own APIs.发展
# Clone and install
git clone https://github.com/tumourlove/unreal-source-mcp.git
cd unreal-source-mcp
uv sync
# Run tests
uv run pytest -v
# Run locally
UE_SOURCE_PATH="/path/to/Engine/Source" uv run python -m unreal_source_mcp需求
- Python 3.11+
- 紫外线 (推荐)或pip
- 本地虚幻引擎源代码安装
许可证
麻省理工学院
