Skip to main content
Glama
alexneargarder

unity-inspector-mcp

execute_script

Compile and run a C# script file in the Unity runtime. Supports full class definitions, MonoBehaviours, Harmony patches, and private member access. Scripts can define Main() for execution and Unload() for cleanup.

Instructions

Compile and run a C# script file in the Unity runtime. Supports full class definitions, MonoBehaviours, Harmony patches, and private member access. Scripts can define Main() for execution and Unload() for cleanup. Use ScriptContext for Harmony instances, logging, and arguments.

Available library scripts:

  • Dump Harmony Patches: List all Harmony patches on a specified method, showing patch owner, type, and priority [args: typeName, methodName]

  • Find Objects By Type: Find all active instances of a type in the scene with key state info [args: typeName, maxResults]

  • Inspect Private Fields: Dump all field values (including private) of a component on a named GameObject [args: gameObjectName, componentType]

  • Menu Tweaker: Live-edit FlexMenu element properties without rebuilding. Target by name, type, or wildcard pattern. [args: elementName]

  • Rogueforce Runner: Test harness for the Rogueforce mod. Start a run, skip levels, log state, auto-run a full campaign, or trigger game over. [args: action]

  • Trace Method Calls: Harmony-patch a method to log every call with arguments for a specified number of frames [args: typeName, methodName, maxCalls]

  • Watch Field: Monitor a field on a component and log whenever its value changes. Runs until unloaded. [args: gameObjectName, componentType, fieldName]

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argsNoOptional key-value arguments passed to the script via ScriptContext.Args
pathYesScript name (from scripts/csharp/) or absolute file path to a .cs file

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv1.0.0

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden. It discloses the execution model via Main()/Unload(), mentions ScriptContext for Harmony, logging, and arguments, and notes that some scripts run until unloaded. It does not explicitly state the side-effect/risk profile of arbitrary C# execution, error behavior, or cleanup guarantees beyond optional Unload().

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The core definition is front-loaded, and the library scripts are organized in a clear bulleted list where each entry carries selection-relevant information. Somewhat long, but the length is justified by the number of built-in script variants and their differing arguments.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers invocation path and args, supported code constructs, lifecycle hooks, and the available library scripts with their parameters. The main gaps are the lack of return/output behavior and error handling, which is more significant given there is no output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already covers both parameters at 100%, so the baseline is 3. The description adds value by enumerating library script argument patterns (typeName, maxResults, action, etc.) and tying args to ScriptContext.Args, going beyond the generic schema description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opening sentence names the specific action (compile and run), resource (C# script file), and environment (Unity runtime). It distinguishes itself from siblings like compile_script and list_scripts by covering execution, and further clarifies scope with supported constructs and library scripts.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description establishes clear usage context: use this tool when a C# script needs to be compiled and run in Unity, including advanced scenarios like MonoBehaviours, Harmony patches, and private member access. It does not explicitly name alternatives or exclusions, but the built-in library script examples give concrete invocation use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/alexneargarder/unity-inspector-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server