Skip to main content
Glama

fs_rmrf

Remove files or directories recursively on remote SSH servers to manage disk space and clean up unwanted data.

Instructions

Removes files or directories recursively

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSSH session ID
pathYesPath to remove

Implementation Reference

  • The handler function `removeRecursive` implements the logic for `fs_rmrf` by interacting with the SFTP session.
    export async function removeRecursive(
      sessionId: string,
      path: string
    ): Promise<boolean> {
      logger.debug('Removing path recursively', { sessionId, path });
      
      const session = sessionManager.getSession(sessionId);
      if (!session) {
        throw new Error(`Session ${sessionId} not found or expired`);
      }
      
      try {
        // Check if path exists and get its type
        const stats = await session.sftp.stat(path);
        
        if ((stats as any).isDirectory && (stats as any).isDirectory()) {
          // Remove directory recursively
          await session.sftp.rmdir(path, true); // recursive = true
        } else {
          // Remove file
          await session.sftp.delete(path);
        }
        
        logger.debug('Path removed successfully', { sessionId, path });
        return true;
      } catch (error) {
        logger.error('Failed to remove path', { sessionId, path, error });
        throw wrapError(
          error,
          ErrorCode.EFS,
          `Failed to remove ${path}. Check if the path exists and you have write permissions.`
        );
      }
    }
  • src/mcp.ts:245-255 (registration)
    Registration of `fs_rmrf` tool in the list of available tools.
      name: 'fs_rmrf',
      description: 'Removes files or directories recursively',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: { type: 'string', description: 'SSH session ID' },
          path: { type: 'string', description: 'Path to remove' }
        },
        required: ['sessionId', 'path']
      }
    },
  • Handling the `fs_rmrf` tool call by invoking `removeRecursive` from `fs-tools.ts`.
    case 'fs_rmrf': {
      const params = FSPathSchema.parse(args);
      const result = await removeRecursive(params.sessionId, params.path);
      logger.info('Path removed', { sessionId: params.sessionId, path: params.path });
      return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action is recursive removal, which implies destructive behavior, but doesn't clarify critical aspects like whether it's irreversible, requires specific permissions, handles symbolic links, or provides confirmation prompts. For a destructive tool, this is a significant gap in safety and operational context.

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 a single, efficient sentence with zero waste. It's front-loaded with the core action and immediately specifies the recursive nature, making it easy to parse. Every word earns its place.

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 tool's destructive nature, lack of annotations, and no output schema, the description is incomplete. It doesn't address safety warnings, error handling, return values, or interaction with SSH sessions. For a recursive removal tool in a system context, this leaves critical gaps for an AI agent.

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%, with clear descriptions for both parameters (sessionId and path). The description doesn't add any meaning beyond what the schema provides—it doesn't explain path syntax, sessionId usage, or edge cases. Baseline 3 is appropriate since the schema does the heavy lifting.

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 ('Removes') and target ('files or directories recursively'), which is specific and unambiguous. It doesn't explicitly differentiate from sibling tools like fs_rename or fs_write, but the verb 'removes' inherently distinguishes it from those operations.

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 provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an SSH session), exclusions, or comparisons to other file operations like fs_rename or deleting via proc_exec. This leaves the agent to infer usage context.

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/oaslananka/mcp-ssh-tool'

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