replicate-flux-mcp
Version:
MCP for Replicate Flux Model
44 lines (43 loc) • 1.26 kB
JavaScript
import { replicate } from "../services/replicate.js";
import { handleError } from "../utils/error.js";
import { urlToSvg } from "../utils/image.js";
import { CONFIG } from "../config/index.js";
export const registerGenerateSvgTool = async (input) => {
try {
const output = (await replicate.run(CONFIG.svgModelId, {
input,
}));
const svgUrl = output.url();
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);
}
};