Skip to main content
Glama
copyFile.js1.25 kB
import * as fs from 'graceful-fs'; import { dirname } from 'path'; import mkdirp from 'mkdirp'; import resolvePathAndOptions from '../utils/resolvePathAndOptions'; export function copyFile () { const { resolvedPath: src, options: readOptions } = resolvePathAndOptions( arguments ); return { to () { const { resolvedPath: dest, options: writeOptions } = resolvePathAndOptions( arguments ); return new Promise( ( fulfil, reject ) => { mkdirp( dirname( dest ), err => { if ( err ) { reject( err ); } else { const readStream = fs.createReadStream( src, readOptions ); const writeStream = fs.createWriteStream( dest, writeOptions ); readStream.on( 'error', reject ); writeStream.on( 'error', reject ); writeStream.on( 'close', fulfil ); readStream.pipe( writeStream ); } }); }); } }; } export function copyFileSync () { const { resolvedPath: src, options: readOptions } = resolvePathAndOptions( arguments ); return { to () { const { resolvedPath: dest, options: writeOptions } = resolvePathAndOptions( arguments ); const data = fs.readFileSync( src, readOptions ); mkdirp.sync( dirname( dest ) ); fs.writeFileSync( dest, data, writeOptions ); } }; }

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/MatheusgVentura/Project-One'

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