Skip to main content
Glama

script_apply_diff

Apply unified diffs to C# scripts in Unity projects, supporting previews via dry-run mode. Integrates with the MCP Server for efficient script updates and version control.

Instructions

Apply a unified diff to a C# script

Input Schema

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

Implementation Reference

  • Handler for the 'script_apply_diff' MCP tool. Validates input arguments and delegates to UnityHttpAdapter.applyDiff, then formats the response.
    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 in getTools() array, defining name, description, and input schema 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'] } },
  • Supporting method in UnityHttpAdapter that makes an HTTP call to the Unity server endpoint '/script/applyDiff' to perform the diff application.
    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