mqscript_file_write
Write content to files using specified encoding and append options for mobile automation script operations.
Instructions
Write content to file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| append | No | Append to file instead of overwrite | |
| content | Yes | Content to write | |
| encoding | No | File encoding | UTF-8 |
| filePath | Yes | File path to write |
Implementation Reference
- src/tools/plugin-commands.ts:364-375 (handler)The handler function that implements the tool logic by generating MQScript code for writing to a file.handler: async (args: { filePath: string; content: string; encoding?: string; append?: boolean }) => { const { filePath, content, encoding = 'UTF-8', append = false } = args; const script = `File.Write("${filePath}", "${content}", "${encoding}", ${append})`; return { content: [ { type: 'text', text: `Generated MQScript file write command:\n\`\`\`\n${script}\n\`\`\`\n\nThis writes content to file "${filePath}" with encoding "${encoding}", append=${append}.` } ] }; }
- src/tools/plugin-commands.ts:339-363 (schema)The input schema defining the parameters for the mqscript_file_write tool.inputSchema: { type: 'object' as const, properties: { filePath: { type: 'string', description: 'File path to write' }, content: { type: 'string', description: 'Content to write' }, encoding: { type: 'string', description: 'File encoding', enum: ['UTF-8', 'GBK', 'ASCII'], default: 'UTF-8' }, append: { type: 'boolean', description: 'Append to file instead of overwrite', default: false } }, required: ['filePath', 'content'] },
- src/index.ts:57-61 (registration)Registration of FileCommands (containing mqscript_file_write) into the ALL_TOOLS registry used by MCP server handlers....CJsonCommands, ...DateTimeCommands, ...FileCommands, ...TuringCommands, };
- src/index.ts:64-72 (registration)MCP ListTools handler that lists all registered tools including mqscript_file_write.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: Object.values(ALL_TOOLS).map(tool => ({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema, })), }; });
- src/index.ts:75-88 (registration)MCP CallTool handler that executes the tool handler for mqscript_file_write when called.server.setRequestHandler(CallToolRequestSchema, async (request: CallToolRequest) => { const { name, arguments: args } = request.params; const tool = Object.values(ALL_TOOLS).find(t => t.name === name); if (!tool) { throw new Error(`Unknown tool: ${name}`); } try { return await tool.handler(args as any || {}); } catch (error) { throw new Error(`Error executing tool ${name}: ${error instanceof Error ? error.message : String(error)}`); } });