虚幻api mcp
](https://pypi.org/project/unreal-api-mcp/) ](https://pypi.org/project/unreal-api-mcp/)  ](https://github.com/Codeturion/unreal-api-mcp) ](https://github.com/Codeturion/unreal-api-mcp)  
MCP服务器,为AI代理提供准确的虚幻引擎C++API文档。节省令牌、上下文和时间——防止出现幻觉签名,错误 #include 路径和不推荐使用的API。
适用于Claude Code、Cursor、Windsurf或任何兼容MCP的AI工具。无需安装虚幻引擎。检查 支持的版本。每周都会自动检测和构建新版本。
快速开始
添加到MCP配置(.mcp.json, mcp.json,或工具的MCP设置),设置 UNREAL_VERSION 要匹配您的项目:
{
"mcpServers": {
"unreal-api": {
"command": "uvx",
"args": ["unreal-api-mcp"],
"env": {
"UNREAL_VERSION": "5.5"
}
}
}
}设置此选项以匹配项目的UE版本。看 支持的版本 对于所有可用的数据库。
首次运行时,服务器会将正确的数据库下载到 ~/.unreal-api-mcp/补丁版本(例如。 "5.7.3")回退到major.minor数据库(例如。 "5.7")如果特定补丁不可用。
运作原理
- 版本检测。 服务器计算出要服务哪个UE版本:
| 优先级 | 来源 | 示例 |
|---|---|---|
| 1 | UNREAL_VERSION 有人是。 "5.5", "5.7", "5.7.3" | |
| 2 | UNREAL_PROJECT_PATH | 阅读 .uproject EngineAssociation 字段(例如。 5.5.1 或 5.7) |
设置其中一个以匹配您的项目。如果没有,服务器默认为UE 5.7。
- 数据库下载。 如果该版本的数据库未在本地缓存,则从GitHub下载(一次)。对于补丁版本,如果需要,可以回退到major.minor数据库。启动时还会检查更新。
- 发球。 所有工具调用都查询特定版本的SQLite数据库。精确查找在\
#include "GameFramework/Character.h"|
| get_class_reference |全类参考卡|“APlayerController”、“UK2Node_SpawnActorFromClass”、“UEdGraphSchema_K2”| | get_deprecation_warnings |检查API是否已过时|“K2_AttachRootComponentTo”->改为使用AttachToComponent()|
覆盖
所有引擎运行时、编辑器、开发人员模块,以及内置插件(增强输入、游戏能力、通用UI、Niagara、Chaos等数百个)。
包括蓝图图内部: 158 UK2节点子类, UEdGraphSchema_K2, BlueprintGraph, KismetCompiler,以及 GraphEditor 模块(1120+个条目)。如果你正在编写自定义K2节点或编辑器工具,它会被索引。
请在上查看支持的版本和数据库的完整列表 db-v1发布页面。每周一通过CI自动检测和构建新版本。
记录细分(UE 5.7):
| 类型 | 计数 | 来源 |
|---|---|---|
| 课程(UCLASS) | 10075 | AActor, ACharacter, UGameplayStatics, ... |
| 结构(USTRUCT) | 9014 | FHitResult, FVector, FTransform, ... |
| 枚举(UENUM) | 3475 | EMovementMode, ECollisionChannel, ... |
| 函数(UFUNCTION) | 23414 | 带参数、返回类型、说明符的签名 |
| 属性(UPROPERTY) | 66340 | 类型、说明符、文档注释 |
| 委托 | 2406 | 动态多播,委托声明 |
是否 不 涵盖第三方插件或市场资产。对于这些,请依赖项目来源。
基准测试
在10步字符移动开发工作流程中,MCP始终使用比使用grep和文件读取的代理少得多的令牌:
这种差距存在于每种问题类型中。MCP在简单的包括查找和复杂的类引用方面获胜:
即使在一个现实的混合工作流程中,MCP结果后会进行目标文件读取,它仍然比没有MCP的熟练代理使用更少的令牌:
“没有MCP”的估计假设是完全或部分文件读取。具有良好工具的熟练代理可能会使用比所示更少的令牌。MCP保证每次通话都能得到正确、结构化的答案。
按问题细分
Query latency
在UE 5.7数据库(114724条记录)上测量,每次查询50次迭代:
| 查询 | 中位数 | p95 |
|---|---|---|
精确的FQN查找(get_function_signature) | \ |
Accuracy
| 测试 | 结果 |
|---|---|
| 搜索前1个相关性(8个常见查询) | 100% |
| 包括路径解析(6个关键类) | 100% |
| 函数签名准确率(3个常见函数) | 100% |
| 类引用完整性(2个类) | 100% |
| 弃用检测(1个弃用的API) | 100% |
排名使用BM25,调整列权重(成员名10x,类名5x)加上核心模块提升,以确保 AActor::GetActorLocation 排名高于利基插件API。
CLAUDE.md片段
将此添加到您的项目 CLAUDE.md (或等效的说明文件)。 这一步很重要。 没有它,人工智能有工具,但不知道什么时候可以使用它们。
## Unreal Engine API Lookup (unreal-api MCP)
Use the `unreal-api` MCP tools to verify UE C++ API usage instead of guessing. **Do not hallucinate signatures or #include paths.**
| When | Tool | Example |
|------|------|---------|
| Unsure about a function's parameters or return type | `get_function_signature` | `get_function_signature("AActor::GetActorLocation")` |
| Need the `#include` for a type | `get_include_path` | `get_include_path("ACharacter")` |
| Want to see all members on a class | `get_class_reference` | `get_class_reference("UCharacterMovementComponent")` |
| Searching for an API by keyword | `search_unreal_api` | `search_unreal_api("spawn actor")` |
| Checking if an API is deprecated | `get_deprecation_warnings` | `get_deprecation_warnings("K2_AttachRootComponentTo")` |
| Writing custom K2 nodes or editor tools | `get_class_reference` | `get_class_reference("UK2Node_SpawnActorFromClass")`, `get_class_reference("UEdGraphSchema_K2")` |
**Rules:**
- Before writing a UE API call you haven't used in this conversation, verify the signature with `get_function_signature`
- Before adding a `#include`, verify with `get_include_path` if unsure
- Covers: all Engine Runtime/Editor modules, built-in plugins (Enhanced Input, GAS, CommonUI, Niagara, etc.), Blueprint graph internals (UK2Node subclasses, EdGraphSchema, BlueprintGraph, KismetCompiler)
- Does NOT cover: third-party plugins or marketplace assets安装详细信息
Auto-detect version from .uproject
而不是设置 UNREAL_VERSION,您可以指向您的虚幻项目。服务器读取 EngineAssociation 从你的字段 .uproject 文件:
{
"mcpServers": {
"unreal-api": {
"command": "uvx",
"args": ["unreal-api-mcp"],
"env": {
"UNREAL_PROJECT_PATH": "F:/Unreal Projects/MyProject"
}
}
}
}Alternative installation methods
使用pip安装:
pip install unreal-api-mcp{
"mcpServers": {
"unreal-api": {
"command": "unreal-api-mcp",
"args": [],
"env": {
"UNREAL_VERSION": "5.5"
}
}
}
}Environment variables
| 变量 | 目的 | 示例 |
|---|---|---|
UNREAL_VERSION | 要服务的UE版本 | 5.5, 5.7, 5.7.3 |
UNREAL_PROJECT_PATH | 自动检测upproject中的版本 | F:/Unreal Projects/MyProject |
UNREAL_INSTALL_PATH | 覆盖UE安装路径(用于 ingest 仅) | H:/UE_5.6 |
Building databases locally
如果你想从自己的虚幻引擎安装构建数据库,而不是下载:
# Build for a specific version
python -m unreal_api_mcp.ingest --unreal-version 5.6 --unreal-install "H:/UE_5.6"
python -m unreal_api_mcp.ingest --unreal-version 5.5 --unreal-install "H:/UE_5.5"数据库被写入 ~/.unreal-api-mcp/unreal_docs_{version}.db 默认情况下。
Project structure
unreal-api-mcp/
├── src/unreal_api_mcp/
│ ├── server.py # MCP server (5 tools)
│ ├── db.py # SQLite + FTS5 database layer
│ ├── version.py # Version detection + DB download
│ ├── header_parser.py # Parse Unreal C++ headers (UCLASS, UFUNCTION, etc.)
│ ├── unreal_paths.py # Locate UE installs + discover modules
│ └── ingest.py # CLI ingestion pipeline
└── pyproject.toml数据库存储在 ~/.unreal-api-mcp/ (首次运行时下载)。
故障排除
| 问题 | 修复 |
|---|---|
| “无法下载UE X数据库” | 检查互联网连接。或者在本地构建: python -m unreal_api_mcp.ingest --unreal-version 5.6 --unreal-install H:/UE_5.6 |
| 正在提供错误的API版本 | 设置 UNREAL_VERSION 明确地。检查标准错误: unreal-api-mcp: serving UE |
| 服务器无法启动 | 检查 python --version (需要3.10+)。检查路径: which unreal-api-mcp 或 where unreal-api-mcp |
| 第三方插件未返回任何结果 | Marketplace/第三方的插件未被索引。仅涵盖内置引擎和插件API。 |
______________________________________________________________________
另见
统一api mcp --Unity(C#)也有同样的概念。涵盖Unity 2022、2023和Unity 6。
联系
需要为您的引擎或框架定制MCP服务器吗?我构建了MCP工具,可以减少代币浪费,防止人工智能辅助游戏开发的幻觉。如果你想为你的团队的堆栈提供类似的东西,请联系我们。
fuatcankoseoglu@gmail.com
许可证
可以出于任何个人或非商业目的自由使用、分叉、修改和共享。 商业用途需要许可。
