Skip to main content
Glama

script_read

Read C# script files from Unity projects to access and review code content directly within the development environment.

Instructions

Read a C# script from Unity project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the script file

Implementation Reference

  • Handler for script_read tool: validates input path, calls adapter.readScript, formats and returns the script content.
    case 'script_read': {
      if (!args.path) {
        throw new Error('path is required');
      }
      const result = await this.adapter.readScript(args.path);
      return {
        content: [{
          type: 'text',
          text: `Script content from ${result.path}:\n\n${result.content}`
        }]
      };
    }
  • Input schema definition for the script_read tool, specifying the required 'path' parameter.
    {
      name: 'script_read',
      description: 'Read a C# script from Unity project',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: 'Path to the script file'
          }
        },
        required: ['path']
      }
    },
  • Registers the tool list handler which includes script_read via UnityMcpTools.getTools().
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: this.tools.getTools(),
    }));
  • Adapter helper method that sends HTTP POST request to Unity server's 'script/read' endpoint.
    async readScript(path: string): Promise<any> {
      return this.call('script/read', { path });
    }
  • Unity C# implementation (embedded): reads script file content from disk in worker thread for 'script/read' endpoint.
    static object ReadScriptOnWorkerThread(JObject request)
    {
        var path = request["path"]?.ToString();
        if (string.IsNullOrEmpty(path))
            throw new ArgumentException("path is required");
        
        var fullPath = Path.Combine(Application.dataPath, path.Substring(ASSETS_PREFIX_LENGTH));
        if (!File.Exists(fullPath))
            throw new FileNotFoundException($"File not found: {path}");
        
        return new
        {
            path = path,
            content = File.ReadAllText(fullPath, new UTF8Encoding(true)),
            guid = "" // GUID requires AssetDatabase, skip in worker thread
        };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states 'Read' but doesn't clarify if this requires specific permissions, what happens if the script doesn't exist (e.g., error handling), or any rate limits. For a read operation with zero annotation coverage, this is a significant gap in transparency.

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, efficient sentence with zero waste—'Read a C# script from Unity project'—front-loading the core action and resource. It's appropriately sized for a simple tool with one parameter.

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 simplicity (1 parameter, 100% schema coverage) but lack of annotations and output schema, the description is incomplete. It doesn't address behavioral aspects like error handling or return values, which are crucial for a read operation. The description alone is insufficient for full agent understanding.

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?

The schema description coverage is 100%, with the single parameter 'path' fully documented in the schema as 'Path to the script file'. The description adds no additional parameter details beyond what the schema provides, so it meets the baseline of 3 where the schema does the heavy lifting.

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 ('Read') and target resource ('a C# script from Unity project'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'script_create' or 'script_delete' beyond the verb, missing explicit distinction about its read-only nature versus other script operations.

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?

No guidance is provided on when to use this tool versus alternatives like 'script_create' or 'script_delete'. The description lacks context about prerequisites (e.g., script must exist), exclusions, or comparisons to siblings, leaving usage entirely implicit based on the verb 'Read'.

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