Skip to main content
Glama

MCP Fullstack

by JacobFV
test-mcp-images.jsโ€ข3.14 kB
#!/usr/bin/env node /** * Test script demonstrating proper MCP image responses using jimp */ const Jimp = require('jimp'); async function generateTestImage() { console.log('๐ŸŽจ Testing MCP Image Response Format\n'); try { // Create a test image with jimp const image = new Jimp(400, 200, '#3498db'); // Blue background // Add text to the image const font = await Jimp.loadFont(Jimp.FONT_SANS_32_WHITE); image.print( font, 0, 0, { text: 'MCP Fullstack\nImage Response', alignmentX: Jimp.HORIZONTAL_ALIGN_CENTER, alignmentY: Jimp.VERTICAL_ALIGN_MIDDLE }, 400, 200 ); // Get the PNG buffer const buffer = await image.getBufferAsync(Jimp.MIME_PNG); // Create proper MCP response format const mcpResponse = { content: [ { type: 'image', data: buffer.toString('base64'), mimeType: 'image/png' } ], // Additional metadata width: image.getWidth(), height: image.getHeight(), message: 'Successfully generated test image' }; console.log('โœ… Generated MCP Image Response:'); console.log(' - Image Type: PNG'); console.log(` - Dimensions: ${mcpResponse.width}x${mcpResponse.height}`); console.log(` - Base64 Size: ${mcpResponse.content[0].data.length} chars`); console.log(' - Format: MCP content array with type "image"'); // Show the response structure (truncated) console.log('\n๐Ÿ“ฆ Response Structure:'); console.log(JSON.stringify({ content: [ { type: mcpResponse.content[0].type, data: mcpResponse.content[0].data.substring(0, 50) + '...', mimeType: mcpResponse.content[0].mimeType } ], width: mcpResponse.width, height: mcpResponse.height, message: mcpResponse.message }, null, 2)); console.log('\nโœจ This is the proper MCP format for returning images!'); console.log(' Tools should return content: [{type: "image", data: base64, mimeType: "..."}]'); // Test cropping functionality console.log('\n๐Ÿ”ง Testing Image Cropping:'); const croppedImage = image.clone().crop(50, 50, 200, 100); const croppedBuffer = await croppedImage.getBufferAsync(Jimp.MIME_PNG); console.log(` โœ… Cropped to 200x100 from (50,50)`); // Test redaction functionality console.log('\n๐Ÿ”’ Testing Redaction (Black Box):'); const redactedImage = image.clone(); const blackBox = new Jimp(100, 50, '#000000'); redactedImage.composite(blackBox, 150, 75); const redactedBuffer = await redactedImage.getBufferAsync(Jimp.MIME_PNG); console.log(` โœ… Applied black box redaction at (150,75)`); console.log('\n๐ŸŽ‰ All image utilities working with jimp!'); console.log(' - No sharp dependency needed'); console.log(' - Works everywhere (pure JavaScript)'); console.log(' - Proper MCP content format'); } catch (error) { console.error('โŒ Error:', error.message); } } // Run the test generateTestImage();

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/JacobFV/mcp-fullstack'

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