Skip to main content
Glama

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

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

Input Schema (JSON Schema)

{ "properties": { "instancePath": { "description": "Path to the script instance (e.g., \"game.ServerScriptService.MainScript\")", "type": "string" }, "source": { "description": "New source code for the script", "type": "string" } }, "required": [ "instancePath", "source" ], "type": "object" }

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' }); } });

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