Skip to main content
Glama
bbernstein

LacyLights MCP Server

by bbernstein

analyze_script

Analyze theatrical scripts to extract lighting cues and generate scene suggestions, enhancing lighting design for LacyLights MCP Server.

Instructions

Analyze a theatrical script to extract lighting-relevant information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
extractLightingCuesNoExtract specific lighting cues from the script
scriptTextYesThe theatrical script text to analyze
suggestScenesNoGenerate scene suggestions based on analysis

Implementation Reference

  • Main execution logic for the 'analyze_script' tool: parses input using Zod schema, calls RAG service for script analysis, extracts lighting cues if requested, generates scene suggestions if requested, and returns structured analysis.
    async analyzeScript(args: z.infer<typeof AnalyzeScriptSchema>) {
      const { scriptText, extractLightingCues, suggestScenes } = AnalyzeScriptSchema.parse(args);
    
      try {
        // Analyze script using RAG service
        const scriptAnalysis = await this.ragService.analyzeScript(scriptText);
    
        const result: GenerateSceneResult = {
          analysis: scriptAnalysis,
          totalCues: scriptAnalysis.scenes.length,
          characters: scriptAnalysis.characters,
          overallMood: scriptAnalysis.overallMood,
          themes: scriptAnalysis.themes
        };
    
        if (extractLightingCues) {
          // Extract specific lighting cues from the analysis
          const lightingCues = scriptAnalysis.scenes.flatMap((scene, _index) => 
            scene.lightingCues.map(cue => ({
              sceneNumber: scene.sceneNumber,
              cue,
              context: scene.content.substring(0, 200) + '...',
              suggestedTiming: this.suggestCueTiming(cue, scene.mood)
            }))
          );
    
          result.lightingCues = lightingCues;
          result.totalCues = lightingCues.length;
        }
    
        if (suggestScenes) {
          // Generate scene suggestions based on script analysis
          const sceneTemplates = await Promise.all(
            scriptAnalysis.scenes.slice(0, 5).map(async (scene, _index) => {
              const recommendations = await this.ragService.generateLightingRecommendations(
                scene.content,
                scene.mood,
                ['LED_PAR', 'MOVING_HEAD'] // Default fixture types
              );
    
              return {
                sceneNumber: scene.sceneNumber,
                title: scene.title || `Scene ${scene.sceneNumber}`,
                mood: scene.mood,
                timeOfDay: scene.timeOfDay,
                location: scene.location,
                suggestedLighting: {
                  colorPalette: recommendations.colorSuggestions,
                  intensity: this.mapIntensityLevel(recommendations.intensityLevels),
                  focusAreas: recommendations.focusAreas,
                  reasoning: recommendations.reasoning
                },
                estimatedFixtureCount: this.estimateFixtureNeeds(recommendations)
              };
            })
          );
    
          result.sceneTemplates = sceneTemplates;
        }
    
        return result;
      } catch (error) {
        throw new Error(`Failed to analyze script: ${error}`);
      }
  • Zod schema defining input parameters for the analyze_script tool: scriptText (required), extractLightingCues and suggestScenes (optional booleans with defaults). Used for validation in handler.
    const AnalyzeScriptSchema = z.object({
      scriptText: z.string(),
      extractLightingCues: z.boolean().default(true),
      suggestScenes: z.boolean().default(true)
    });
  • src/index.ts:861-884 (registration)
    Tool registration in ListToolsRequestSchema handler: defines name 'analyze_script', description, and inputSchema matching AnalyzeScriptSchema.
      name: "analyze_script",
      description:
        "Analyze a theatrical script to extract lighting-relevant information",
      inputSchema: {
        type: "object",
        properties: {
          scriptText: {
            type: "string",
            description: "The theatrical script text to analyze",
          },
          extractLightingCues: {
            type: "boolean",
            default: true,
            description: "Extract specific lighting cues from the script",
          },
          suggestScenes: {
            type: "boolean",
            default: true,
            description: "Generate scene suggestions based on analysis",
          },
        },
        required: ["scriptText"],
      },
    },
  • src/index.ts:2098-2110 (registration)
    Dispatch handler in CallToolRequestSchema: routes 'analyze_script' calls to sceneTools.analyzeScript method.
    case "analyze_script":
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              await this.sceneTools.analyzeScript(args as any),
              null,
              2,
            ),
          },
        ],
      };
  • Core RAG service method analyzeScript that performs GPT-4 analysis on script text to extract scenes, moods, characters, lighting cues, etc., returning ScriptAnalysis object. Called by the tool handler.
      async analyzeScript(scriptText: string): Promise<ScriptAnalysis> {
        const prompt = `
    Analyze this theatrical script and extract lighting-relevant information. Return a JSON object with the following structure:
    
    {
      "scenes": [
        {
          "sceneNumber": "string",
          "title": "string (optional)",
          "content": "string (excerpt)",
          "mood": "string (e.g., tense, romantic, mysterious)",
          "characters": ["string"],
          "stageDirections": ["string"],
          "lightingCues": ["string"],
          "timeOfDay": "string (optional)",
          "location": "string (optional)"
        }
      ],
      "characters": ["string"],
      "settings": ["string"],
      "overallMood": "string",
      "themes": ["string"]
    }
    
    Script text:
    ${scriptText}
    
    Focus on:
    - Mood and atmosphere descriptions
    - Time of day and location changes
    - Stage directions that imply lighting
    - Character entrances and emotional beats
    - Explicit lighting cues in the text
    `;
    
        const response = await this.openai.chat.completions.create({
          model: 'gpt-4',
          messages: [{ role: 'user', content: prompt }],
          temperature: 0.3
        });
    
        const content = response.choices[0].message.content || '{}';
        try {
          return JSON.parse(content);
        } catch (_error) {
          // If JSON parsing fails, try to extract JSON from the response
          const jsonMatch = content.match(/\{[\s\S]*\}/);
          if (jsonMatch) {
            try {
              return JSON.parse(jsonMatch[0]);
            } catch (_e) {
              // If still fails, return a fallback structure
              return {
                scenes: [],
                characters: [],
                settings: [],
                overallMood: 'unknown',
                themes: []
              };
            }
          }
          return {
            scenes: [],
            characters: [],
            settings: [],
            overallMood: 'unknown',
            themes: []
          };
        }
      }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool analyzes scripts for lighting information but doesn't describe what the analysis entails, how results are returned, or any constraints like processing time or error handling. For a tool with 3 parameters and no output schema, this leaves significant gaps in understanding its behavior.

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 core purpose without unnecessary words. It directly states what the tool does, making it easy to parse and understand quickly. Every word earns its place, with no redundancy or fluff.

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 complexity of analyzing theatrical scripts with 3 parameters, no annotations, and no output schema, the description is incomplete. It lacks details on what 'lighting-relevant information' includes, how analysis results are structured, or any behavioral traits like error handling. This makes it inadequate for an agent to fully understand the tool's operation and output.

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 documents all parameters ('scriptText', 'extractLightingCues', 'suggestScenes') with clear descriptions. The description adds no additional meaning beyond implying that 'lighting-relevant information' relates to the parameters, but it doesn't explain their interplay or provide examples. Baseline 3 is appropriate as 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 tool's purpose: 'Analyze a theatrical script to extract lighting-relevant information.' It specifies the verb ('analyze'), resource ('theatrical script'), and scope ('lighting-relevant information'), which distinguishes it from siblings like 'analyze_cue_structure' or 'generate_scene'. However, it doesn't explicitly differentiate from all siblings, such as 'generate_act_cues' or 'optimize_scene', which might also involve script analysis for lighting.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, such as needing a script text input, or compare it to siblings like 'analyze_cue_structure' for cue-specific analysis or 'generate_scene' for scene generation. Without this context, an agent might struggle to choose between related tools.

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/bbernstein/lacylights-mcp'

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