Skip to main content
Glama

replicate-flux-mcp

generateSVG.ts1.25 kB
import { SvgGenerationParams } from "../types/index.js"; import { replicate } from "../services/replicate.js"; import { handleError } from "../utils/error.js"; import { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; import { urlToSvg } from "../utils/image.js"; import { CONFIG } from "../config/index.js"; import { FileOutput } from "replicate"; export const registerGenerateSvgTool = async ( input: SvgGenerationParams ): Promise<CallToolResult> => { try { const output = (await replicate.run(CONFIG.svgModelId, { input, })) as FileOutput; const svgUrl = output.url() as unknown as string; if (!svgUrl) { throw new Error("Failed to generate SVG URL"); } try { const svg = await urlToSvg(svgUrl); return { content: [ { type: "text", text: `This is a generated SVG url: ${svgUrl}`, }, { type: "text", text: svg, }, ], }; } catch (error) { return { content: [ { type: "text", text: `This is a generated SVG url: ${svgUrl}`, }, ], }; } } catch (error) { return handleError(error); } };

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/awkoy/replicate-flux-mcp'

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