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
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | SSH session ID | |
| from | Yes | Source path | |
| to | Yes | Destination path |
Implementation Reference
- src/fs-tools.ts:280-304 (handler)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.` ); } } - src/types.ts:275-280 (schema)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'] } }, - src/mcp.ts:468-473 (handler)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) }] }; }