Skip to main content
Glama
gunjanjp

Linux Bash MCP Server

by gunjanjp

create_bash_script

Generate bash script files with custom content and set execution permissions for automating Linux tasks in WSL2 environments on Windows.

Instructions

Create a bash script file with specified content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scriptPathYesPath where to create the script file
contentYesContent of the bash script
executableNoMake the script executable (optional, defaults to true)

Implementation Reference

  • The core handler function for the 'create_bash_script' tool. It validates inputs, escapes the script content, writes it to the specified path in the WSL Linux environment using 'echo > file', makes it executable if requested via 'chmod +x', and returns a JSON-formatted success or error response.
    async createBashScript(args) {
      const { scriptPath, content, executable = true } = args;
      
      if (!scriptPath || typeof scriptPath !== "string") {
        throw new Error("Script path is required and must be a string");
      }
      
      if (!content || typeof content !== "string") {
        throw new Error("Script content is required and must be a string");
      }
    
      if (!this.wslDistribution) {
        throw new Error("WSL distribution not configured");
      }
    
      try {
        // Escape content for bash
        const escapedContent = content.replace(/'/g, "'\"'\"'");
        
        // Create the script file
        const createCommand = `wsl -d ${this.wslDistribution} -- bash -c "echo '${escapedContent}' > '${scriptPath}'"`;
        
        console.error(`[DEBUG] Creating script: ${scriptPath}`);
        
        await execAsync(createCommand);
        
        // Make executable if requested
        if (executable) {
          const chmodCommand = `wsl -d ${this.wslDistribution} -- chmod +x '${scriptPath}'`;
          await execAsync(chmodCommand);
        }
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({
                success: true,
                scriptPath: scriptPath,
                executable: executable,
                wslDistribution: this.wslDistribution,
                message: "Script created successfully",
                timestamp: new Date().toISOString()
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({
                success: false,
                scriptPath: scriptPath,
                wslDistribution: this.wslDistribution,
                error: error.message,
                timestamp: new Date().toISOString()
              }, null, 2),
            },
          ],
        };
      }
    }
  • The input schema definition for the 'create_bash_script' tool, specifying required parameters (scriptPath, content) and optional executable flag.
    inputSchema: {
      type: "object",
      properties: {
        scriptPath: {
          type: "string",
          description: "Path where to create the script file",
        },
        content: {
          type: "string",
          description: "Content of the bash script",
        },
        executable: {
          type: "boolean",
          description: "Make the script executable (optional, defaults to true)",
          default: true
        }
      },
      required: ["scriptPath", "content"],
    },
  • src/index.js:214-236 (registration)
    The tool registration entry in the ListTools response, including name, description, and input schema.
    {
      name: "create_bash_script",
      description: "Create a bash script file with specified content",
      inputSchema: {
        type: "object",
        properties: {
          scriptPath: {
            type: "string",
            description: "Path where to create the script file",
          },
          content: {
            type: "string",
            description: "Content of the bash script",
          },
          executable: {
            type: "boolean",
            description: "Make the script executable (optional, defaults to true)",
            default: true
          }
        },
        required: ["scriptPath", "content"],
      },
    },
  • src/index.js:286-287 (registration)
    The dispatch case in the CallToolRequestHandler switch statement that routes calls to the createBashScript handler.
    case "create_bash_script":
      return await this.createBashScript(args);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool creates a file but doesn't mention critical behaviors: whether it overwrites existing files, requires specific permissions, handles errors (e.g., invalid paths), or what happens on success/failure. For a file creation tool with zero annotation coverage, this is a significant gap in transparency.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse. Every word earns its place, achieving optimal conciseness for this level of detail.

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

Completeness2/5

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

Given the tool's complexity (file creation with potential side effects), lack of annotations, and no output schema, the description is incomplete. It doesn't address key contextual aspects: what the tool returns (e.g., success confirmation, file path), error handling, or security implications (e.g., script injection risks). For a mutation tool with no structured safety hints, more detail is needed.

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%, with clear documentation for all three parameters (scriptPath, content, executable). The description adds no additional meaning beyond the schema, such as format examples or constraints (e.g., path must be absolute). Baseline 3 is appropriate since the schema adequately defines parameters, but the description doesn't enhance understanding.

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 action ('Create') and resource ('bash script file') with the specific purpose of adding content. It distinguishes from siblings like execute_bash_command or execute_bash_script by focusing on file creation rather than execution. However, it doesn't explicitly differentiate from other potential file creation 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 Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., file system permissions), when not to use it (e.g., for non-bash scripts), or refer to sibling tools like execute_bash_script for running scripts after creation. This lack of contextual direction leaves the agent with minimal usage cues.

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/gunjanjp/linuxshell-mcp'

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