Skip to main content
Glama

script_create

Create new C# scripts in Unity projects with customizable file names, content, and folder locations to streamline development workflows.

Instructions

Create a new C# script in Unity project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileNameYesName of the script file (without .cs extension)
contentNoScript content (optional, will use template if not provided)
folderNoTarget folder path (default: Assets/Scripts)

Implementation Reference

  • Handler function for the 'script_create' tool. Validates required 'fileName' parameter and delegates to UnityHttpAdapter.createScript, returning success message with path and GUID.
    case 'script_create': {
      if (!args.fileName) {
        throw new Error('fileName is required');
      }
      const result = await this.adapter.createScript(args.fileName, args.content, args.folder);
      return {
        content: [{
          type: 'text',
          text: `Script created successfully:\nPath: ${result.path}\nGUID: ${result.guid}`
        }]
      };
    }
  • Input schema defining parameters for script_create: required fileName, optional content and folder.
    inputSchema: {
      type: 'object',
      properties: {
        fileName: {
          type: 'string',
          description: 'Name of the script file (without .cs extension)'
        },
        content: {
          type: 'string',
          description: 'Script content (optional, will use template if not provided)'
        },
        folder: {
          type: 'string',
          description: 'Target folder path (default: Assets/Scripts)'
        }
      },
      required: ['fileName']
  • Tool registration in getTools() array, including name, description, and schema.
    {
      name: 'script_create',
      description: 'Create a new C# script in Unity project',
      inputSchema: {
        type: 'object',
        properties: {
          fileName: {
            type: 'string',
            description: 'Name of the script file (without .cs extension)'
          },
          content: {
            type: 'string',
            description: 'Script content (optional, will use template if not provided)'
          },
          folder: {
            type: 'string',
            description: 'Target folder path (default: Assets/Scripts)'
          }
        },
        required: ['fileName']
      }
    },
  • Helper method in adapter that sends HTTP request to Unity server endpoint 'script/create' with parameters.
    async createScript(fileName: string, content?: string, folder?: string): Promise<any> {
      return this.call('script/create', { fileName, content, folder });
    }

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/zabaglione/mcp-server-unity'

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