Skip to content

Commit db2a05d

Browse files
committed
Improved readme information by providing prompts
improved the Unity editor window help tab with information with all the tools Fixed the resource templates to now work properly
1 parent 6e6bd61 commit db2a05d

30 files changed

+547
-316
lines changed

Editor/Resources/GetTestsResource.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +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}";
26+
Uri = "unity://tests/{testMode}";
2727

2828
_testRunnerService = testRunnerService;
2929
}
@@ -36,7 +36,6 @@ public override JObject Fetch(JObject parameters)
3636
{
3737
// Get filter parameters
3838
string testModeFilter = parameters["testMode"]?.ToObject<string>();
39-
string nameFilter = parameters["nameFilter"]?.ToObject<string>();
4039

4140
// Get all tests from the service
4241
var allTests = _testRunnerService.GetAllTests();
@@ -49,16 +48,6 @@ public override JObject Fetch(JObject parameters)
4948
).ToList();
5049
}
5150

52-
// Apply name filter if provided
53-
if (!string.IsNullOrEmpty(nameFilter))
54-
{
55-
allTests = allTests.Where(t =>
56-
t.Name.Contains(nameFilter, StringComparison.OrdinalIgnoreCase) ||
57-
t.FullName.Contains(nameFilter, StringComparison.OrdinalIgnoreCase) ||
58-
t.Path.Contains(nameFilter, StringComparison.OrdinalIgnoreCase)
59-
).ToList();
60-
}
61-
6251
// Create the results array
6352
var results = new JArray();
6453
foreach (var test in allTests)

