Skip to main content
Glama
boshyxd

Roblox Studio MCP Server

set_script_source

Update script source code safely in Roblox Studio without using loadstring. Input the script instance path and the new source code to modify scripts directly in the Studio environment.

Instructions

Safely set the source code of a script object without using loadstring (Studio only)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instancePathYesPath to the script instance (e.g., "game.ServerScriptService.MainScript")
sourceYesNew source code for the script

Implementation Reference

  • The primary handler function for the 'set_script_source' MCP tool. Validates instancePath and source parameters, makes an API request to '/api/set-script-source', and returns a formatted text response with the result.
    async setScriptSource(instancePath: string, source: string) {
      if (!instancePath || typeof source !== 'string') {
        throw new Error('Instance path and source code string are required for set_script_source');
      }
      const response = await this.client.request('/api/set-script-source', { instancePath, source });
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(response, null, 2)
          }
        ]
      };
    }
  • Input schema definition for the 'set_script_source' tool, specifying required string properties: instancePath and source.
    inputSchema: {
      type: 'object',
      properties: {
        instancePath: {
          type: 'string',
          description: 'Path to the script instance (e.g., "game.ServerScriptService.MainScript")'
        },
        source: {
          type: 'string',
          description: 'New source code for the script'
        }
      },
      required: ['instancePath', 'source']
    }
  • src/index.ts:620-637 (registration)
    Registration of the 'set_script_source' tool in the MCP tools list, including name, description, and input schema for the ListTools endpoint.
    {
      name: 'set_script_source',
      description: 'Safely set the source code of a script object without using loadstring (Studio only)',
      inputSchema: {
        type: 'object',
        properties: {
          instancePath: {
            type: 'string',
            description: 'Path to the script instance (e.g., "game.ServerScriptService.MainScript")'
          },
          source: {
            type: 'string',
            description: 'New source code for the script'
          }
        },
        required: ['instancePath', 'source']
      }
    }
  • src/index.ts:714-715 (registration)
    Switch case registration that routes 'set_script_source' tool calls to this.tools.setScriptSource in the MCP CallTool handler.
    case 'set_script_source':
      return await this.tools.setScriptSource((args as any)?.instancePath as string, (args as any)?.source as string);
  • Secondary HTTP handler for POST /mcp/set_script_source endpoint, which invokes tools.setScriptSource and returns JSON response.
    app.post('/mcp/set_script_source', async (req, res) => {
      try {
        const result = await tools.setScriptSource(req.body.instancePath, req.body.source);
        res.json(result);
      } catch (error) {
        res.status(500).json({ error: error instanceof Error ? error.message : 'Unknown error' });
      }
    });
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds valuable context about safety ('safely') and platform restriction ('Studio only'), but does not cover other critical behaviors such as error handling, permission requirements, or whether the change is reversible. This leaves gaps for a mutation tool.

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 that front-loads the key action ('Safely set the source code') and includes essential constraints without unnecessary words. Every part earns its place by clarifying purpose and usage context concisely.

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

Completeness3/5

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

Given a mutation tool with no annotations and no output schema, the description is moderately complete. It covers purpose and key constraints but lacks details on behavioral aspects like error responses, side effects, or return values. For a tool that modifies script source, more context on safety implications or success indicators would be beneficial.

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 already fully documents both parameters ('instancePath' and 'source'). The description does not add any parameter-specific details beyond what the schema provides, such as syntax examples or constraints on source code format. Baseline 3 is appropriate when the schema handles all parameter documentation.

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

Purpose5/5

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

The description clearly states the specific action ('set the source code'), target resource ('of a script object'), and key constraints ('without using loadstring', 'Studio only'). It precisely distinguishes this from sibling tools like 'set_property' or 'get_script_source' by focusing on script source modification with safety and platform limitations.

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

Usage Guidelines4/5

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

The description provides clear context for usage ('Studio only') and a key constraint ('without using loadstring'), which implicitly guides when to use this tool. However, it does not explicitly state when to use alternatives like 'set_property' for other properties or 'get_script_source' for reading, nor does it mention prerequisites like script existence or permissions.

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

Related 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/boshyxd/robloxstudio-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server