Skip to content

Commit 3acfb23

Browse files
committed
npm package update to 11.2.0
Fixed Resources to now use resource templates
1 parent b73421e commit 3acfb23

File tree

771 files changed

+4778
-85983
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

771 files changed

+4778
-85983
lines changed

Editor/Resources/GetAssetsResource.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public class GetAssetsResource : McpResourceBase
1616
public GetAssetsResource()
1717
{
1818
Name = "get_assets";
19-
Description = "Gets a list of all assets from the Unity Asset Database";
19+
Description = "Retrieves assets from the Unity Asset Database";
20+
Uri = "unity://assets";
2021
}
2122

2223
/// <summary>

Editor/Resources/GetConsoleLogsResource.cs

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public GetConsoleLogsResource()
2828
{
2929
Name = "get_console_logs";
3030
Description = "Retrieves all logs from the Unity console";
31+
Uri = "logs://console";
3132

3233
// Register for log messages
3334
Application.logMessageReceived += OnLogMessageReceived;
@@ -43,36 +44,6 @@ public GetConsoleLogsResource()
4344
Debug.Log("[MCP Unity] Console logs resource initialized");
4445
}
4546

46-
/// <summary>
47-
/// Check if console was cleared using reflection (for Unity 2022.3)
48-
/// </summary>
49-
private void CheckConsoleClearViaReflection()
50-
{
51-
try
52-
{
53-
// Get current log counts using LogEntries (internal Unity API)
54-
var logEntriesType = Type.GetType("UnityEditor.LogEntries,UnityEditor");
55-
if (logEntriesType == null) return;
56-
57-
var getCountMethod = logEntriesType.GetMethod("GetCount",
58-
BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic);
59-
if (getCountMethod == null) return;
60-
61-
int currentTotalCount = (int)getCountMethod.Invoke(null, null);
62-
63-
// If we had logs before, but now we don't, console was likely cleared
64-
if (currentTotalCount == 0 && _logEntries.Count > 0)
65-
{
66-
ClearLogs();
67-
}
68-
}
69-
catch (Exception ex)
70-
{
71-
// Just log the error but don't break functionality
72-
Debug.LogError($"[MCP Unity] Error checking console clear: {ex.Message}");
73-
}
74-
}
75-
7647
/// <summary>
7748
/// Fetch all logs from the Unity console
7849
/// </summary>
@@ -105,6 +76,36 @@ public override JObject Fetch(JObject parameters)
10576
["logs"] = logsArray
10677
};
10778
}
79+
80+
/// <summary>
81+
/// Check if console was cleared using reflection (for Unity 2022.3)
82+
/// </summary>
83+
private void CheckConsoleClearViaReflection()
84+
{
85+
try
86+
{
87+
// Get current log counts using LogEntries (internal Unity API)
88+
var logEntriesType = Type.GetType("UnityEditor.LogEntries,UnityEditor");
89+
if (logEntriesType == null) return;
90+
91+
var getCountMethod = logEntriesType.GetMethod("GetCount",
92+
BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic);
93+
if (getCountMethod == null) return;
94+
95+
int currentTotalCount = (int)getCountMethod.Invoke(null, null);
96+
97+
// If we had logs before, but now we don't, console was likely cleared
98+
if (currentTotalCount == 0 && _logEntries.Count > 0)
99+
{
100+
ClearLogs();
101+
}
102+
}
103+
catch (Exception ex)
104+
{
105+
// Just log the error but don't break functionality
106+
Debug.LogError($"[MCP Unity] Error checking console clear: {ex.Message}");
107+
}
108+
}
108109

109110
/// <summary>
110111
/// Callback for when a log message is received

Editor/Resources/GetGameObjectResource.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public GetGameObjectResource()
1616
{
1717
Name = "get_gameobject";
1818
Description = "Retrieves detailed information about a specific GameObject by instance ID";
19+
Uri = "unity://gameobject/{id}";
1920
}
2021

2122
/// <summary>

Editor/Resources/GetHierarchyResource.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public GetHierarchyResource()
1515
{
1616
Name = "get_hierarchy";
1717
Description = "Retrieves all game objects in the Unity loaded scenes with their active state";
18+
Uri = "unity://hierarchy";
1819
}
1920

2021
/// <summary>

Editor/Resources/GetMenuItemsResource.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public class GetMenuItemsResource : McpResourceBase
1818
public GetMenuItemsResource()
1919
{
2020
Name = "get_menu_items";
21-
Description = "Retrieves a list of all available Unity menu items";
21+
Description = "List of available menu items in Unity to execute";
22+
Uri = "unity://menu-items";
2223
}
2324

2425
/// <summary>

Editor/Resources/GetPackagesResource.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public class GetPackagesResource : McpResourceBase
1919
public GetPackagesResource()
2020
{
2121
Name = "get_packages";
22-
Description = "Gets a list of all packages from the Unity Package Manager";
22+
Description = "Retrieve all packages from the Unity Package Manager";
23+
Uri = "unity://packages";
2324
}
2425

2526
/// <summary>

Editor/Resources/GetTestsResource.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public GetTestsResource(TestRunnerService testRunnerService)
2323
{
2424
Name = "get_tests";
2525
Description = "Gets available tests from Unity Test Runner";
26+
Uri = "tests://{testMode}/{nameFilter}";
2627

2728
_testRunnerService = testRunnerService;
2829
}

Editor/Resources/McpResourceBase.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ public abstract class McpResourceBase
2020
/// </summary>
2121
public string Description { get; protected set; }
2222

23+
/// <summary>
24+
/// The URI pattern of the resource
25+
/// </summary>
26+
public string Uri { get; protected set; }
27+
2328
/// <summary>
2429
/// Whether this resource is enabled and available for use
2530
/// </summary>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using Newtonsoft.Json.Linq;
4+
using UnityEditor.TestTools.TestRunner.Api;
5+
6+
namespace McpUnity.Services
7+
{
8+
/// <summary>
9+
/// Interface for the test runner service
10+
/// </summary>
11+
public interface ITestRunnerService
12+
{
13+
/// <summary>
14+
/// Get the TestRunnerApi instance
15+
/// </summary>
16+
TestRunnerApi TestRunnerApi { get; }
17+
18+
/// <summary>
19+
/// Get a list of all available tests
20+
/// </summary>
21+
List<TestItemInfo> GetAllTests();
22+
23+
/// <summary>
24+
/// Execute tests with the provided parameters
25+
/// </summary>
26+
/// <param name="testMode">Test mode to run</param>
27+
/// <param name="testFilter">Optional test filter</param>
28+
/// <param name="completionSource">TaskCompletionSource to resolve when tests are complete</param>
29+
/// <param name="timeoutMinutes">Timeout in minutes, defaults to 10</param>
30+
/// <returns>Task that resolves with test results when tests are complete</returns>
31+
void ExecuteTests(
32+
TestMode testMode,
33+
string testFilter,
34+
TaskCompletionSource<JObject> completionSource,
35+
int timeoutMinutes = 1);
36+
}
37+
}

Editor/Services/ITestRunnerService.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)