Skip to main content
Glama
ngh1105
by ngh1105

genlayer

Execute CLI commands with full access to perform state-changing operations on your project. Configure working directory, environment variables, and timeout.

Instructions

Run the GenLayer CLI with full command access. This can perform state-changing operations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argsNoArguments passed to the command.
cwdNoWorking directory for the command. Defaults to the MCP server cwd.
timeoutMsNoTimeout in milliseconds. Defaults to 120000.
envNoExtra environment variables merged over the MCP server environment.

Implementation Reference

  • src/index.ts:484-489 (registration)
    Registration of the 'genlayer' tool via server.tool(), linking it to the runCommand('genlayer', ...) handler.
    server.tool(
      "genlayer",
      "Run the GenLayer CLI with full command access. This can perform state-changing operations.",
      commandInputShape,
      async (input) => textResponse(await runCommand("genlayer", input))
    );
  • The runCommand function that executes the 'genlayer' CLI command via child_process.spawn, handling args, env, timeout, and collecting stdout/stderr.
    async function runCommand(
      command: string,
      input: z.infer<typeof commandInputSchema>
    ): Promise<CommandResult> {
      const cwd = input.cwd ?? processCwd();
      const childEnv = {
        ...processEnv,
        ...(input.env ?? {})
      };
    
      return await new Promise<CommandResult>((resolve) => {
        let stdout = "";
        let stderr = "";
        let settled = false;
        let timedOut = false;
    
        const resolvedCommand = resolveCommand(command, childEnv);
        const child = spawn(resolvedCommand.command, [...resolvedCommand.argsPrefix, ...input.args], {
          cwd,
          env: childEnv,
          shell: false,
          windowsHide: true
        });
    
        const timeout = setTimeout(() => {
          timedOut = true;
          child.kill("SIGTERM");
        }, input.timeoutMs);
    
        child.stdout?.setEncoding("utf8");
        child.stderr?.setEncoding("utf8");
    
        child.stdout?.on("data", (chunk: string) => {
          stdout += chunk;
        });
    
        child.stderr?.on("data", (chunk: string) => {
          stderr += chunk;
        });
    
        child.on("error", (error) => {
          if (settled) {
            return;
          }
    
          settled = true;
          clearTimeout(timeout);
          resolve({
            command,
            resolvedCommand: resolvedCommand.command,
            args: input.args,
            cwd,
            exitCode: null,
            signal: null,
            stdout,
            stderr,
            timedOut,
            error: error.message
          });
        });
    
        child.on("close", (exitCode, signal) => {
          if (settled) {
            return;
          }
    
          settled = true;
          clearTimeout(timeout);
          resolve({
            command,
            resolvedCommand: resolvedCommand.command,
            args: input.args,
            cwd,
            exitCode,
            signal,
            stdout,
            stderr,
            timedOut
          });
        });
      });
    }
  • Input schema (commandInputShape) defining the args, cwd, timeoutMs, and env parameters accepted by the genlayer tool.
    const commandInputShape = {
      args: z.array(z.string()).default([]).describe("Arguments passed to the command."),
      cwd: z.string().optional().describe("Working directory for the command. Defaults to the MCP server cwd."),
      timeoutMs: z
        .number()
        .int()
        .positive()
        .max(30 * 60 * 1000)
        .default(120_000)
        .describe("Timeout in milliseconds. Defaults to 120000."),
      env: z
        .record(z.string())
        .optional()
        .describe("Extra environment variables merged over the MCP server environment.")
    };
  • resolveCommand helper that resolves the CLI command path, handling Windows .cmd scripts and npm bin scripts.
    function resolveCommand(command: string, env: NodeJS.ProcessEnv): ResolvedCommand {
      const commandPath = process.platform === "win32" ? findWindowsCommand(command, env) : command;
    
      if (process.platform === "win32" && commandPath?.toLowerCase().endsWith(".cmd")) {
        const npmBin = resolveNpmBinScript(command, commandPath);
        if (npmBin) {
          return {
            command: process.execPath,
            argsPrefix: [npmBin]
          };
        }
    
        return {
          command: "cmd.exe",
          argsPrefix: ["/d", "/s", "/c", commandPath]
        };
      }
    
      return {
        command: commandPath ?? command,
        argsPrefix: []
      };
    }
  • findWindowsCommand helper that locates a command on Windows by searching PATH entries with common extensions.
    function findWindowsCommand(command: string, env: NodeJS.ProcessEnv): string | undefined {
      if (command.includes("\\") || command.includes("/")) {
        return existsSync(command) ? command : undefined;
      }
    
      const pathValue = env.Path ?? env.PATH ?? "";
      const pathEntries = pathValue.split(delimiter).filter(Boolean);
      const extensions = [".exe", ".cmd", ".bat", ".ps1", ""];
    
      for (const extension of extensions) {
        for (const pathEntry of pathEntries) {
          const candidate = join(pathEntry, `${command}${extension}`);
          if (existsSync(candidate)) {
            if (isBrokenPythonScriptsLauncher(candidate)) {
              continue;
            }
    
            return candidate;
          }
        }
      }
    
      return undefined;
    }
Behavior3/5

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

The description notes that it 'can perform state-changing operations', which is a key behavioral trait. However, no annotations are provided, and the description lacks details on security, error handling, or resource impact.

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

Conciseness4/5

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

The description is very concise with two sentences, no fluff. While efficient, it could include a bit more context without becoming verbose.

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 tool's complexity (4 parameters, no output schema, no annotations), the description is adequate but not fully complete. It does not describe return values or potential side effects beyond stating state-changing operations.

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 coverage is 100% with clear parameter descriptions. The description does not add significant meaning beyond the schema, meeting the baseline for this dimension.

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 'Run the GenLayer CLI' with 'full command access', distinguishing it from sibling tools like genlayer_deploy and genvm_lint. However, it is somewhat broad without specifying typical commands.

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?

No guidance is provided on when to use this tool versus the sibling tools. There is no mention of scenarios or alternatives, leaving the agent to infer usage.

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/ngh1105/genlayer-cli-mcp'

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