docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ManageScript

    Handles CRUD operations for C# scripts within the Unity project.

    ROSLYN INSTALLATION GUIDE: To enable advanced syntax validation with Roslyn compiler services:

    1. Install Microsoft.CodeAnalysis.CSharp NuGet package:

      • Open Package Manager in Unity
      • Follow the instruction on https://github.com/GlitchEnzo/NuGetForUnity
    2. Open NuGet Package Manager and Install Microsoft.CodeAnalysis.CSharp:

    3. Alternative: Manual DLL installation:

      • Download Microsoft.CodeAnalysis.CSharp.dll and dependencies
      • Place in Assets/Plugins/ folder
      • Ensure .NET compatibility settings are correct
    4. Define USE_ROSLYN symbol:

      • Go to Player Settings > Scripting Define Symbols
      • Add "USE_ROSLYN" to enable Roslyn-based validation
    5. 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.

    Inheritance
    object
    ManageScript
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)