Class ManageScript
Handles CRUD operations for C# scripts within the Unity project.
ROSLYN INSTALLATION GUIDE: To enable advanced syntax validation with Roslyn compiler services:
Install Microsoft.CodeAnalysis.CSharp NuGet package:
- Open Package Manager in Unity
- Follow the instruction on https://github.com/GlitchEnzo/NuGetForUnity
Open NuGet Package Manager and Install Microsoft.CodeAnalysis.CSharp:
Alternative: Manual DLL installation:
- Download Microsoft.CodeAnalysis.CSharp.dll and dependencies
- Place in Assets/Plugins/ folder
- Ensure .NET compatibility settings are correct
Define USE_ROSLYN symbol:
- Go to Player Settings > Scripting Define Symbols
- Add "USE_ROSLYN" to enable Roslyn-based validation
Restart Unity after installation
Note: Without Roslyn, the system falls back to basic structural validation. Roslyn provides full C# compiler diagnostics with line numbers and detailed error messages.
Inherited Members
Namespace: Unity.AI.MCP.Editor.Tools
Assembly: Unity.AI.MCP.Editor.dll
Syntax
public static class ManageScript
Fields
Description
Description of the Unity.ManageScript tool for MCP clients. Provides compatibility routing for legacy script operations with guidance to use newer tools.
Declaration
public const string Description = "Compatibility router for legacy script operations.\n\nIMPORTANT:\n- Direct file reads should use resources/read.\n- Edits should use Unity.ApplyTextEdits (ranges) or Unity.ScriptApplyEdits (structured).\n\nArgs:\n action: Operation ('create', 'read', 'delete').\n name: Script name (no .cs extension).\n path: Asset path (default: \"Assets/\").\n contents: C# code for 'create'/'update'.\n script_type: Type hint (e.g., 'MonoBehaviour').\n namespace: Script namespace.\n\nReturns:\n Dictionary with results ('success', 'message', 'data')."
Field Value
| Type | Description |
|---|---|
| string |
Methods
GetInputSchema()
JSON schema for script management tool parameters.
Declaration
[McpSchema("Unity.ManageScript")]
public static object GetInputSchema()
Returns
| Type | Description |
|---|---|
| object | The JSON schema object describing the tool's input structure. |
HandleCommand(JObject)
Main handler for script management actions (compatibility router).
Declaration
[McpTool("Unity.ManageScript", "Compatibility router for legacy script operations.\n\nIMPORTANT:\n- Direct file reads should use resources/read.\n- Edits should use Unity.ApplyTextEdits (ranges) or Unity.ScriptApplyEdits (structured).\n\nArgs:\n action: Operation ('create', 'read', 'delete').\n name: Script name (no .cs extension).\n path: Asset path (default: \"Assets/\").\n contents: C# code for 'create'/'update'.\n script_type: Type hint (e.g., 'MonoBehaviour').\n namespace: Script namespace.\n\nReturns:\n Dictionary with results ('success', 'message', 'data').", null, null, Groups = new string[] { "core", "scripting" })]
public static object HandleCommand(JObject @params)
Parameters
| Type | Name | Description |
|---|---|---|
| JObject | params | The JObject containing action and parameters for script operations. |
Returns
| Type | Description |
|---|---|
| object | A response object containing success status, message, and optional data. |