Skip to main content
Glama

get_script_source

Retrieve the source code of a script object (LocalScript, Script, or ModuleScript) by specifying the instance path using the MCP server in Roblox Studio. Enables direct access to script data for development and debugging purposes.

Instructions

Get the source code of a script object (LocalScript, Script, or ModuleScript)

Input Schema

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

Input Schema (JSON Schema)

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

Implementation Reference

  • The core handler function for the 'get_script_source' tool. It validates the instancePath, fetches the script source via an API request to '/api/get-script-source', formats the response as JSON text content, and returns it in MCP format.
    async getScriptSource(instancePath: string) { if (!instancePath) { throw new Error('Instance path is required for get_script_source'); } const response = await this.client.request('/api/get-script-source', { instancePath }); return { content: [ { type: 'text', text: JSON.stringify(response, null, 2) } ] }; }
  • Defines the tool schema including name, description, and input schema requiring 'instancePath' string for the get_script_source tool in the listTools response.
    { name: 'get_script_source', description: 'Get the source code of a script object (LocalScript, Script, or ModuleScript)', inputSchema: { type: 'object', properties: { instancePath: { type: 'string', description: 'Path to the script instance (e.g., "game.ServerScriptService.MainScript")' } }, required: ['instancePath'] } },
  • src/index.ts:712-713 (registration)
    MCP tool registration in the CallToolRequest handler switch statement, dispatching to this.tools.getScriptSource.
    case 'get_script_source': return await this.tools.getScriptSource((args as any)?.instancePath as string);
  • HTTP endpoint registration for '/mcp/get_script_source' that forwards requests to tools.getScriptSource and handles errors.
    app.post('/mcp/get_script_source', async (req, res) => { try { const result = await tools.getScriptSource(req.body.instancePath); 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