file_write
Write content to files for storing notes, documents, and operational data within the AI Ops Hub environment.
Instructions
Записать содержимое в файл
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Содержимое для записи | |
| path | Yes | Путь к файлу |
Implementation Reference
- src/connectors/file-service.ts:30-48 (handler)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: 'Файл записан' };
- src/server.ts:99-116 (schema)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'], }, },
- src/transports/http-transport.ts:237-239 (registration)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'] } },