script-execute

script-execute is a skill for Claude Code, Codex from IvanMurzak/Unity-MCP. It costs 48 tokens per session (1,988 once invoked), scanned A, original, Apache-2.0.

A tool for compiling and running C# code inside the Unity Editor, either as a complete class or as method statements. It can also resolve Unity objects such as GameObjects and components passed as parameters.

In plain words
What is it for?
Use it to run C# logic, inspect or modify Unity objects, and execute editor-side experiments.
Why use it?
It lets you test or perform Unity code without manually creating a script file for every small operation. It also handles references to objects already in the Unity project.

Skill for Claude CodeCodex

About the project

Unity-MCP connects AI coding agents to the Unity game engine through MCP, letting them work with the Unity Editor and running games. It is used by game developers to generate code, automate development and testing, debug projects, and add AI-driven behavior to games. The catalogue entries provide skills, instructions, an MCP integration, and settings for operating this workflow.

IvanMurzak/Unity-MCP · 4,148 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/ivanmurzak/unity-mcp/script-execute
Any agent
npx skills add IvanMurzak/Unity-MCP --skill script-execute
Clone the repo
git clone --depth 1 https://github.com/IvanMurzak/Unity-MCP

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for script-execute

README.md
[![agentmods](https://agentmods.dev/badge/skills/ivanmurzak/unity-mcp/script-execute.svg)](https://agentmods.dev/skills/ivanmurzak/unity-mcp/script-execute)
Your own site
<a href="https://agentmods.dev/skills/ivanmurzak/unity-mcp/script-execute"><img src="https://agentmods.dev/badge/skills/ivanmurzak/unity-mcp/script-execute.svg" alt="Measured on agentmods" height="20"></a>
Per session 48 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,988 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00048 $0.01988
Opus 5 $0.00024 $0.00994
Sonnet 5 $0.00010 $0.00398
Haiku 4.5 $0.00005 $0.00199

Measured yesterday against content hash 00b38c73fb05, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

script-execute scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Unity-MCP-Plugin/.claude/skills/script-execute/SKILL.md · 197 lines

How it starts

The opening of the file, as written. The whole thing — 197 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Script / Execute

Modes

  • Full code mode (default, isMethodBody=false): the csharpCode argument must define a complete class with a static method (no top-level statements).
  • Body-only mode (isMethodBody=true): provide only the method body statements. The tool auto-generates the usings, class, and method header.

Passing Unity objects as parameters

Unity objects (GameObject, Component, etc.) can be passed as parameters using their Ref types (GameObjectRef, ComponentRef, etc.) or directly by type:

  • UnityEngine.GameObject — resolves an actual GameObject from value {"instanceID": N}, {"name": "..."}, or {"path": "..."}.
  • UnityEngine.Component (or any component subtype) — resolves from {"instanceID": N}.
  • AIGD.GameObjectRef — passes a GameObjectRef POCO directly; the method body calls goRef.FindGameObject() to resolve it.
  • AIGD.ComponentRef — passes a ComponentRef POCO.
  • AIGD.ObjectRef — passes a base ObjectRef POCO.

How to Call

unity-mcp-cli run-tool script-execute --input '{
  "csharpCode": "string_value",
  "className": "string_value",
  "methodName": "string_value",
  "parameters": "string_value",
  "isMethodBody": false
}'

For complex input (multi-line strings, code), save the JSON to a file and use:

unity-mcp-cli run-tool script-execute --input-file args.json

Or pipe via stdin (recommended):

unity-mcp-cli run-tool script-execute --input-file - <<'EOF'
{"param": "value"}
EOF

Troubleshooting

If unity-mcp-cli is not found, either install it globally (npm install -g unity-mcp-cli) or use npx unity-mcp-cli instead. Read the /unity-initial-setup skill for detailed installation instructions.

Input

Name Type Required Description
csharpCode string Yes C# code to compile and execute. In full code mode (default, isMethodBody=false): must define a complete class with a static method. Example: 'using UnityEngine; public class Script { public static void Main() { Debug.Log("Hello"); } }'. Do NOT use top-level statements. In body-only mode (isMethodBody=true): provide only the method body statements. The tool auto-generates usings, class, and method header. Example body: 'go.SetActive(false);'. Custom helper classes can still be defined inline in the body-only string after the main logic, but for complex additional class definitions use full code mode instead.
className string No The name of the class containing the method to execute. In body-only mode this becomes the generated class name.
methodName string No The name of the method to execute. Must be a static method. In body-only mode this becomes the generated method name.
parameters any No Serialized parameters to pass to the method. Each entry must specify 'name' and 'typeName'. Supported parameter types include primitives, strings, and Unity object references: - 'UnityEngine.GameObject': resolves an actual GameObject from value '{"instanceID": N}', '{"name": "..."}', or '{"path": "..."}'. - 'UnityEngine.Component' (or any component subtype): resolves from '{"instanceID": N}'. - 'AIGD.GameObjectRef': passes a GameObjectRef POCO directly; the method body calls goRef.FindGameObject() to resolve it. - 'AIGD.ComponentRef': passes a ComponentRef POCO. - 'AIGD.ObjectRef': passes a base ObjectRef POCO. If the method does not require parameters, leave this empty.
isMethodBody boolean No When true, 'csharpCode' is treated as just the method body. The tool auto-generates standard using directives (System, UnityEngine, AIGD, com.IvanMurzak.Unity.MCP.Runtime.Extensions, UnityEditor), the class definition, and the method signature (void return type). Parameters from the 'parameters' list are automatically added to the method signature using their typeName and name. When false (default), 'csharpCode' must be a complete C# compilation unit with class and method definitions.

Read the full file on GitHub · 197 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 197 lines · 48 tokens per session scan A 00b38c73fb05

Subscribe to this mod's changes

script-execute is a skill published in the GitHub repository IvanMurzak/Unity-MCP (4,148 stars, last pushed today), licensed Apache-2.0. It adds 48 tokens to every session and 1,988 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

gdextension

Use when building native extensions for Godot — godot-cpp (C++) or gdext (Rust), binding classes, building, and GDScript/C# interop.

jame581/GodotPrompter · 38 tokens

godot-mentor

Use when the user wants to learn Godot while building — teaching mode that explains the concept, the editor setup, and what to verify, instead of just delivering code. Triggers on "teach me", "explain as we go", "I'm learning Godot", "guide me", "walk me through", "help me understand".

jame581/GodotPrompter · 73 tokens

creating-python-scripts

Use when creating or editing a Python script, utility, CLI helper, one-off automation, or small standalone Python program that should stay as a script instead of becoming a multi-file project.

Signal-Loop/UnityCodeMCPServer · 42 tokens

fantasy-net

This guide applies to development and code review for Fantasy / Fantasy.Net / Fantasy.Unity written in C#. Use it when a task involves Fantasy server code or Unity client code using Fantasy, ECS entities/components/systems, scenes and subscenes, FTask, network handlers/messages/protocols, Address or Roaming routing…

qq362946/Fantasy · 157 tokens

sbox

Use when writing or modifying code for s&box, sbox, the Facepunch sandbox engine, or any Source 2 game project in C#. Triggers on mentions of s&box, sbox, sandbox game, Facepunch engine, Source 2 game, .sbproj, .razor with PanelComponent, @inherits PanelComponent, Sandbox.Component, GameObject + Components.Get …

gavogavogavo/claude-sbox · 197 tokens

unity-csharp

写 Unity C# 时使用。生命周期、协程、GC、性能、序列化的实战规范。.

Wade-DevCode/awesome-coding-skills-cn · 28 tokens