write_file
Create or update files on Windows systems by specifying a path and content. This tool enables automated file management within the Windows Automation MCP Server environment.
Instructions
写入文件内容
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | 文件路径 | |
| content | Yes | 文件内容 |
Implementation Reference
- src/tools/filesystem.js:147-154 (handler)The core handler function that executes the file writing logic using fs.promises.writeFile, with error handling.async writeFile(filePath, content) { try { await fs.writeFile(filePath, content, 'utf-8'); return { success: true, path: filePath, message: '文件写入成功' }; } catch (error) { return { success: false, error: error.message }; } }
- src/tools/filesystem.js:25-36 (schema)The tool definition including name, description, and input schema (path and content required strings).{ name: 'write_file', description: '写入文件内容', inputSchema: { type: 'object', properties: { path: { type: 'string', description: '文件路径' }, content: { type: 'string', description: '文件内容' }, }, required: ['path', 'content'], }, },
- src/tools/filesystem.js:119-120 (registration)Dispatches write_file calls to the writeFile handler in the executeTool switch statement.case 'write_file': return await this.writeFile(args.path, args.content);
- src/server.js:44-44 (registration)Instantiates the FileSystemTools class, which provides the write_file tool, and registers it in the server's tools map.filesystem: new FileSystemTools(),
- src/tools/filesystem.js:110-111 (helper)Includes 'write_file' in the list of supported tools for the canHandle method.const tools = ['read_file', 'write_file', 'list_directory', 'create_directory', 'delete_file', 'copy_file', 'move_file', 'search_files'];