Editor/Services/TestRunnerService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public async void ExecuteTests(
6767
if (!string.IsNullOrEmpty(testFilter))
6868
{
6969
filter.testNames = new[] { testFilter };
70-
filter.categoryNames = new[] { testFilter };
7170
}
7271

7372
// Execute tests

Editor/UnityBridge/McpUnityEditorWindow.cs

Lines changed: 146 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -159,28 +159,6 @@ private void DrawServerTab()
159159

160160
EditorGUILayout.EndVertical();
161161

162-
// IDE Integration settings
163-
string ideIntegrationTooltip = "Add the Library/PackedCache folder to VSCode-like IDE workspaces so code can be indexed for the AI to access it. This improves code intelligence for Unity packages in VSCode, Cursor, and similar IDEs.";
164-
EditorGUILayout.Space();
165-
EditorGUILayout.LabelField(new GUIContent("Improve VSCode-like IDEs code intelligence", ideIntegrationTooltip), EditorStyles.boldLabel);
166-
167-
// Add button to manually update workspace
168-
EditorGUILayout.BeginHorizontal();
169-
if (GUILayout.Button(new GUIContent("Update Workspace Cache Now", ideIntegrationTooltip), GUILayout.Height(24)))
170-
{
171-
bool updated = VsCodeWorkspaceUtils.AddPackageCacheToWorkspace();
172-
if (updated)
173-
{
174-
EditorUtility.DisplayDialog("Workspace Updated", "Successfully added Library/PackedCache to workspace files. Please restart your IDE and open the workspace.", "OK");
175-
}
176-
else
177-
{
178-
EditorUtility.DisplayDialog("Workspace Update Failed", "No workspace files were found or needed updating.", "OK");
179-
}
180-
}
181-
182-
EditorGUILayout.EndHorizontal();
183-
184162
// MCP Config generation section
185163
EditorGUILayout.Space();
186164
EditorGUILayout.LabelField("MCP Configuration", EditorStyles.boldLabel);
@@ -238,13 +216,159 @@ private void DrawHelpTab()
238216

239217
EditorGUILayout.EndVertical();
240218

219+
// IDE Integration settings
220+
EditorGUILayout.Space();
221+
WrappedLabel("IDE Integration Settings", _subHeaderStyle);
222+
223+
EditorGUILayout.BeginVertical(_boxStyle);
224+
string ideIntegrationTooltip = "Add the Library/PackedCache folder to VSCode-like IDE workspaces so code can be indexed for the AI to access it. This improves code intelligence for Unity packages in VSCode, Cursor, and similar IDEs.";
225+
226+
WrappedLabel("These settings help improve code intelligence in VSCode-like IDEs by adding the Unity Package Cache to your workspace. This is automatically configured when the MCP Unity tool is opened in Unity.");
227+
EditorGUILayout.Space();
228+
229+
// Add button to manually update workspace
230+
if (GUILayout.Button(new GUIContent("Update Workspace Cache Now", ideIntegrationTooltip), GUILayout.Height(24)))
231+
{
232+
bool updated = VsCodeWorkspaceUtils.AddPackageCacheToWorkspace();
233+
if (updated)
234+
{
235+
EditorUtility.DisplayDialog("Workspace Updated", "Successfully added Library/PackedCache to workspace files. Please restart your IDE and open the workspace.", "OK");
236+
}
237+
else
238+
{
239+
EditorUtility.DisplayDialog("Workspace Update Failed", "No workspace files were found or needed updating.", "OK");
240+
}
241+
}
242+
243+
EditorGUILayout.EndVertical();
244+
241245
EditorGUILayout.Space();
242246
WrappedLabel("Available Tools", _subHeaderStyle);
243247

244248
EditorGUILayout.BeginVertical(_boxStyle);
245249

250+
// execute_menu_item
246251
WrappedLabel("execute_menu_item", EditorStyles.boldLabel);
247252
WrappedLabel("Executes a function that is currently tagged with MenuItem attribute in the project or in the Unity Editor's menu path");
253+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
254+
EditorGUILayout.LabelField("Example prompt:", EditorStyles.miniLabel);
255+
WrappedLabel("Execute the menu item 'GameObject/Create Empty' to create a new empty GameObject", new GUIStyle(EditorStyles.miniLabel) { fontStyle = FontStyle.Italic });
256+
EditorGUILayout.EndVertical();
257+
EditorGUILayout.Space();
258+
259+
// select_gameobject
260+
WrappedLabel("select_gameobject", EditorStyles.boldLabel);
261+
WrappedLabel("Selects game objects in the Unity hierarchy by path or instance ID");
262+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
263+
EditorGUILayout.LabelField("Example prompt:", EditorStyles.miniLabel);
264+
WrappedLabel("Select the Main Camera object in my scene", new GUIStyle(EditorStyles.miniLabel) { fontStyle = FontStyle.Italic });
265+
EditorGUILayout.EndVertical();
266+
EditorGUILayout.Space();
267+
268+
// update_component
269+
WrappedLabel("update_component", EditorStyles.boldLabel);
270+
WrappedLabel("Updates component fields on a GameObject or adds it to the GameObject if it does not contain the component");
271+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
272+
EditorGUILayout.LabelField("Example prompt:", EditorStyles.miniLabel);
273+
WrappedLabel("Add a Rigidbody component to the Player object and set its mass to 5", new GUIStyle(EditorStyles.miniLabel) { fontStyle = FontStyle.Italic });
274+
EditorGUILayout.EndVertical();
275+
EditorGUILayout.Space();
276+
277+
// add_package
278+
WrappedLabel("add_package", EditorStyles.boldLabel);
279+
WrappedLabel("Installs new packages in the Unity Package Manager");
280+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
281+
EditorGUILayout.LabelField("Example prompt:", EditorStyles.miniLabel);
282+
WrappedLabel("Add the TextMeshPro package to my project", new GUIStyle(EditorStyles.miniLabel) { fontStyle = FontStyle.Italic });
283+
EditorGUILayout.EndVertical();
284+
EditorGUILayout.Space();
285+
286+
// run_tests
287+
WrappedLabel("run_tests", EditorStyles.boldLabel);
288+
WrappedLabel("Runs tests using the Unity Test Runner");
289+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
290+
EditorGUILayout.LabelField("Example prompt:", EditorStyles.miniLabel);
291+
WrappedLabel("Run all the EditMode tests in my project", new GUIStyle(EditorStyles.miniLabel) { fontStyle = FontStyle.Italic });
292+
EditorGUILayout.EndVertical();
293+
EditorGUILayout.Space();
294+
295+
// notify_message
296+
WrappedLabel("notify_message", EditorStyles.boldLabel);
297+
WrappedLabel("Displays messages in the Unity Editor console");
298+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
299+
EditorGUILayout.LabelField("Example prompt:", EditorStyles.miniLabel);
300+
WrappedLabel("Send a notification to Unity that the task has been completed", new GUIStyle(EditorStyles.miniLabel) { fontStyle = FontStyle.Italic });
301+
EditorGUILayout.EndVertical();
302+
303+
EditorGUILayout.EndVertical();
304+
305+
// Available Resources section
306+
EditorGUILayout.Space();
307+
WrappedLabel("Available Resources", _subHeaderStyle);
308+
309+
EditorGUILayout.BeginVertical(_boxStyle);
310+
311+
// get_menu_items
312+
WrappedLabel("get_menu_items", EditorStyles.boldLabel);
313+
WrappedLabel("Retrieves a list of all available menu items in the Unity Editor");
314+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
315+
EditorGUILayout.LabelField("Example prompt:", EditorStyles.miniLabel);
316+
WrappedLabel("Show me all available menu items related to GameObject creation", new GUIStyle(EditorStyles.miniLabel) { fontStyle = FontStyle.Italic });
317+
EditorGUILayout.EndVertical();
318+
EditorGUILayout.Space();
319+
320+
// get_hierarchy
321+
WrappedLabel("get_hierarchy", EditorStyles.boldLabel);
322+
WrappedLabel("Retrieves a list of all game objects in the Unity hierarchy");
323+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
324+
EditorGUILayout.LabelField("Example prompt:", EditorStyles.miniLabel);
325+
WrappedLabel("Show me the current scene hierarchy structure", new GUIStyle(EditorStyles.miniLabel) { fontStyle = FontStyle.Italic });
326+
EditorGUILayout.EndVertical();
327+
EditorGUILayout.Space();
328+
329+
// get_gameobject
330+
WrappedLabel("get_gameobject", EditorStyles.boldLabel);
331+
WrappedLabel("Retrieves detailed information about a specific GameObject, including all components with serialized properties and fields");
332+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
333+
EditorGUILayout.LabelField("Example prompt:", EditorStyles.miniLabel);
334+
WrappedLabel("Get me detailed information about the Player GameObject", new GUIStyle(EditorStyles.miniLabel) { fontStyle = FontStyle.Italic });
335+
EditorGUILayout.EndVertical();
336+
EditorGUILayout.Space();
337+
338+
// get_console_logs
339+
WrappedLabel("get_console_logs", EditorStyles.boldLabel);
340+
WrappedLabel("Retrieves a list of all logs from the Unity console");
341+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
342+
EditorGUILayout.LabelField("Example prompt:", EditorStyles.miniLabel);
343+
WrappedLabel("Show me the recent error messages from the Unity console", new GUIStyle(EditorStyles.miniLabel) { fontStyle = FontStyle.Italic });
344+
EditorGUILayout.EndVertical();
345+
EditorGUILayout.Space();
346+
347+
// get_packages
348+
WrappedLabel("get_packages", EditorStyles.boldLabel);
349+
WrappedLabel("Retrieves information about installed and available packages from the Unity Package Manager");
350+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
351+
EditorGUILayout.LabelField("Example prompt:", EditorStyles.miniLabel);
352+
WrappedLabel("List all the packages currently installed in my Unity project", new GUIStyle(EditorStyles.miniLabel) { fontStyle = FontStyle.Italic });
353+
EditorGUILayout.EndVertical();
354+
EditorGUILayout.Space();
355+
356+
// get_assets
357+
WrappedLabel("get_assets", EditorStyles.boldLabel);
358+
WrappedLabel("Retrieves information about assets in the Unity Asset Database");
359+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
360+
EditorGUILayout.LabelField("Example prompt:", EditorStyles.miniLabel);
361+
WrappedLabel("Find all texture assets in my project", new GUIStyle(EditorStyles.miniLabel) { fontStyle = FontStyle.Italic });
362+
EditorGUILayout.EndVertical();
363+
EditorGUILayout.Space();
364+
365+
// get_tests
366+
WrappedLabel("get_tests", EditorStyles.boldLabel);
367+
WrappedLabel("Retrieves information about tests in the Unity Test Runner");
368+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
369+
EditorGUILayout.LabelField("Example prompt:", EditorStyles.miniLabel);
370+
WrappedLabel("List all available tests in my Unity project", new GUIStyle(EditorStyles.miniLabel) { fontStyle = FontStyle.Italic });
371+
EditorGUILayout.EndVertical();
248372

249373
EditorGUILayout.EndVertical();
250374

Editor/UnityBridge/McpUnitySocketHandler.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ protected override void OnOpen()
116116
_server.Clients.Add(ID, clientName);
117117
}
118118

