Unreal Engine コードアナライザー MCP サーバー
Unreal Engineのコードベースに強力なソースコード解析機能を提供するModel Context Protocol(MCP)サーバー。このツールにより、ClaudeやClineといったAIアシスタントはUnreal Engineのソースコードを深く理解し、解析できるようになります。
特徴
クラス分析: メソッド、プロパティ、継承を含む C++ クラスの詳細情報を取得します。
階層マッピング: クラスの継承階層を視覚化して理解する
コード検索: コンテキストに応じた結果でコードを検索します
参照の検索: クラス、関数、変数へのすべての参照を検索します
サブシステム分析: レンダリング、物理などの主要な Unreal Engine サブシステムを分析します。
ゲームジャンル知識: ゲームのジャンル、機能、実装パターンに関する知識ベースが組み込まれています
パターン検出と学習: 一般的な Unreal Engine パターンを識別し、学習リソースを提供します
カスタムコードベースサポート: 独自の Unreal Engine プロジェクトのコードベースを分析します
Related MCP server: RAPID MCP Server
クイックスタート
インストール
このリポジトリをクローンします:
git clone https://github.com/ayeletstudioindia/unreal-analyzer-mcp
cd unreal-analyzer-mcp
依存関係をインストールします:
プロジェクトをビルドします。
構成
Claudeデスクトップアプリ
Claude デスクトップ構成ファイル (Windows の場合は%APPDATA%\Claude\claude_desktop_config.json ) に次のコードを追加します。
{
"mcpServers": {
"unreal-analyzer": {
"command": "node",
"args": ["path/to/unreal-analyzer/build/index.js"],
"env": {}
}
}
}
クラインのために
Cline MCP 設定ファイル (Windows の場合は%APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json ) に以下を追加します。
{
"mcpServers": {
"unreal-analyzer": {
"command": "node",
"args": ["path/to/unreal-analyzer/build/index.js"],
"env": {}
}
}
}
技術的な詳細
アナライザーは以下を使用して構築されます:
主な依存関係:
使用法
分析ツールを使用する前に、まず Unreal Engine ソース パスまたはカスタム コードベース パスのいずれかを設定する必要があります。
分析の設定
Unreal Engineソースコード
{
"name": "set_unreal_path",
"arguments": {
"path": "/path/to/UnrealEngine/Source"
}
}
カスタムC++コードベースの場合
{
"name": "set_custom_codebase",
"arguments": {
"path": "/path/to/your/codebase"
}
}
カスタムコードベース機能を使用すると、あらゆるC++プロジェクトを分析できます。例えば:
カスタム ゲーム エンジンを分析する例:
// Initialize with custom codebase
{
"name": "set_custom_codebase",
"arguments": {
"path": "/path/to/game-engine"
}
}
// Analyze engine's renderer class
{
"name": "analyze_class",
"arguments": {
"className": "Renderer"
}
}
// Find all shader-related code
{
"name": "search_code",
"arguments": {
"query": "shader|glsl|hlsl",
"filePattern": "*.{h,cpp,hpp}"
}
}
// Get render system class hierarchy
{
"name": "find_class_hierarchy",
"arguments": {
"className": "RenderSystem",
"includeImplementedInterfaces": true
}
}
Qt アプリケーションを分析する例:
// Initialize with Qt project
{
"name": "set_custom_codebase",
"arguments": {
"path": "/path/to/qt-app"
}
}
// Find widget class definitions
{
"name": "search_code",
"arguments": {
"query": "class.*:.*public.*QWidget",
"filePattern": "*.h"
}
}
// Analyze main window class
{
"name": "analyze_class",
"arguments": {
"className": "MainWindow"
}
}
// Find signal/slot connections
{
"name": "find_references",
"arguments": {
"identifier": "connect",
"type": "function"
}
}
利用可能なツール
1. クラス分析
// Get detailed information about the AActor class
{
"name": "analyze_class",
"arguments": {
"className": "AActor"
}
}
出力例:
{
"name": "AActor",
"properties": [
{
"name": "RootComponent",
"type": "USceneComponent*",
"access": "protected"
}
// ... other properties
],
"methods": [
{
"name": "BeginPlay",
"returnType": "void",
"access": "protected",
"virtual": true
}
// ... other methods
]
}
2. クラス階層分析
// Get the inheritance hierarchy for ACharacter
{
"name": "find_class_hierarchy",
"arguments": {
"className": "ACharacter",
"includeImplementedInterfaces": true
}
}
出力例:
{
"class": "ACharacter",
"inheritsFrom": "APawn",
"interfaces": ["IMovementModeInterface"],
"hierarchy": [
"ACharacter",
"APawn",
"AActor",
"UObject"
]
}
3. 参考文献の発見
// Find all references to the BeginPlay function
{
"name": "find_references",
"arguments": {
"identifier": "BeginPlay",
"type": "function"
}
}
出力例:
{
"references": [
{
"file": "Actor.cpp",
"line": 245,
"context": "void AActor::BeginPlay() { ... }"
},
{
"file": "Character.cpp",
"line": 178,
"context": "Super::BeginPlay();"
}
]
}
4. コード検索
// Search for physics-related code
{
"name": "search_code",
"arguments": {
"query": "PhysicsHandle",
"filePattern": "*.h",
"includeComments": true
}
}
出力例:
{
"matches": [
{
"file": "PhysicsEngine/PhysicsHandleComponent.h",
"line": 15,
"context": "class UPhysicsHandleComponent : public UActorComponent",
"snippet": "// Component used for grabbing and moving physics objects"
}
]
}
5. パターン検出とベストプラクティス
アナライザーには、Unreal Engine のベスト プラクティスを理解して従うための 2 つの強力なツールが用意されています。
パターン検出
// Detect patterns in a file
{
"name": "detect_patterns",
"arguments": {
"filePath": "Source/MyGame/MyActor.h"
}
}
出力例:
{
"patterns": [
{
"pattern": "UPROPERTY Macro",
"description": "Property declaration for Unreal reflection system",
"location": "Source/MyGame/MyActor.h:15",
"context": "UPROPERTY(EditAnywhere, BlueprintReadWrite)\nfloat Health;",
"improvements": "Consider adding a Category specifier for better organization\nConsider adding Meta tags for validation",
"documentation": "https://docs.unrealengine.com/5.0/en-US/unreal-engine-uproperty-specifier-reference/",
"bestPractices": "Use appropriate specifiers (EditAnywhere, BlueprintReadWrite)\nConsider replication needs (Replicated, ReplicatedUsing)\nGroup related properties with categories",
"examples": "UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = \"Combat\")\nfloat Health;\nUPROPERTY(Replicated, Meta = (ClampMin = \"0.0\"))\nfloat Speed;"
}
]
}
ベストプラクティスガイド
// Get best practices for specific Unreal concepts
{
"name": "get_best_practices",
"arguments": {
"concept": "UPROPERTY" // or UFUNCTION, Components, Events, Replication, Blueprints
}
}
出力例:
{
"description": "Property declaration for Unreal reflection system",
"bestPractices": [
"Use appropriate specifiers (EditAnywhere, BlueprintReadWrite)",
"Consider replication needs (Replicated, ReplicatedUsing)",
"Group related properties with categories",
"Use Meta tags for validation and UI customization"
],
"examples": [
"UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = \"Combat\")\nfloat Health;",
"UPROPERTY(Replicated, Meta = (ClampMin = \"0.0\"))\nfloat Speed;"
],
"documentation": "https://docs.unrealengine.com/5.0/en-US/unreal-engine-uproperty-specifier-reference/"
}
ベスト プラクティス ガイドでは、Unreal Engine の主要な概念について説明します。
UPROPERTY: 不動産の反映と露出
UFUNCTION: 関数リフレクションとブループリントの統合
コンポーネント: コンポーネントの作成と管理
イベント: イベント処理と委任
レプリケーション: ネットワークレプリケーションのセットアップ
ブループリント: ブループリント/C++ のインタラクション パターン
6. APIドキュメントクエリ
// Search the API documentation
{
"name": "query_api",
"arguments": {
"query": "Actor",
"category": "Object",
"module": "Core",
"includeExamples": true,
"maxResults": 10
}
}
出力例:
{
"results": [
{
"class": "AActor",
"description": "Base class for all actors in the game",
"module": "Core",
"category": "Object",
"syntax": "class AActor : public UObject",
"examples": [
"// Create a new actor\nAActor* MyActor = GetWorld()->SpawnActor<AActor>();"
],
"remarks": [
"Actors are the base building blocks of the game",
"Can be placed in levels or spawned dynamically"
],
"documentation": "https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Core/AActor",
"relevance": 100
}
]
}
API ドキュメント クエリ ツールは以下を提供します。
クラスドキュメント全体の全文検索
カテゴリとモジュールによるフィルタリング
コード例と使用パターン
関連性に基づいた結果の並べ替え
公式ドキュメントへのリンク
7. サブシステム分析
// Analyze the Physics subsystem
{
"name": "analyze_subsystem",
"arguments": {
"subsystem": "Physics"
}
}
出力例:
{
"name": "Physics",
"coreClasses": [
"UPhysicsEngine",
"FPhysScene",
"UBodySetup"
],
"keyFeatures": [
"PhysX integration",
"Collision detection",
"Physical materials"
],
"commonUseCases": [
"Character movement",
"Vehicle simulation",
"Destructible environments"
]
}
APIドキュメント
アナライザーには、包括的な API ドキュメント機能が含まれるようになりました。
自動ドキュメント生成
スマート検索
すべてのドキュメントの全文検索
関連性に基づいた結果のランキング
カテゴリとモジュールのフィルタリング
コード例の組み込み
ドキュメントのカテゴリ
モジュール構成
コア: コアエンジン機能
RenderCore: レンダリングシステム
PhysicsCore: 物理エンジン
その他のエンジンモジュール
既存のツールとの統合
ベストプラクティス
分析ツールを使用する前に、必ず Unreal Engine パスまたはカスタム コードベース パスのいずれかを設定してください。
分析時には特定のクラス名を使用します(例:単に「Class」ではなく「MyClass」)
search_codeのファイルパターンパラメータを活用して結果を絞り込む
クラス階層を分析する際には実装されたインターフェースを含めて完全な理解を得る
サブシステム分析ツールを使用して、特定のクラスに進む前に概要を把握します (Unreal Engine のみ)
エラー処理
アナライザーは、次の場合に明確なエラー メッセージを表示します。
コードベース パスが設定されていません (Unreal Engine またはカスタム)
指定されたパスは存在しないかアクセスできません
コードベースにクラスまたはシンボルが見つかりません
無効なファイルパターンが指定されました
検索クエリまたはC++コードの構文エラー
ソースファイルへのアクセスは制限されています
C++ ファイルの Tree-sitter 解析が失敗する
パフォーマンスに関する考慮事項
大規模なコードベースでは分析に時間がかかる場合があります
複雑なクラス階層では処理に時間がかかる場合があります
幅広い検索パターンでは多くの一致が見つかる可能性がある
より早く結果を得るために、より具体的なクエリの使用を検討してください
テスト
このプロジェクトには、すべての主要コンポーネントに対する包括的なテストが含まれています。
テスト範囲
アナライザー テスト: UnrealCodeAnalyzer クラスのコア機能テスト
初期化とパス検証
クラス分析と解析
参考文献
コード検索
サブシステム分析
キャッシュ管理
ゲームジャンルテスト:ゲームジャンル知識ベースの検証
データ構造の検証
ジャンル固有の機能検証
コンポーネントの命名規則
データの完全性チェック
MCP サーバーテスト: MCP サーバー実装のテスト
サーバーの初期化
ツールの登録と取り扱い
リクエスト/レスポンスの検証
エラー処理
ツール固有の機能テスト
テストの実行
すべてのテストを実行します。
ウォッチモードでテストを実行します (開発中に便利です):
テストを書く
新しい機能を提供する際は、次の点に注意してください。
すべての新機能には対応するテストカバレッジがあります
テストはsrc/__tests__ディレクトリに整理されます
外部依存関係を適切にモックする
一貫性を保つために既存のテストパターンに従う
貢献
貢献を歓迎します!改善点があれば、お気軽にプルリクエストを送信してください。
ソースコード解析機能
新しい分析機能
パフォーマンスの最適化
ドキュメントの改善
テスト範囲
PR を送信する前に:
すべてのテストが合格することを確認する( npm test )
新しい機能のテストを追加する
必要に応じてドキュメントを更新する