Skip to main content
Glama

script_create

Generate a new C# script in Unity projects with customizable file names, content, and folder locations using the MCP Server for Unity interface.

Instructions

Create a new C# script in Unity project

Input Schema

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

Implementation Reference

  • Tool registration for 'script_create' including name, description, and input schema definition.
    { 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'] } },
  • Main handler logic in executeTool method that validates arguments and calls the adapter to create the script.
    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}` }] }; }
  • Adapter helper method that performs the HTTP call to Unity server endpoint 'script/create'.
    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