Skip to main content
Glama

script_apply_diff

Apply unified diffs to C# scripts in Unity projects to modify code files directly through patch application.

Instructions

Apply a unified diff to a C# script

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the script file
diffYesUnified diff content to apply
optionsNoOptional diff application settings

Implementation Reference

  • Handler for script_apply_diff tool: validates input, calls adapter.applyDiff, and returns formatted success response with stats.
    case 'script_apply_diff': {
      if (!args.path || !args.diff) {
        throw new Error('path and diff are required');
      }
      const result = await this.adapter.applyDiff(args.path, args.diff, args.options);
      return {
        content: [{
          type: 'text',
          text: `Diff applied successfully:\nPath: ${result.path}\nLines added: ${result.linesAdded}\nLines removed: ${result.linesRemoved}`
        }]
      };
    }
  • Tool registration including name, description, and input schema definition for script_apply_diff.
    {
      name: 'script_apply_diff',
      description: 'Apply a unified diff to a C# script',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: 'Path to the script file'
          },
          diff: {
            type: 'string',
            description: 'Unified diff content to apply'
          },
          options: {
            type: 'object',
            description: 'Optional diff application settings',
            properties: {
              dryRun: {
                type: 'boolean',
                description: 'Preview changes without applying (default: false)'
              }
            }
          }
        },
        required: ['path', 'diff']
      }
    },
  • Helper method in UnityHttpAdapter that proxies the diff application request to Unity HTTP server endpoint.
    async applyDiff(path: string, diff: string, options?: any): Promise<any> {
      return this.call('script/applyDiff', { path, diff, options });
    }

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