Skip to main content
Glama

fast_write_file

Write or modify files with automatic directory creation, append mode, and emoji handling options for reliable file system operations.

Instructions

Writes or modifies a file (provides emoji guidelines)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile path
contentYesFile content
encodingNoText encodingutf-8
create_dirsNoAutomatically create directories
appendNoAppend mode
force_remove_emojisNoForce remove emojis (default: false)

Implementation Reference

  • Implements the core logic for the fast_write_file tool: resolves and validates the path, optionally creates parent directories, writes or appends the content to the file, and returns success information with file stats.
    async function handleWriteFile(args: any) { const { path: filePath, content, encoding = 'utf-8', create_dirs = true, append = false } = args; let targetPath: string; if (path.isAbsolute(filePath)) { targetPath = filePath; } else { targetPath = path.join(process.cwd(), filePath); } if (!isPathAllowed(targetPath)) { throw new Error(`Access denied to path: ${targetPath}`); } const resolvedPath = path.resolve(targetPath); if (create_dirs) { const dir = path.dirname(resolvedPath); await fs.mkdir(dir, { recursive: true }); } if (append) { await fs.appendFile(resolvedPath, content, encoding as BufferEncoding); } else { await fs.writeFile(resolvedPath, content, encoding as BufferEncoding); } const stats = await fs.stat(resolvedPath); return { message: `File ${append ? 'appended' : 'written'} successfully`, path: resolvedPath, size: stats.size, size_readable: formatSize(stats.size), encoding: encoding, mode: append ? 'append' : 'write', timestamp: new Date().toISOString() }; }
  • Defines the input schema for the fast_write_file tool, specifying parameters like path, content, encoding, create_dirs, and append with their types and descriptions.
    { name: 'fast_write_file', description: '파일을 쓰거나 수정합니다', inputSchema: { type: 'object', properties: { path: { type: 'string', description: '파일 경로' }, content: { type: 'string', description: '파일 내용' }, encoding: { type: 'string', description: '텍스트 인코딩', default: 'utf-8' }, create_dirs: { type: 'boolean', description: '디렉토리 자동 생성', default: true }, append: { type: 'boolean', description: '추가 모드', default: false } }, required: ['path', 'content'] } },
  • api/server.ts:326-328 (registration)
    Registers the fast_write_file tool handler in the main tools/call switch statement, dispatching calls to the handleWriteFile function.
    case 'fast_write_file': result = await handleWriteFile(args); break;

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/efforthye/fast-filesystem-mcp'

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