UNPKG

@genwave/svgmaker-mcp

Version:

MCP server for generating, editing, and converting SVG images using SVGMaker API

97 lines 3.55 kB
import { SVGMakerClient } from '@genwave/svgmaker-sdk'; let svgMaker; export function initializeSvgmakerService(apiKey, rateLimitRpmStr, baseUrl) { const rateLimit = rateLimitRpmStr ? parseInt(rateLimitRpmStr, 10) : 2; const config = { logging: false, // Disable logging to prevent stdout pollution rateLimit: rateLimit, // RPM debug: false, // Enable debug mode timeout: 180000, // 180s timeout maxRetries: 0, // Do not retry requests }; // Add baseUrl to config if provided if (baseUrl) { config.baseUrl = baseUrl; } svgMaker = new SVGMakerClient(apiKey, config); } export async function generateSVG(params) { if (!svgMaker) throw new Error('SVGMakerService not initialized.'); const configuredParams = { ...params, svgText: !params.raster, storage: params.raster ? false : (params.storage ?? true), }; const result = await svgMaker.generate.configure(configuredParams).execute(); return result; } export async function editSVG(params) { if (!svgMaker) throw new Error('SVGMakerService not initialized.'); const configuredParams = { ...params, svgText: !params.raster, storage: params.raster ? false : (params.storage ?? true), }; const result = await svgMaker.edit.configure(configuredParams).execute(); return result; } export async function convertImageToSVG(params) { if (!svgMaker) throw new Error('SVGMakerService not initialized.'); const configuredParams = { ...params, svgText: true, storage: true }; const result = await svgMaker.convert.aiVectorize.configure(configuredParams).execute(); return result; } export async function getAccountInfo() { if (!svgMaker) throw new Error('SVGMakerService not initialized.'); return await svgMaker.account.getInfo(); } export async function getAccountUsage(params) { if (!svgMaker) throw new Error('SVGMakerService not initialized.'); return await svgMaker.account.getUsage(params); } export async function listGenerations(params) { if (!svgMaker) throw new Error('SVGMakerService not initialized.'); return await svgMaker.generations.list(params); } export async function getGeneration(id) { if (!svgMaker) throw new Error('SVGMakerService not initialized.'); return await svgMaker.generations.get(id); } export async function deleteGeneration(id) { if (!svgMaker) throw new Error('SVGMakerService not initialized.'); return await svgMaker.generations.delete(id); } export async function shareGeneration(id) { if (!svgMaker) throw new Error('SVGMakerService not initialized.'); return await svgMaker.generations.share(id); } export async function downloadGeneration(id, params) { if (!svgMaker) throw new Error('SVGMakerService not initialized.'); return await svgMaker.generations.download(id, params); } export async function listGallery(params) { if (!svgMaker) throw new Error('SVGMakerService not initialized.'); return await svgMaker.gallery.list(params); } export async function getGalleryItem(id) { if (!svgMaker) throw new Error('SVGMakerService not initialized.'); return await svgMaker.gallery.get(id); } export async function downloadGalleryItem(id, params) { if (!svgMaker) throw new Error('SVGMakerService not initialized.'); return await svgMaker.gallery.download(id, params); } //# sourceMappingURL=svgmakerService.js.map