Skip to main content
Glama

Printify MCP Server

by TSavo
file-utils.ts1.53 kB
/** * File utilities for Printify MCP */ import * as fs from 'fs'; import * as path from 'path'; /** * Ensure a directory exists, creating it if necessary */ export function ensureDirectoryExists(dirPath: string): void { if (!fs.existsSync(dirPath)) { fs.mkdirSync(dirPath, { recursive: true }); console.log(`Created directory: ${dirPath}`); } } /** * Generate a temporary file path */ export function generateTempFilePath( baseDir: string, fileName: string, extension: string = 'png' ): string { // Ensure the directory exists ensureDirectoryExists(baseDir); // Generate a unique filename with timestamp const uniqueFileName = `${Date.now()}_${fileName}.${extension}`; return path.resolve(path.join(baseDir, uniqueFileName)); } /** * Clean up temporary files */ export function cleanupFiles(filePaths: string[]): void { filePaths.forEach(filePath => { if (filePath && fs.existsSync(filePath)) { try { fs.unlinkSync(filePath); console.log(`Cleaned up file: ${filePath}`); } catch (error) { console.error(`Error cleaning up file ${filePath}:`, error); } } }); } /** * Get file information */ export function getFileInfo(filePath: string): { exists: boolean; size?: number; stats?: fs.Stats } { if (!filePath) { return { exists: false }; } if (fs.existsSync(filePath)) { const stats = fs.statSync(filePath); return { exists: true, size: stats.size, stats }; } return { exists: false }; }

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/TSavo/printify-mcp'

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