119-
//Debug.Log(Context);
120-
121119
Debug.Log($"[MCP Unity] WebSocket client '{clientName}' connected");
122120
}
123121

README.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,38 +53,60 @@ MCP Unity provides automatic integration with VSCode-like IDEs (Visual Studio Co
5353
- Enables better autocompletion and type information for Unity packages
5454
- Helps AI coding assistants understand your project's dependencies
5555

56-
You can manually update your workspace using the "Update Workspace Now" button in the Unity Editor MCP Server window (Tools > MCP Unity > Server Window) under the IDE Integration section.
57-
5856
### MCP Server Tools
5957

6058
This MCP currently provides the following <ins>tools</ins>:
6159

6260
- <ins>**execute_menu_item**</ins>: Executes Unity menu items (functions tagged with the MenuItem attribute)
61+
> **Example prompt:** "Execute the menu item 'GameObject/Create Empty' to create a new empty GameObject"
62+
6363
- <ins>**select_gameobject**</ins>: Selects game objects in the Unity hierarchy by path or instance ID
64+
> **Example prompt:** "Select the Main Camera object in my scene"
65+
6466
- <ins>**update_component**</ins>: Updates component fields on a GameObject or adds it to the GameObject if it does not contain the component
67+
> **Example prompt:** "Add a Rigidbody component to the Player object and set its mass to 5"
68+
6569
- <ins>**add_package**</ins>: Installs new packages in the Unity Package Manager
70+
> **Example prompt:** "Add the TextMeshPro package to my project"
71+
6672
- <ins>**run_tests**</ins>: Runs tests using the Unity Test Runner
73+
> **Example prompt:** "Run all the EditMode tests in my project"
74+
6775
- <ins>**notify_message**</ins>: Displays messages in the Unity Editor
76+
> **Example prompt:** "Send a notification to Unity that the task has been completed"
6877
6978
### MCP Server Resources
7079

7180
- <ins>**get_menu_items**</ins>: Retrieves a list of all available menu items in the Unity Editor to facilitate <ins>**execute_menu_item**</ins> tool
81+
> **Example prompt:** "Show me all available menu items related to GameObject creation"
82+
7283
- <ins>**get_hierarchy**</ins>: Retrieves a list of all game objects in the Unity hierarchy
84+
> **Example prompt:** "Show me the current scene hierarchy structure"
85+
7386
- <ins>**get_gameobject**</ins>: Retrieves detailed information about a specific GameObject by instance ID, including all GameObject components with it's serialized properties and fields
87+
> **Example prompt:** "Get me detailed information about the Player GameObject"
88+
7489
- <ins>**get_console_logs**</ins>: Retrieves a list of all logs from the Unity console
90+
> **Example prompt:** "Show me the recent error messages from the Unity console"
91+
7592
- <ins>**get_packages**</ins>: Retrieves information about installed and available packages from the Unity Package Manager
93+
> **Example prompt:** "List all the packages currently installed in my Unity project"
94+
7695
- <ins>**get_assets**</ins>: Retrieves information about assets in the Unity Asset Database
96+
> **Example prompt:** "Find all texture assets in my project"
97+
7798
- <ins>**get_tests**</ins>: Retrieves information about tests in the Unity Test Runner
99+
> **Example prompt:** "List all available tests in my Unity project"
100+
101+
<a href="https://glama.ai/mcp/servers/@CoderGamester/mcp-unity">
102+
<img width="400" height="200" src="https://glama.ai/mcp/servers/@CoderGamester/mcp-unity/badge" alt="Unity MCP server" />
103+
</a>
78104

79105
## Requirements
80106
- Unity 2022.3 or later - to [install the server](#install-server)
81107
- Node.js 18 or later - to [start the server](#start-server)
82108
- npm 9 or later - to [debug the server](#debug-server)
83109

84-
<a href="https://glama.ai/mcp/servers/@CoderGamester/mcp-unity">
85-
<img width="400" height="200" src="https://glama.ai/mcp/servers/@CoderGamester/mcp-unity/badge" alt="Unity MCP server" />
86-
</a>
87-
88110
## <a name="install-server"></a>Installation
89111

90112
Installing this MCP Unity Server is a multi-step process:

Server/build/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ async function startServer() {
6464
// Connect the server to the transport
6565
await server.connect(stdioTransport);
6666
serverLogger.info('MCP Server started');
67-
// Start Unity Bridge connection
68-
await mcpUnity.start();
67+
// Get the client name from the MCP server
68+
const clientName = server.server.getClientVersion()?.name || 'Unknown MCP Client';
69+
serverLogger.info(`Connected MCP client: ${clientName}`);
70+
// Start Unity Bridge connection with client name in headers
71+
await mcpUnity.start(clientName);
6972
}
7073
catch (error) {
7174
serverLogger.error('Failed to start server', error);

Server/build/resources/getConsoleLogResource.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { McpUnityError, ErrorType } from '../utils/errors.js';
22
export function createGetConsoleLogsResource(mcpUnity, logger) {
33
const resourceName = 'get_console_logs';
4-
const resourceUri = `unity://${resourceName}`;
4+
const resourceUri = `logs://console`;
55
const resourceMimeType = 'application/json';
66
return {
77
name: resourceName,
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
import { McpUnity } from '../unity/mcpUnity.js';
1+
import { z } from 'zod';
22
import { Logger } from '../utils/logger.js';
3+
import { McpUnity } from '../unity/mcpUnity.js';
34
import { ResourceDefinition } from './resourceRegistry.js';
5+
export declare const GameObjectParamsSchema: z.ZodEffects<z.ZodObject<{
6+
instanceId: z.ZodOptional<z.ZodNumber>;
7+
objectPath: z.ZodOptional<z.ZodString>;
8+
}, "strip", z.ZodTypeAny, {
9+
objectPath?: string | undefined;
10+
instanceId?: number | undefined;
11+
}, {
12+
objectPath?: string | undefined;
13+
instanceId?: number | undefined;
14+
}>, {
15+
objectPath?: string | undefined;
16+
instanceId?: number | undefined;
17+
}, {
18+
objectPath?: string | undefined;
19+
instanceId?: number | undefined;
20+
}>;
21+
export type GameObjectParams = z.infer<typeof GameObjectParamsSchema>;
422
export declare function createGetGameObjectResource(mcpUnity: McpUnity, logger: Logger): ResourceDefinition;

0 commit comments

Comments
 (0)