docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ResourceTools

    Resource wrapper tools so clients that do not expose MCP resources primitives can still list and read files via normal tools. These call into the same safe path logic to ensure security.

    Inheritance
    object
    ResourceTools
    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 ResourceTools

    Fields

    FindInFileDescription

    Description text for the Unity.FindInFile MCP tool. Explains how to search files using regex patterns for methods, variables, or any text.

    Declaration
    public const string FindInFileDescription = "Searches a file with a regex pattern and returns line numbers and excerpts.\n            Ideal for: Finding methods, variables, classes, or any text patterns for renaming/editing.\n\nArgs:\n    Uri: The resource URI to search under Assets/\n    Pattern: Regex pattern to search for\n    IgnoreCase: Case-insensitive search (default: true)\n    MaxResults: Maximum results to return (default: 200)\n    ProjectRoot: Override project root path\n\nReturns:\n    Dictionary with 'success', 'data' (containing 'matches' and 'count'), and optional 'error'."
    Field Value
    Type Description
    string

    ListResourcesDescription

    Description text for the Unity.ListResources MCP tool. Explains how to list project files and URIs under a specified folder.

    Declaration
    public const string ListResourcesDescription = "Lists project URIs (unity://path/...) under a folder (default: Assets). Returns all files by default; always appends unity://spec/script-edits.\n\nArgs:\n    Pattern: Glob pattern for filtering files (default: *)\n    Under: Folder under project root to search (default: Assets)\n    Limit: Maximum number of results (default: 200)\n    ProjectRoot: Override project root path\n\nReturns:\n    Dictionary with 'success', 'data' (containing 'uris' array and 'count'), and optional 'error'."
    Field Value
    Type Description
    string

    ReadResourceDescription

    Description text for the Unity.ReadResource MCP tool. Explains how to read file contents with optional line-based or byte-based slicing.

    Declaration
    public const string ReadResourceDescription = "Reads a resource by unity://path/... URI with optional slicing.\n\nArgs:\n    Uri: The resource URI to read under Assets/\n    StartLine: Starting line number (1-based)\n    LineCount: Number of lines to read\n    HeadBytes: Number of bytes to read from start\n    TailLines: Number of lines from end\n    Request: Natural language request (e.g., 'last 120 lines', 'show 40 lines around MethodName')\n    ProjectRoot: Override project root path\n\nReturns:\n    Dictionary with 'success', 'data' (containing 'text' and 'metadata'), and optional 'error'."
    Field Value
    Type Description
    string

    Methods

    FindInFile(FindInFileParams)

    Searches for regex patterns within a Unity project file.

    Declaration
    [McpTool("Unity.FindInFile", "Searches a file with a regex pattern and returns line numbers and excerpts.\n            Ideal for: Finding methods, variables, classes, or any text patterns for renaming/editing.\n\nArgs:\n    Uri: The resource URI to search under Assets/\n    Pattern: Regex pattern to search for\n    IgnoreCase: Case-insensitive search (default: true)\n    MaxResults: Maximum results to return (default: 200)\n    ProjectRoot: Override project root path\n\nReturns:\n    Dictionary with 'success', 'data' (containing 'matches' and 'count'), and optional 'error'.", null, null, Groups = new string[] { "core", "resources" })]
    public static object FindInFile(FindInFileParams parameters)
    Parameters
    Type Name Description
    FindInFileParams parameters

    Parameters specifying the URI to search, regex pattern, case sensitivity, and maximum results.

    Returns
    Type Description
    object

    A response dictionary containing success status, list of matches with line/column positions, match count, file SHA-256, and any error messages.

    ListResources(ListResourcesParams)

    Lists Unity project resources (URIs) under a specified folder.

    Declaration
    [McpTool("Unity.ListResources", "Lists project URIs (unity://path/...) under a folder (default: Assets). Returns all files by default; always appends unity://spec/script-edits.\n\nArgs:\n    Pattern: Glob pattern for filtering files (default: *)\n    Under: Folder under project root to search (default: Assets)\n    Limit: Maximum number of results (default: 200)\n    ProjectRoot: Override project root path\n\nReturns:\n    Dictionary with 'success', 'data' (containing 'uris' array and 'count'), and optional 'error'.", null, null, Groups = new string[] { "core", "resources" })]
    public static object ListResources(ListResourcesParams parameters)
    Parameters
    Type Name Description
    ListResourcesParams parameters

    Parameters controlling which resources to list, including pattern filter, base folder, and result limit.

    Returns
    Type Description
    object

    A response dictionary containing success status, list of resource URIs, count, and any error messages.

    ReadResource(ReadResourceParams)

    Reads a Unity project resource by URI with optional content slicing.

    Declaration
    [McpTool("Unity.ReadResource", "Reads a resource by unity://path/... URI with optional slicing.\n\nArgs:\n    Uri: The resource URI to read under Assets/\n    StartLine: Starting line number (1-based)\n    LineCount: Number of lines to read\n    HeadBytes: Number of bytes to read from start\n    TailLines: Number of lines from end\n    Request: Natural language request (e.g., 'last 120 lines', 'show 40 lines around MethodName')\n    ProjectRoot: Override project root path\n\nReturns:\n    Dictionary with 'success', 'data' (containing 'text' and 'metadata'), and optional 'error'.", null, null, Groups = new string[] { "core", "resources" })]
    public static object ReadResource(ReadResourceParams parameters)
    Parameters
    Type Name Description
    ReadResourceParams parameters

    Parameters specifying the URI to read and optional slicing options (line ranges, head bytes, tail lines, or natural language requests).

    Returns
    Type Description
    object

    A response dictionary containing success status, file text content, metadata (SHA-256 and length), and any error messages.

    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)