Skip to main content

find_in_file

Auto-generated from the Python tool registry. Do not hand-edit outside <!-- examples:start --><!-- examples:end --> blocks — the generator (tools/generate_docs_reference.py) will overwrite them.

Group: core  ·  Module: services.tools.find_in_file

Maturity: stable (support status; independent of enabled state, readiness and permissions).

Description​

Searches a C# script with a regex pattern and returns line numbers, excerpts and identities of the searched snapshot. bytes_sha256 identifies raw file bytes when supplied by the Editor; sha256 identifies decoded UTF-8 content. Continue with next_cursor and the same search options; source or option changes reject the cursor. Pages follow regex engine order, including reverse and zero-width searches. Existing source, total-match and execution limits apply to every page.

Parameters​

NameTypeRequiredDescription
uristryesThe C# script URI or path under Assets/ (.cs or extensionless)
patternstryesThe regex pattern to search for
project_rootstr | None—Reserved. Omit or pass null and select the Unity instance to search.
max_resultsint—Cap results to avoid huge payloads
ignore_casebool | str | None—Case insensitive search
cursorstr | None—Opaque next_cursor from the preceding page
unity_instancestr | int | None—Target Unity instance for this call: Name@hash or hash prefix; an integer selects only that exact port over stdio and is rejected over HTTP. Read mcpforunity://instances for available targets. Omit to use the legacy active selection or the sole available instance.

Returns​

A dict containing the Unity response. The exact shape depends on the action.

Examples​

Find the registration call in Assets/BerthProbe.cs from the Harbor fixture. For another project, replace the URI and regex. Reuse a returned next_cursor with the same query to continue searching the same snapshot.

MCP arguments
{
"uri": "Assets/BerthProbe.cs",
"pattern": "PlayScenarioStateRegistry\\.Register",
"max_results": 10
}