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 });
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. 'Apply a unified diff' implies a write/mutation operation, but it doesn't specify critical behaviors: whether changes are reversible, potential side effects (e.g., file overwriting), error handling for invalid diffs, or authentication requirements. For a mutation tool with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence that directly states the tool's function without unnecessary words. Every part ('Apply', 'unified diff', 'C# script') contributes essential meaning, making it highly efficient and easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (applying diffs to scripts is a non-trivial mutation), lack of annotations, and no output schema, the description is insufficient. It doesn't cover behavioral aspects like safety (e.g., backup creation), error conditions, or return values. For a tool that modifies files, more context is needed to ensure correct and safe usage by an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all parameters (path, diff, options with dryRun). The description adds no additional parameter semantics beyond what's in the schema—it doesn't explain diff format specifics, path constraints, or dryRun implications. With high schema coverage, the baseline is 3, as the description doesn't compensate but also doesn't detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Apply') and target ('a unified diff to a C# script'), making the purpose immediately understandable. It distinguishes from siblings like script_create or script_delete by focusing on modification via diff patching rather than creation or deletion. However, it doesn't explicitly contrast with script_read or other modification tools, keeping it at 4 rather than 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing script file), exclusions (e.g., not for non-C# files), or comparisons to siblings like script_create or script_delete. Without any usage context, the agent must infer when this tool is appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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