Skip to main content
Glama

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
NameRequiredDescriptionDefault
fileYesInput file path
outputFileNoOutput file path (optional, defaults to stdout)
scriptYesAWK script to execute

Implementation Reference

  • 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' }] }; }
  • 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'] } },

Other Tools

Related Tools

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/MikeyBeez/mcp-smalledit'

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