Skip to main content
Glama
A-Niranjan

MCP Filesystem Server

by A-Niranjan

bash_pipe

Execute a sequence of Bash commands piped together to combine multiple operations in a single workflow, returning both stdout and stderr outputs.

Instructions

Execute a sequence of Bash commands piped together. Allows for powerful command combinations with pipes. Results include both stdout and stderr.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandsYesArray of commands to pipe together
workingDirNoWorking directory for command execution
timeoutNoMaximum execution time in milliseconds (max 60s)
envNoAdditional environment variables for the command

Implementation Reference

  • The primary handler function for the 'bash_pipe' tool. Validates input arguments using BashPipeArgsSchema, executes the piped commands via bashPipe, formats the result with stdout/stderr/exit code, and handles errors.
    export async function handleBashPipe(args: any, config: Config) {
      const endMetric = metrics.startOperation('bash_pipe')
    
      try {
        // Validate arguments
        const parsed = BashPipeArgsSchema.safeParse(args)
        if (!parsed.success) {
          throw new FileSystemError(`Invalid arguments for bash_pipe`, 'INVALID_ARGS', undefined, {
            errors: parsed.error.format(),
          })
        }
    
        // Execute the command
        const result = await bashPipe(parsed.data, config)
    
        // Format the response
        const formattedResponse = formatCommandResult(result, parsed.data.commands.join(' | '))
    
        await logger.debug(`Bash pipe executed`, {
          commands: parsed.data.commands,
          exitCode: result.exitCode,
        })
    
        endMetric()
        return {
          content: [
            {
              type: 'text',
              text: formattedResponse,
            },
          ],
        }
      } catch (error) {
        metrics.recordError('bash_pipe')
    
        if (error instanceof FileSystemError) {
          await logger.error(`Error in bash_pipe:`, error.toJSON())
          return {
            content: [{ type: 'text', text: `Error: ${error.message}` }],
            isError: true,
          }
        }
    
        const errorMessage = error instanceof Error ? error.message : String(error)
        await logger.error(`Unexpected error in bash_pipe:`, { error })
    
        return {
          content: [{ type: 'text', text: `Error: ${errorMessage}` }],
          isError: true,
        }
      }
  • Core implementation of bash_pipe logic: validates each command in the array, joins them with pipe '|', constructs args for bashExecute, and delegates execution.
    export async function bashPipe(
      args: z.infer<typeof BashPipeArgsSchema>,
      config: Config
    ): Promise<{ stdout: string; stderr: string; exitCode: number }> {
      // Validate each command
      for (const command of args.commands) {
        validateCommand(command)
      }
    
      // Validate working directory if provided
      args.workingDir ? await validatePath(args.workingDir, config) : process.cwd()
      // Construct the piped command
      const pipedCommand = args.commands.join(' | ')
    
      // Use bash to execute the piped command
      return bashExecute(
        {
          command: pipedCommand,
          workingDir: args.workingDir,
          timeout: args.timeout,
          env: args.env,
        },
        config
      )
    }
  • Zod schema for input validation of the bash_pipe tool, defining required 'commands' array and optional workingDir, timeout, env.
    export const BashPipeArgsSchema = z.object({
      commands: z.array(z.string()).min(1).describe('Array of commands to pipe together'),
      workingDir: z.string().optional().describe('Working directory for command execution'),
      timeout: z
        .number()
        .int()
        .positive()
        .max(60000)
        .optional()
        .default(30000)
        .describe('Maximum execution time in milliseconds (max 60s)'),
      env: z.record(z.string()).optional().describe('Additional environment variables for the command'),
    })
  • src/index.ts:363-370 (registration)
    Registration of the 'bash_pipe' tool in the list_tools handler response, specifying name, description, and input schema.
    {
      name: 'bash_pipe',
      description:
        'Execute a sequence of Bash commands piped together. ' +
        'Allows for powerful command combinations with pipes. ' +
        'Results include both stdout and stderr.',
      inputSchema: zodToJsonSchema(BashPipeArgsSchema) as ToolInput,
    },
  • src/index.ts:761-763 (registration)
    Dispatch handler in the main tool call switch statement that routes 'bash_pipe' calls to the handleBashPipe function.
    case 'bash_pipe': {
      return await handleBashPipe(a, config)
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds useful context about what results to expect ('Results include both stdout and stderr'), which isn't obvious from the schema alone. However, it doesn't mention important behavioral aspects like security implications, error handling, or whether commands run with user privileges, leaving significant gaps for a tool that executes arbitrary Bash commands.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise with just two sentences that each earn their place: the first states the core functionality, and the second adds crucial behavioral information about output. There's zero waste or redundancy, and the information is front-loaded effectively.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of executing arbitrary Bash commands with pipes (a potentially dangerous operation), the description is incomplete. With no annotations and no output schema, it should provide more guidance about security, permissions, error conditions, and return format. The description covers basic functionality but lacks the depth needed for safe and effective use of this powerful tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the schema already documents all 4 parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema, such as explaining how the pipe sequence works or providing examples of command arrays. The baseline score of 3 reflects adequate but not enhanced parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Execute a sequence of Bash commands piped together') and resource (Bash commands), distinguishing it from sibling tools like 'bash_execute' or 'execute_command' by emphasizing the pipe functionality. It provides a precise verb+resource combination that leaves no ambiguity about the tool's function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('Allows for powerful command combinations with pipes'), suggesting it's for chaining commands rather than single executions. However, it doesn't explicitly state when NOT to use it or name specific alternatives among siblings like 'bash_execute', leaving some room for improvement in distinguishing between similar tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/A-Niranjan/mcp-filesystem'

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