Skip to main content
Glama

terminal

Execute shell commands to run scripts, manage files, and automate system tasks directly from an MCP client, returning stdout, stderr, and exit codes.

Instructions

Run a shell command and return its output.

Returns a single string containing stdout, and stderr when present. Non-zero exit codes are reported at the end of the output so the caller can detect failures without parsing exit status separately.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesThe shell command to execute. Runs via /bin/sh -c on Unix or cmd /c on Windows. Pipes, redirects, and shell built-ins are supported. Commands time out after 30 seconds.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • server.py:13-55 (handler)
    The terminal function is the handler for the 'terminal' tool, executing shell commands via subprocess.run.
    def terminal(
        command: Annotated[
            str,
            Field(
                description=(
                    "The shell command to execute. Runs via /bin/sh -c on Unix or cmd /c "
                    "on Windows. Pipes, redirects, and shell built-ins are supported. "
                    "Commands time out after 30 seconds."
                )
            ),
        ],
    ) -> str:
        """Run a shell command and return its output.
    
        Returns a single string containing stdout, and stderr when present.
        Non-zero exit codes are reported at the end of the output so the caller
        can detect failures without parsing exit status separately.
        """
        try:
            result = subprocess.run(
                command,
                shell=True,
                capture_output=True,
                text=True,
                timeout=30,
            )
        except subprocess.TimeoutExpired:
            return "Error: command timed out after 30 seconds."
        except Exception as exc:  # noqa: BLE001
            return f"Error: failed to execute command — {exc}"
    
        parts: list[str] = []
    
        if result.stdout:
            parts.append(result.stdout.rstrip())
    
        if result.stderr:
            parts.append(f"STDERR:\n{result.stderr.rstrip()}")
    
        if result.returncode != 0:
            parts.append(f"Exit code: {result.returncode}")
    
        return "\n".join(parts) if parts else "(no output)"
  • server.py:12-12 (registration)
    Registration of the 'terminal' tool using the FastMCP decorator.
    @mcp.tool()
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. It transparently explains output formatting (stdout/stderr combined, exit codes appended) but omits safety warnings, destructive potential, or execution boundaries that would be critical for an arbitrary shell execution tool.

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?

Three tightly constructed sentences with no wasted words. The description front-loads the core action, followed by output structure specifics and error-handling behavior. Every sentence provides distinct value.

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

Completeness4/5

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

Given the simple single-parameter input and implied output schema, the description adequately covers return value behavior. Minor gap: lacks safety warnings expected for shell execution tools, though the mechanics are fully documented.

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%, documenting the command parameter, timeout behavior, and shell environments. The description focuses on output behavior rather than parameter semantics, meeting the baseline expectation without adding redundant param details.

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 opens with a specific verb ('Run') and resource ('shell command'), clearly stating the tool executes commands and returns output. Without sibling tools, no differentiation is required, and the purpose is immediately obvious.

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?

No explicit 'when to use' guidance is provided, though the description explains how to interpret results (non-zero exit codes appended to output). This provides implicit usage guidance for error detection but lacks context about when shell execution is appropriate versus alternatives.

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/joandiazcapell/shellserver'

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