← Back to blog
Apr 21, 2026GuideBy Funplay AI

How to Use execute_code to Build a Unity Scene from a Single Prompt

Funplay MCP for Unity exposes an execute_code tool that lets AI assistants run C# directly inside the Unity Editor. That means you can describe a scene in plain language and have your coding agent assemble it in one shot, with no copy-paste cycle.

What Funplay Unity MCP Is

Funplay MCP for Unity is an MIT-licensed MCP server that plugs into the Unity Editor and exposes 79 built-in tools to any connected AI assistant. Those tools cover scene creation, script generation, runtime verification, input simulation, performance analysis, and editor automation. The server runs locally at http://127.0.0.1:8765/ and works with Claude Code, Cursor, VS Code Copilot, Windsurf, and Codex.

Two tool profiles are available: core (19 tools) and full (79 tools). The core profile keeps things lightweight. The full profile opens up every capability, including execute_code.

Why This Matters

Without MCP integration, building a scene from an AI prompt means a tedious loop: ask the model for C#, copy the output into Unity, wait for compilation, fix errors, and repeat. With execute_code in the loop, the agent writes, executes, and validates code inside Unity without you touching the editor. One prompt can produce a complete scene hierarchy with GameObjects, materials, and attached scripts.

Prerequisites

  • Unity 2022.3 or later
  • A supported AI coding environment (Claude Code, Cursor, VS Code Copilot, Windsurf, or Codex)
  • Funplay Unity MCP installed and the server running

Installation

Open Unity, navigate to Window → Package Manager → Add from git URL, and paste:

https://github.com/FunplayAI/funplay-unity-mcp.git

After installation, open Funplay → MCP Server in the Unity menu bar. The server starts on http://127.0.0.1:8765/ by default. Confirm the server is running before connecting your AI client.

Walkthrough: One Prompt, One Scene

Below is a concrete example using Cursor as the AI client. The same approach works in Claude Code, VS Code Copilot, Windsurf, or Codex.

Step 1 — Configure Your AI Client

Point your MCP client configuration at the local server. A minimal configuration might look like this:

```json { "mcpServers": { "funplay-unity": { "url

Keep reading

Try it in your project. All four repos are on GitHub under github.com/FunplayAI — pick the engine you're using and follow the README.
How to Use execute_code to Build a Unity Scene from a Single Prompt | funplay mcp