awk_process
Manipulate file columns, perform calculations, or apply conditional processing using AWK scripts with MCP SmallEdit. Input a file path and script to generate custom outputs efficiently.
Instructions
Process files using AWK for more complex operations like column manipulation, calculations, or conditional processing
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Input file path | |
| outputFile | No | Output file path (optional, defaults to stdout) | |
| script | Yes | AWK script to execute |
Implementation Reference
- src/index.ts:646-672 (handler)Handler function that destructures input arguments, checks if input file exists, constructs and executes the AWK command using execAsync, handles output redirection if outputFile is provided, and returns a response with processing status or stdout.case 'awk_process': { const { file, script, outputFile } = args; if (!existsSync(file)) { throw new Error(`File not found: ${file}`); } let awkCmd = `awk '${script}' '${file}'`; if (outputFile) { awkCmd += ` > '${outputFile}'`; } const { stdout, stderr } = await execAsync(awkCmd); if (stderr) { throw new Error(`AWK error: ${stderr}`); } return { content: [{ type: 'text', text: outputFile ? `Processed ${file} -> ${outputFile}` : stdout || 'AWK processing complete' }] }; }
- src/index.ts:98-115 (schema)Input schema defining the parameters for the awk_process tool: required file and script, optional outputFile.inputSchema: { type: 'object', properties: { file: { type: 'string', description: 'Input file path' }, script: { type: 'string', description: 'AWK script to execute' }, outputFile: { type: 'string', description: 'Output file path (optional, defaults to stdout)' } }, required: ['file', 'script'] }
- src/index.ts:95-116 (registration)Tool registration object in the tools array passed to server.setTools, including name, description, and inputSchema.{ name: 'awk_process', description: 'Process files using AWK for more complex operations like column manipulation, calculations, or conditional processing', inputSchema: { type: 'object', properties: { file: { type: 'string', description: 'Input file path' }, script: { type: 'string', description: 'AWK script to execute' }, outputFile: { type: 'string', description: 'Output file path (optional, defaults to stdout)' } }, required: ['file', 'script'] } },