apply-effect
Transform images by applying effects like blur, sharpen, grayscale, or sepia using customizable intensity. Save processed files to a specified path or default Downloads folder.
Instructions
Apply visual effect to image
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| effect | Yes | Effect to apply | |
| inputPath | Yes | Absolute path to input image file | |
| intensity | No | Effect intensity (0-100, not applicable for some effects) | |
| outputFilename | No | Output filename (only used if outputPath is not provided) | |
| outputPath | No | Optional absolute path for output file. If not provided, file will be saved in Downloads folder |
Implementation Reference
- src/index.ts:513-579 (registration)Registration of the 'apply-effect' MCP tool using server.tool, including inline schema and handler function.server.tool( "apply-effect", "Apply visual effect to image", { inputPath: z.string().describe("Absolute path to input image file"), effect: z.enum(['blur', 'sharpen', 'edge', 'emboss', 'grayscale', 'sepia', 'negate']).describe("Effect to apply"), intensity: z.number().min(0).max(100).default(50).describe("Effect intensity (0-100, not applicable for some effects)"), outputPath: z.string().optional().describe("Optional absolute path for output file. If not provided, file will be saved in Downloads folder"), outputFilename: z.string().optional().describe("Output filename (only used if outputPath is not provided)") }, async ({ inputPath, effect, intensity, outputPath, outputFilename }) => { try { await checkImageMagick(); const absoluteInputPath = await getAbsolutePath(inputPath); const inputFileName = absoluteInputPath.split('/').pop()?.split('.')[0] || 'output'; const extension = absoluteInputPath.split('.').pop() || 'png'; const defaultFilename = outputFilename || `${inputFileName}_${effect}.${extension}`; const finalOutputPath = await getOutputPath(outputPath, defaultFilename); let command = ''; switch (effect) { case 'blur': command = `convert "${absoluteInputPath}" -blur 0x${intensity / 5} "${finalOutputPath}"`; break; case 'sharpen': command = `convert "${absoluteInputPath}" -sharpen 0x${intensity / 10} "${finalOutputPath}"`; break; case 'edge': command = `convert "${absoluteInputPath}" -edge ${intensity / 10} "${finalOutputPath}"`; break; case 'emboss': command = `convert "${absoluteInputPath}" -emboss ${intensity / 10} "${finalOutputPath}"`; break; case 'grayscale': command = `convert "${absoluteInputPath}" -colorspace Gray "${finalOutputPath}"`; break; case 'sepia': command = `convert "${absoluteInputPath}" -sepia-tone ${intensity}% "${finalOutputPath}"`; break; case 'negate': command = `convert "${absoluteInputPath}" -negate "${finalOutputPath}"`; break; } await execSync(command); return { content: [ { type: "text", text: `Effect successfully applied and saved to: ${finalOutputPath}`, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error applying effect: ${errorMessage}`, }, ], }; } } );
- src/index.ts:523-578 (handler)Handler that applies ImageMagick effects to images based on the 'effect' parameter (blur, sharpen, edge, emboss, grayscale, sepia, negate), handling paths and errors.async ({ inputPath, effect, intensity, outputPath, outputFilename }) => { try { await checkImageMagick(); const absoluteInputPath = await getAbsolutePath(inputPath); const inputFileName = absoluteInputPath.split('/').pop()?.split('.')[0] || 'output'; const extension = absoluteInputPath.split('.').pop() || 'png'; const defaultFilename = outputFilename || `${inputFileName}_${effect}.${extension}`; const finalOutputPath = await getOutputPath(outputPath, defaultFilename); let command = ''; switch (effect) { case 'blur': command = `convert "${absoluteInputPath}" -blur 0x${intensity / 5} "${finalOutputPath}"`; break; case 'sharpen': command = `convert "${absoluteInputPath}" -sharpen 0x${intensity / 10} "${finalOutputPath}"`; break; case 'edge': command = `convert "${absoluteInputPath}" -edge ${intensity / 10} "${finalOutputPath}"`; break; case 'emboss': command = `convert "${absoluteInputPath}" -emboss ${intensity / 10} "${finalOutputPath}"`; break; case 'grayscale': command = `convert "${absoluteInputPath}" -colorspace Gray "${finalOutputPath}"`; break; case 'sepia': command = `convert "${absoluteInputPath}" -sepia-tone ${intensity}% "${finalOutputPath}"`; break; case 'negate': command = `convert "${absoluteInputPath}" -negate "${finalOutputPath}"`; break; } await execSync(command); return { content: [ { type: "text", text: `Effect successfully applied and saved to: ${finalOutputPath}`, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error applying effect: ${errorMessage}`, }, ], }; } }
- src/index.ts:516-522 (schema)Zod input schema for the apply-effect tool parameters.{ inputPath: z.string().describe("Absolute path to input image file"), effect: z.enum(['blur', 'sharpen', 'edge', 'emboss', 'grayscale', 'sepia', 'negate']).describe("Effect to apply"), intensity: z.number().min(0).max(100).default(50).describe("Effect intensity (0-100, not applicable for some effects)"), outputPath: z.string().optional().describe("Optional absolute path for output file. If not provided, file will be saved in Downloads folder"), outputFilename: z.string().optional().describe("Output filename (only used if outputPath is not provided)") },