Skip to main content
Glama

check_path

Validate file path safety for write or delete operations to protect sensitive system files and directories from unintended modifications.

Instructions

Check if a file path operation is safe. Protects .env, .ssh/, .aws/credentials, private keys, /etc/passwd, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile path to check
operationYesOperation type

Implementation Reference

  • The 'checkPath' method is defined within the ShellWard class in src/core/engine.ts. It validates a given file path against a list of protected paths, returning a result indicating whether the path is allowed or blocked based on the configured security mode.
    checkPath(path: string, operation: 'write' | 'delete', toolName?: string): CheckResult {
      const enforce = this.config.mode === 'enforce'
      const normalizedPath = normalizePath(path)
    
      for (const rule of PROTECTED_PATHS) {
        if (rule.pattern.test(normalizedPath)) {
          const desc = this.locale === 'zh' ? rule.description_zh : rule.description_en
          const reason = this.locale === 'zh'
            ? `禁止操作受保护路径: ${path}\n原因: ${desc}`
            : `Protected path blocked: ${path}\nReason: ${desc}`
          this.log.write({
            level: 'HIGH',
            layer: 'L3',
            action: enforce ? 'block' : 'detect',
            detail: reason,
            tool: toolName,
            pattern: rule.id,
          })
          return { allowed: false, level: 'HIGH', reason, ruleId: rule.id }
        }
      }
      return { allowed: true }
    }
Behavior3/5

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

No annotations provided, so description carries full burden. Adds valuable context by enumerating specific protected resources (.aws/credentials, /etc/passwd), revealing what constitutes 'unsafe'. However, omits whether it returns boolean, risk score, or blocks operations, and doesn't clarify if validation is advisory or enforceative.

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?

Two efficient sentences with zero waste. Front-loaded with the core action 'Check if...', followed by specific exemplars of protected resources. Every word earns its place.

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 2 parameters with 100% schema coverage and no output schema, description adequately covers intent and domain-specific scope (enumerating sensitive paths). Missing explicit return value semantics, but 'Protects' implies validation logic sufficient for tool selection.

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 descriptions ('File path to check', 'Operation type'). Description mentions 'file path operation' which aligns with parameters but adds no syntax examples, path format requirements, or semantic details beyond the schema definitions.

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?

Specific verb 'Check' with clear resource 'file path operation' and scope (safety validation). Lists concrete protected targets (.env, .ssh/, etc.) that clearly distinguish it from siblings like check_command ( shell commands) and check_injection (code injections).

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?

Implies usage context through security focus (use before write/delete operations on sensitive paths), but lacks explicit 'when to use vs alternatives' guidance comparing to sibling security tools like scan_data or security_status.

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