Skip to main content
Glama

check_command

Verify shell command safety by detecting dangerous patterns like rm -rf, reverse shells, and fork bombs before execution.

Instructions

Check if a shell command is safe to execute. Detects rm -rf, reverse shells, fork bombs, curl|sh, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesThe shell command to check

Implementation Reference

  • The implementation of the checkCommand logic within the ShellWard class. It splits the command into parts and checks each part against dangerous command patterns.
    checkCommand(cmd: string, toolName?: string): CheckResult {
      const enforce = this.config.mode === 'enforce'
      const parts = splitCommands(cmd)
    
      for (const part of parts) {
        for (const rule of DANGEROUS_COMMANDS) {
          if (rule.pattern.test(part)) {
            const desc = this.locale === 'zh' ? rule.description_zh : rule.description_en
            const reason = this.locale === 'zh'
              ? `检测到危险命令: ${truncate(part, 80)}\n原因: ${desc}`
              : `Dangerous command: ${truncate(part, 80)}\nReason: ${desc}`
            this.log.write({
              level: 'CRITICAL',
              layer: 'L3',
              action: enforce ? 'block' : 'detect',
              detail: reason,
              tool: toolName,
              pattern: rule.id,
            })
            return { allowed: false, level: 'CRITICAL', reason, ruleId: rule.id }
          }
        }
      }
      return { allowed: true }
    }
Behavior3/5

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

With no annotations provided, the description carries the full transparency burden. It discloses detection capabilities (what patterns it finds) but omits critical behavioral traits: return value/format (boolean vs risk score?), whether the command is actually executed (presumably read-only analysis but not stated), and side effects. Adequate but missing execution safety guarantees expected for a security 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?

Perfectly compact: two sentences with zero waste. First sentence establishes core purpose; second provides concrete scoping examples. Every word earns its place and no repetition of schema details.

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?

For a single-parameter analysis tool, the description covers the input side well but has clear gaps: with no output schema provided, it fails to describe what the tool returns (safe/unsafe boolean? detailed breakdown?). Also missing explicit confirmation that this is a read-only analysis tool, which is crucial context given the sensitive nature of shell execution.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% ('The shell command to check'), setting a baseline of 3. The description adds semantic value by implying via threat examples that the parameter accepts complex shell syntax and dangerous command strings, helping the agent understand what constitutes a valid input beyond the basic string type.

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?

Excellent specificity: verb 'Check' + resource 'shell command' + intent 'safe to execute'. The enumerated threat examples (rm -rf, reverse shells, fork bombs, curl|sh) clearly distinguish this from siblings like check_injection or check_path by scoping it specifically to shell command safety analysis.

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 threat examples provide implied usage context (use when validating shell commands containing these patterns), but lacks explicit guidance on when to select this over siblings like check_injection or check_path. No 'when-not-to-use' or alternative recommendations are stated.

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/jnMetaCode/shellward'

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