Skip to main content

unity_reflect

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: docs  ·  Module: services.tools.unity_reflect

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

Description​

Inspect Unity's live C# API via reflection. Use this to verify that classes, methods, and properties exist before writing C# code — training data may be wrong or outdated.

Actions:

  • get_type: Member summary (names only) for a class. Requires class_name.
  • get_member: Full signature detail for one member. Requires class_name + member_name.
  • search: Ranked public type search across loaded assemblies. Requires query. Optional scope, assembly, type_kind, page_size (default 25, maximum 100), cursor. Repeat the same inputs with next_cursor within five minutes; reload/catalog changes require restarting. complete=false reports assemblies that could not be enumerated. scope retains its assembly-name heuristics; assembly is an additional case-insensitive filter. Cursor continuation requires the original assembly spelling exactly, including case.

Parameters​

NameTypeRequiredDescription
actionstryesThe reflection action to perform.
class_namestr | None—Fully qualified or simple C# class name.
member_namestr | None—Method, property, or field name to inspect.
querystr | None—Search query for type name search.
scopestr | None—Assembly scope for search: unity, packages, project, all.
page_sizeint | None—Search page size 1..100; omitted uses 25. Repeat the same value for cursor continuation.
cursorstr | None—Opaque next_cursor from the same Editor/catalog and identical search inputs. Maximum 1024 ASCII characters; expires five minutes after the first page.
assemblystr | None—Search filter: exact simple or full assembly identity, case insensitive; intersects scope. Maximum 256 characters. With cursor, repeat the original spelling exactly, including case.
type_kindstr | None—Search filter: class, interface, struct, enum, or delegate. Delegates are excluded from the class filter.
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​

Check a class before writing code against it​

Does Rigidbody have linearVelocity in this Unity version?

{
"action": "get_type",
"class_name": "Rigidbody"
}

Returns type metadata (namespace, assembly, base class, interfaces) plus the names of the methods, properties, fields and events declared on the type itself, its extension methods and any obsolete members — no signatures. Inherited members are not listed (Rigidbody does not show transform); get_member does find inherited instance members. A cheap way to confirm an API exists in the editor that is actually open, instead of trusting what the model remembers.

Get the exact signature of one member​

Show every overload of Physics.Raycast.

{
"action": "get_member",
"class_name": "Physics",
"member_name": "Raycast"
}

Methods come back with overload_count and one entry per overload. The lookup includes inherited instance members and tries methods, properties, fields and events in that order; extension methods are tried last.

Resolve an ambiguous short name​

Which Button types are loaded?

{
"action": "get_type",
"class_name": "Button"
}

When several loaded types share the short name, the response has ambiguous: true and a matches list of full names. Call again with one of them, e.g. "class_name": "UnityEngine.UI.Button".

Find a type by partial name​

Find my project's inventory classes.

{
"action": "search",
"query": "Inventory",
"scope": "project"
}

scope defaults to unity (UnityEngine / UnityEditor / Unity.* assemblies). project covers only the Assembly-CSharp* assemblies, so types in your own .asmdef assemblies need packages (everything except System*, mscorlib and netstandard, so UnityEngine too) or all. Results are capped at 25 (truncated: true when more matched), so keep the query specific when the scope is wide.