Skip to main content
Glama
fileUtils.ts821 B
import * as fs from 'fs'; import * as path from 'path'; import open from 'open'; /** * Creates a temporary directory if it doesn't exist * @returns The path to the temporary directory */ export function ensureTempDir(): string { const tempDir = path.join(process.cwd(), 'temp'); if (!fs.existsSync(tempDir)) { fs.mkdirSync(tempDir); } return tempDir; } /** * Writes content to a file and opens it in the browser * @param filename The name of the file * @param content The content to write * @returns The path to the created file */ export async function writeAndOpenFile(filename: string, content: string): Promise<string> { const tempDir = ensureTempDir(); const filePath = path.join(tempDir, filename); fs.writeFileSync(filePath, content); await open(filePath); return filePath; }

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/madebyaris/rakitui-ai'

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