Skip to main content
Glama
g0t4

mcp-server-commands

by g0t4

run_command

Execute Linux commands on a machine to run scripts, manage files, or process input through STDIN from a specified working directory.

Instructions

Run a command on this linux machine

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesCommand with args
workdirNoOptional, current working directory
stdinNoOptional, text to pipe into the command's STDIN. For example, pass a python script to python3. Or, pass text for a new file to the cat command to create it!

Implementation Reference

  • The core handler function `runCommand` that parses args, executes the shell command using `execute` (which uses child_process.exec or execFileWithInput), handles workdir and stdin, catches errors, and returns formatted CallToolResult.
    export type RunCommandArgs = Record<string, unknown> | undefined;
    export async function runCommand(args: RunCommandArgs): Promise<CallToolResult> {
    
        const command = args?.command as string;
        if (!command) {
            const message = "Command is required, current value: " + command;
            return {
                isError: true,
                content: [{ type: "text", text: message }],
            };
        }
    
        const options: ObjectEncodingOptions & ExecOptions = { encoding: "utf8" };
        if (args?.workdir) {
            options.cwd = String(args.workdir);
        }
    
        const stdin = args?.stdin as string;
    
        try {
            const result = await execute(command, stdin, options);
            return {
                content: messagesFor(result),
            };
        } catch (error) {
            // PRN do I want to differentiate non-command related error (i.e. if messagesFor blows up
            //   or presumably if smth else goes wrong with the node code in exec that isn't command related
            //   if so, write a test first
    
            // console.log("ERROR_runCommand", error);
            // ExecException (error + stdout/stderr) merged
            // - IIUC this happens on uncaught failures
            // - but if you catch an exec() promise failure (or use exec's callback) => you get separated values: error, stdout, stderr
            // - which is why I mirror this response type in my reject(error) calls
            //
            // 'error' example:
            // code: 127,
            // killed: false,
            // signal: null,
            // cmd: 'nonexistentcommand',
            // stdout: '',
            // stderr: '/bin/sh: nonexistentcommand: command not found\n'
    
            const response = {
                isError: true,
                content: messagesFor(error as ExecResult),
            };
            always_log("WARN: run_command failed", response);
            return response;
        }
    }
  • The input schema definition for the run_command tool, including properties for command (required), workdir, and stdin.
        name: "run_command",
        description:
            "Run a command on this " + os.platform() + " machine",
        inputSchema: {
            type: "object",
            properties: {
                command: {
                    type: "string",
                    description: "Command with args",
                },
                workdir: {
                    // previous run_command calls can probe the filesystem and find paths to change to
                    type: "string",
                    description:
                        "Optional, current working directory",
                },
                stdin: {
                    type: "string",
                    description:
                        "Optional, text to pipe into the command's STDIN. For example, pass a python script to python3. Or, pass text for a new file to the cat command to create it!",
                },
                // args to consider:
                // - env - obscure cases where command takes a param only via an env var?
                // - timeout - lets just hard code this for now
            },
            required: ["command"],
        },
    },
  • src/tools.ts:11-62 (registration)
    The `reisterTools` function that registers the run_command tool on the MCP server by handling ListToolsRequestSchema (listing the tool with schema) and CallToolRequestSchema (dispatching calls to runCommand based on name).
    export function reisterTools(server: Server) {
        server.setRequestHandler(ListToolsRequestSchema, async () => {
            verbose_log("INFO: ListTools");
            return {
                tools: [
                    {
                        name: "run_command",
                        description:
                            "Run a command on this " + os.platform() + " machine",
                        inputSchema: {
                            type: "object",
                            properties: {
                                command: {
                                    type: "string",
                                    description: "Command with args",
                                },
                                workdir: {
                                    // previous run_command calls can probe the filesystem and find paths to change to
                                    type: "string",
                                    description:
                                        "Optional, current working directory",
                                },
                                stdin: {
                                    type: "string",
                                    description:
                                        "Optional, text to pipe into the command's STDIN. For example, pass a python script to python3. Or, pass text for a new file to the cat command to create it!",
                                },
                                // args to consider:
                                // - env - obscure cases where command takes a param only via an env var?
                                // - timeout - lets just hard code this for now
                            },
                            required: ["command"],
                        },
                    },
                ],
            };
        });
    
        server.setRequestHandler(
            CallToolRequestSchema,
            async (request): Promise<CallToolResult> => {
                verbose_log("INFO: ToolRequest", request);
                switch (request.params.name) {
                    case "run_command": {
                        return await runCommand(request.params.arguments);
                    }
                    default:
                        throw new Error("Unknown tool");
                }
            }
        );
    }
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 mentions execution on a Linux machine but fails to address critical aspects like security implications, permission requirements, side effects (e.g., file modifications), error handling, or output format. This is inadequate for a tool that executes arbitrary 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 extremely concise—a single sentence with no wasted words—and front-loaded with the core purpose. It efficiently communicates the essential function without unnecessary elaboration.

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 complexity of executing arbitrary commands on a Linux system, the description is insufficient. With no annotations, no output schema, and a lack of behavioral details (e.g., safety, permissions, output handling), it leaves significant gaps for an AI agent to understand tool behavior and risks.

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%, meaning all parameters are documented in the schema itself. The description adds no additional parameter semantics beyond what the schema provides, such as examples or constraints not captured in schema descriptions. This meets the baseline for high schema coverage.

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 ('Run a command') and target ('on this linux machine'), providing a specific verb+resource combination. However, since there are no sibling tools mentioned, it cannot demonstrate differentiation from alternatives, which prevents a perfect score 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 offers no guidance on when to use this tool versus alternatives, prerequisites, or contextual constraints. It simply states what the tool does without any usage instructions, leaving the agent to infer appropriate scenarios.

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/g0t4/mcp-server-commands'

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