Skip to main content
Glama

letzai_upscale_image

Enhance image resolution and clarity using the Letz AI MCP server. Provide an image ID or URL, set upscaling strength (1-3), and generate high-quality versions.

Instructions

Upscale an image using the LetzAI public api

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageIdNoThe unique identifier of the image to be upscaled.
imageUrlNoThe URL of the image to be upscaled. Must be a publicly available URL.
strengthYesThe strength of the upscaling process. Min. 1, Max. 3.

Implementation Reference

  • Main execution logic for the letzai_upscale_image tool: parses arguments, makes POST to LetzAI /upscale API, polls status until ready, opens image in browser, and returns success message with URL.
    } else if (request.params.name === "letzai_upscale_image") { try { let { imageId, imageUrl, strength } = request.params.arguments as any; strength = parseInt(strength) || 1; let body = {}; if (imageId) { body = { imageId, strength, }; } else if (imageUrl) { body = { imageUrl, strength, }; } else { throw new Error("Provide image ID or Image URL"); } // Step 1: Create the image request const responseCreate = await axios.post( "https://api.letz.ai/upscale", body, { headers: { Authorization: `Bearer ${process.env.LETZAI_API_KEY}`, }, } ); let imageFinished = false; let imageVersions: { original: string; "96x96": string; "240x240": string; "640x640": string; "1920x1920": string; } | null = null; let upscaleId = responseCreate.data.id; // Step 2: Poll for image creation status while (!imageFinished) { await new Promise((resolve) => setTimeout(resolve, 5000)); // Wait before checking again const responseImage = await axios.get( `https://api.letz.ai/upscale/${upscaleId}`, { headers: { Authorization: `Bearer ${process.env.LETZAI_API_KEY}`, }, } ); if (responseImage.data.status != "ready") { // Send a progress notification (through stdout for Stdio transport) console.log( JSON.stringify({ jsonrpc: "2.0", method: "progress_update", params: { message: `Image is still being processed. Progress: ${responseImage.data.progress}%`, }, }) ); } else { imageFinished = true; imageVersions = responseImage.data.imageVersions; } } // Convert the image to Base64 after processing is complete /* const imageBase64 = convertImageUrlToBase64( imageVersions?.["640x640"] as string ); */ // Open the image in browser open(imageVersions?.original as string); // Return the response to the client return { content: [ { type: "text", text: `Image upscaled successfully!\nThe image has been opened in your default browser.\n\n Image URL: ${imageVersions?.original}\n\nYou can also click the URL above to view the image again.`, }, ], }; } catch (err: any) { return { content: [ { type: "text", text: `Error happened: ${err.toString()}`, }, ], }; } }
  • Defines the tool metadata, description, and input schema (imageId or imageUrl, strength).
    export const upscaleImageTool = { name: "letzai_upscale_image", description: "Upscale an image using the LetzAI public api", inputSchema: { type: "object", properties: { imageId: { type: "string", description: "The unique identifier of the image to be upscaled.", }, imageUrl: { type: "string", description: "The URL of the image to be upscaled. Must be a publicly available URL.", }, strength: { type: "number", default: 1, description: "The strength of the upscaling process. Min. 1, Max. 3.", }, }, required: ["strength"], }, };
  • src/tools.ts:13-17 (registration)
    Registers the upscaleImageTool (imported from ./tools/upscaleImage.js) in the list of available tools for ListToolsRequest.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [createImageTool, upscaleImageTool], }; });

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/Letz-AI/letzai-mcp'

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