Skip to main content
Glama
gabrielmaialva33

MCP Filesystem Server

bash_pipe

Execute a sequence of Bash commands piped together on the MCP Filesystem Server. Combine commands for advanced processing, with results capturing both stdout and stderr.

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
envNoAdditional environment variables for the command
timeoutNoMaximum execution time in milliseconds (max 60s)
workingDirNoWorking directory for command execution

Implementation Reference

  • Main handler for bash_pipe tool: validates arguments using BashPipeArgsSchema, calls bashPipe core function, formats output with stdout/stderr/exit code, logs, and returns MCP response or error.
    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,
        }
      }
  • Tool registration object defining name 'bash_pipe', description, and input schema (converted from Zod 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),
      },
    ]
  • Zod schema defining input arguments for bash_pipe: array of commands (required), optional workingDir, timeout (default 30s max 60s), and env vars.
    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'),
    })
  • Core bash_pipe implementation: validates each command for safety, joins them with ' | ', and delegates execution to bashExecute helper.
    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
      )
    }
Behavior2/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 mentions that 'Results include both stdout and stderr,' which adds useful context about output behavior. However, it lacks critical details such as security implications (e.g., potential for destructive commands), error handling, or execution limits beyond the timeout parameter. For a tool executing arbitrary Bash commands, this is a significant gap.

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 highly concise and front-loaded: two sentences that directly state the tool's purpose and key behavioral trait (stdout/stderr inclusion). Every sentence earns its place with no wasted words, making it easy for an agent to parse quickly.

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 (high-risk operation), no annotations, and no output schema, the description is incomplete. It covers the basic purpose and output format but misses critical context like safety warnings, permission requirements, or error scenarios. However, it does provide some behavioral transparency (stdout/stderr), preventing a lower score.

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?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description doesn't add any parameter-specific semantics beyond what's in the schema (e.g., it doesn't explain how 'commands' array elements are piped or provide examples). Baseline 3 is appropriate as the schema does the heavy lifting, but no extra value is added.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Execute a sequence of Bash commands piped together.' It specifies the verb ('execute') and resource ('Bash commands'), and distinguishes it from sibling tools like 'bash_execute' by emphasizing piped sequences. However, it doesn't explicitly differentiate from 'execute_command' or other execution tools, keeping it at 4 instead of 5.

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

Usage Guidelines3/5

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

The description implies usage context with 'Allows for powerful command combinations with pipes,' suggesting this tool is for chaining commands via pipes. However, it doesn't explicitly state when to use this versus alternatives like 'bash_execute' or 'execute_command,' nor does it provide exclusions or prerequisites. This leaves some ambiguity for the agent.

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

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/gabrielmaialva33/mcp-filesystem'

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