You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Docstrings generation was requested by @shahzadgamedev.
* #6 (comment)
The following files were modified:
* `Editor/UI/MCPDebugWindow.cs`
* `mcpServer/build/filesystemTools.js`
* `mcpServer/build/toolDefinitions.js`
* `mcpServer/src/filesystemTools.ts`
* `mcpServer/src/toolDefinitions.ts`
Copy file name to clipboardExpand all lines: Editor/UI/MCPDebugWindow.cs
+27Lines changed: 27 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,16 @@ public static void ShowWindow()
50
50
wnd.minSize=newVector2(400,500);
51
51
}
52
52
53
+
/// <summary>
54
+
/// Initializes the debug window UI by loading visual assets, configuring UI elements, and binding event callbacks.
55
+
/// </summary>
56
+
/// <remarks>
57
+
/// This method clones the UXML layout into the window's root element and applies styling from the USS asset.
58
+
/// It queries essential UI components such as connection status labels, buttons, toggles, and text fields, and sets
59
+
/// a default server port value ("5010") if the port field is empty. Additionally, it binds events for connection,
60
+
/// disconnection, and auto-reconnect functionalities, sets up logging toggles, updates the UI to reflect the current state,
61
+
/// and registers an editor update callback. If either the UXML or USS asset is missing, an error is logged for debugging purposes.
62
+
/// </remarks>
53
63
publicvoidCreateGUI()
54
64
{
55
65
VisualElementroot=rootVisualElement;
@@ -106,6 +116,13 @@ public void CreateGUI()
106
116
EditorApplication.update+=OnEditorUpdate;
107
117
}
108
118
119
+
/// <summary>
120
+
/// Creates a fallback user interface for the MCP Debug Window when the UXML layout is unavailable.
121
+
/// </summary>
122
+
/// <remarks>
123
+
/// This method builds a basic UI on the provided root element that includes a notification label about the missing UXML, a text field for entering the server port (default value "5010"), buttons to initiate connection and disconnection, a toggle for auto-reconnect functionality, and a label to display connection status.
124
+
/// </remarks>
125
+
/// <param name="root">The container to which the fallback UI elements are added.</param>
109
126
privatevoidCreateFallbackUI(VisualElementroot)
110
127
{
111
128
// Create a simple fallback UI if UXML fails to load
* Recursively constructs a tree representation of the directory structure.
256
+
*
257
+
* This asynchronous function reads the contents of the directory at the specified
258
+
* path, validates it against the asset root, and recursively processes subdirectories
259
+
* up to the specified maximum depth. When the maximum depth is reached, it returns a
260
+
* stub entry to indicate that further subdirectories exist.
261
+
*
262
+
* @param {string} currentPath - The starting directory path to build the tree from, typically relative to the asset root.
263
+
* @param {string} assetRootPath - The root directory used to validate and resolve the current path.
264
+
* @param {number} [maxDepth=5] - The maximum depth the function will traverse.
265
+
* @param {number} [currentDepth=0] - The current depth level during recursion (used internally).
266
+
* @returns {Promise<Array<Object>>} A promise that resolves to an array representing the directory tree. Each object includes a "name" and a "type" (either "file" or "directory"), and directory objects may include a "children" property with nested entries.
path: z.string().optional().default("Scripts").describe('Path to look for scripts in. Can be absolute or relative to Unity project Assets folder. If empty, defaults to the Assets/Scripts folder.'),
49
49
});
50
+
/**
51
+
* Registers available Unity Editor and filesystem tools with the MCP server and configures tool request handling.
52
+
*
53
+
* This function determines the project root from the UNITY_PROJECT_PATH environment variable (or defaults
54
+
* to the current working directory) and registers a set of tools—each defined with its name, description,
55
+
* category, tags, and input schema—for both Unity Editor operations and filesystem interactions.
56
+
* It also sets up a request handler that routes tool invocation requests based on the tool name,
57
+
* handling special cases such as connection verification, filesystem operations (via a dedicated handler),
58
+
* and Unity-specific commands. If the Unity Editor is not connected when required, it throws an McpError.
59
+
*
60
+
* @remark Tools like "verify_connection" are processed even if the Unity Editor is not connected, while other
61
+
* Unity-specific tools require an active connection and perform additional error handling.
62
+
*/
50
63
exportfunctionregisterTools(server,wsHandler){
51
64
// Determine project root path from environment variable or default to parent of Assets folder
0 commit comments