Skip to main content
Glama
CrispUpscale.ts1.59 kB
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" import { imageDataToBlob } from "../utils" import z from "zod" import { RecraftServer } from "../RecraftServer" import { PARAMETERS } from "../utils/parameters" import { downloadImage } from "../utils/download" export const crispUpscaleTool = { name: "crisp_upscale", description: "Crisp upscale of the input image using Recraft.\n" + "This operation takes an input image and returns an upscaled image, making the image sharper and cleaner.\n" + "This version of upscale is much cheaper and faster than creative upscale.\n" + "Local path or URL to resulting image and its preview will be returned in the response.", inputSchema: { type: "object", properties: { imageURI: PARAMETERS.imageURI, }, required: ["imageURI"] } } export const crispUpscaleHandler = async (server: RecraftServer, args: Record<string, unknown>): Promise<CallToolResult> => { try { const { imageURI } = z.object({ imageURI: z.string(), }).parse(args) const imageData = await downloadImage(imageURI) const result = await server.api.imageApi.crispUpscale({ image: await imageDataToBlob(imageData), responseFormat: 'url', expire: server.isLocalResultsStorage, }) return await server.transformSingleImageOperationToCallToolResult(result.image, 'Crisp upscale completed.') } catch (error) { return { content: [ { type: 'text', text: `Crisp upscale error: ${error}` } ], isError: true } } }

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/recraft-ai/mcp-recraft-server'

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