Skip to main content
Glama

fs_rename

Renames or moves files and directories on remote servers via SSH to organize or relocate data.

Instructions

Renames or moves a file/directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSSH session ID
fromYesSource path
toYesDestination path

Implementation Reference

  • The handler function that executes the rename operation using the SFTP session.
    export async function renameFile(
      sessionId: string,
      from: string,
      to: string
    ): Promise<boolean> {
      logger.debug('Renaming file', { sessionId, from, to });
      
      const session = sessionManager.getSession(sessionId);
      if (!session) {
        throw new Error(`Session ${sessionId} not found or expired`);
      }
      
      try {
        await session.sftp.rename(from, to);
        logger.debug('File renamed successfully', { sessionId, from, to });
        return true;
      } catch (error) {
        logger.error('Failed to rename file', { sessionId, from, to, error });
        throw wrapError(
          error,
          ErrorCode.EFS,
          `Failed to rename ${from} to ${to}. Check if the source exists and destination is writable.`
        );
      }
    }
  • The schema defining the expected input for the fs_rename tool.
    export const FSRenameSchema = z.object({
      sessionId: z.string().min(1),
      from: z.string().min(1),
      to: z.string().min(1)
    });
  • src/mcp.ts:257-268 (registration)
    Registration of the 'fs_rename' tool in the MCP server's tool list.
      name: 'fs_rename',
      description: 'Renames or moves a file/directory',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: { type: 'string', description: 'SSH session ID' },
          from: { type: 'string', description: 'Source path' },
          to: { type: 'string', description: 'Destination path' }
        },
        required: ['sessionId', 'from', 'to']
      }
    },
  • Tool call handler case for 'fs_rename', which validates inputs and calls the renameFile function.
    case 'fs_rename': {
      const params = FSRenameSchema.parse(args);
      const result = await renameFile(params.sessionId, params.from, params.to);
      logger.info('Path renamed', { sessionId: params.sessionId, from: params.from, to: params.to });
      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 full burden for behavioral disclosure. It states the action but doesn't mention critical behaviors: whether it overwrites existing files, requires specific permissions, handles symbolic links, or provides error messages for invalid paths. This leaves significant gaps for a mutation 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?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core action and resource, making it immediately understandable 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?

For a mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens on success/failure, whether the operation is atomic, or how it interacts with other file operations. Given the complexity of file system operations, more behavioral context is needed.

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%, so all parameters are documented in the schema. The description doesn't add any additional meaning about the parameters beyond what the schema provides (e.g., explaining path formats or session requirements). 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 ('renames or moves') and resource ('a file/directory'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like fs_list or fs_rmrf, but the verb 'renames or moves' is specific enough to distinguish it from other file 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 like fs_write for creating new files or fs_rmrf for deletion. There's no mention of prerequisites (e.g., needing an active SSH session) or when moving versus renaming is appropriate.

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