Skip to main content
Glama

file_write

Write content to files for storing notes, documents, and operational data within the AI Ops Hub environment.

Instructions

Записать содержимое в файл

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesСодержимое для записи
pathYesПуть к файлу

Implementation Reference

  • The core handler function that executes the file_write tool logic. Sanitizes the file path, ensures it's within the allowed directory, creates parent directories if needed, and writes the content using Node.js fs.promises.writeFile.
    async writeFile(filePath: string, content: string): Promise<void> { try { // Проверяем безопасность пути const safePath = this.sanitizePath(filePath); console.log(`✏️ Запись в файл: ${safePath}`); // Создаем директорию если её нет const dir = path.dirname(safePath); await fs.mkdir(dir, { recursive: true }); await fs.writeFile(safePath, content, 'utf-8'); console.log(`✅ Файл записан: ${safePath} (${content.length} символов)`); } catch (error) { console.error('Ошибка записи файла:', error); throw new Error(`Ошибка записи файла: ${error}`); } }
  • src/server.ts:201-203 (registration)
    Registration and dispatch for file_write tool in the MCP server's CallToolRequestSchema handler. Calls the FileService.writeFile method.
    case 'file_write': await this.fileService.writeFile(args.path as string, args.content as string); return { content: 'Файл записан' };
  • Input schema definition for the file_write tool, provided in the ListToolsRequestSchema response.
    { name: 'file_write', description: 'Записать содержимое в файл', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Путь к файлу', }, content: { type: 'string', description: 'Содержимое для записи', }, }, required: ['path', 'content'], }, },
  • Duplicate registration and dispatch for file_write in the HTTP transport's handleCallTool method.
    case 'file_write': await this.fileService.writeFile(args.path, args.content); result = { message: 'Файл записан' };
  • Input schema for file_write tool in the HTTP transport's handleListTools method.
    { name: 'file_write', description: 'Записать содержимое в файл', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Путь к файлу' }, content: { type: 'string', description: 'Содержимое для записи' } }, required: ['path', 'content'] } },

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/Galiusbro/MCP'

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