Skip to main content
Glama

mcp_aftereffects_applyEffect

Apply effects to specific layers in After Effects by specifying composition and layer indices, effect name, and optional settings using a standardized protocol.

Instructions

Apply an effect to a layer in After Effects

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
compIndexYes1-based index of the target composition in the project panel.
effectMatchNameNoAfter Effects internal name for the effect (more reliable, e.g., 'ADBE Gaussian Blur 2').
effectNameNoDisplay name of the effect to apply (e.g., 'Gaussian Blur').
effectSettingsNoOptional parameters for the effect (e.g., { 'Blurriness': 25 }).
layerIndexYes1-based index of the target layer within the composition.

Implementation Reference

  • The async handler function for the mcp_aftereffects_applyEffect tool. It writes the 'applyEffect' command to a temporary JSON file for the After Effects MCP Bridge Auto panel to execute, waits 1 second, then reads and returns the results from the results temp file.
    async (parameters) => { try { // Queue the command for After Effects writeCommandFile("applyEffect", parameters); // Wait a bit for After Effects to process the command await new Promise(resolve => setTimeout(resolve, 1000)); // Get the results const result = readResultsFromTempFile(); return { content: [ { type: "text", text: result } ] }; } catch (error) { return { content: [ { type: "text", text: `Error applying effect: ${String(error)}` } ], isError: true }; } }
  • Zod input schema defining parameters for the tool: compIndex, layerIndex, effectName, effectMatchName, and effectSettings.
    { compIndex: z.number().int().positive().describe("1-based index of the target composition in the project panel."), layerIndex: z.number().int().positive().describe("1-based index of the target layer within the composition."), effectName: z.string().optional().describe("Display name of the effect to apply (e.g., 'Gaussian Blur')."), effectMatchName: z.string().optional().describe("After Effects internal name for the effect (more reliable, e.g., 'ADBE Gaussian Blur 2')."), effectSettings: z.record(z.any()).optional().describe("Optional parameters for the effect (e.g., { 'Blurriness': 25 }).") },
  • src/index.ts:773-814 (registration)
    MCP server.tool registration for the 'mcp_aftereffects_applyEffect' tool, including schema and inline handler.
    server.tool( "mcp_aftereffects_applyEffect", "Apply an effect to a layer in After Effects", { compIndex: z.number().int().positive().describe("1-based index of the target composition in the project panel."), layerIndex: z.number().int().positive().describe("1-based index of the target layer within the composition."), effectName: z.string().optional().describe("Display name of the effect to apply (e.g., 'Gaussian Blur')."), effectMatchName: z.string().optional().describe("After Effects internal name for the effect (more reliable, e.g., 'ADBE Gaussian Blur 2')."), effectSettings: z.record(z.any()).optional().describe("Optional parameters for the effect (e.g., { 'Blurriness': 25 }).") }, async (parameters) => { try { // Queue the command for After Effects writeCommandFile("applyEffect", parameters); // Wait a bit for After Effects to process the command await new Promise(resolve => setTimeout(resolve, 1000)); // Get the results const result = readResultsFromTempFile(); return { content: [ { type: "text", text: result } ] }; } catch (error) { return { content: [ { type: "text", text: `Error applying effect: ${String(error)}` } ], isError: true }; } } );
  • Helper function used by the handler to write the command ('applyEffect') and parameters to the temporary ae_command.json file for After Effects to detect and execute.
    function writeCommandFile(command: string, args: Record<string, any> = {}): void { try { const commandFile = path.join(process.env.TEMP || process.env.TMP || '', 'ae_command.json'); const commandData = { command, args, timestamp: new Date().toISOString(), status: "pending" // pending, running, completed, error }; fs.writeFileSync(commandFile, JSON.stringify(commandData, null, 2)); console.error(`Command "${command}" written to ${commandFile}`); } catch (error) { console.error("Error writing command file:", error); }
  • Helper function used by the handler to read the JSON results from the ae_mcp_result.json temp file produced by After Effects after executing the command.
    function readResultsFromTempFile(): string { try { const tempFilePath = path.join(process.env.TEMP || process.env.TMP || '', 'ae_mcp_result.json'); // Add debugging info console.error(`Checking for results at: ${tempFilePath}`); if (fs.existsSync(tempFilePath)) { // Get file stats to check modification time const stats = fs.statSync(tempFilePath); console.error(`Result file exists, last modified: ${stats.mtime.toISOString()}`); const content = fs.readFileSync(tempFilePath, 'utf8'); console.error(`Result file content length: ${content.length} bytes`); // If the result file is older than 30 seconds, warn the user const thirtySecondsAgo = new Date(Date.now() - 30 * 1000); if (stats.mtime < thirtySecondsAgo) { console.error(`WARNING: Result file is older than 30 seconds. After Effects may not be updating results.`); return JSON.stringify({ warning: "Result file appears to be stale (not recently updated).", message: "This could indicate After Effects is not properly writing results or the MCP Bridge Auto panel isn't running.", lastModified: stats.mtime.toISOString(), originalContent: content }); } return content; } else { console.error(`Result file not found at: ${tempFilePath}`); return JSON.stringify({ error: "No results file found. Please run a script in After Effects first." }); } } catch (error) { console.error("Error reading results file:", error); return JSON.stringify({ error: `Failed to read results: ${String(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/Dakkshin/after-effects-mcp'

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