move_path
Move or rename a file or directory by providing a source and destination path. Optionally set a workspace root for context.
Instructions
Move or rename a file or directory.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | Source path | |
| destination | Yes | Destination path | |
| workspace_root | No | Workspace root directory (optional) |
Implementation Reference
- src/index.ts:497-503 (handler)Handler for the 'move_path' tool. Resolves source and destination paths using resolveWorkspacePath, ensures the destination directory exists via mkdir with recursive:true, then uses rename() from fs/promises to move/rename the file or directory. Returns a confirmation message with source and destination paths.
case "move_path": { const src = resolveWorkspacePath(a.source as string, a.workspace_root as string | undefined); const dst = resolveWorkspacePath(a.destination as string, a.workspace_root as string | undefined); await mkdir(dirname(dst), { recursive: true }); await rename(src, dst); return { content: [{ type: "text", text: `Moved: ${src} → ${dst}` }] }; } - src/index.ts:247-258 (schema)Schema definition for 'move_path' tool. Defines inputSchema with three properties: 'source' (string, required), 'destination' (string, required), and 'workspace_root' (string, optional). The tool is described as 'Move or rename a file or directory.'
name: "move_path", description: "Move or rename a file or directory.", inputSchema: { type: "object", properties: { source: { type: "string", description: "Source path" }, destination: { type: "string", description: "Destination path" }, workspace_root: { type: "string", description: "Workspace root directory (optional)" }, }, required: ["source", "destination"], }, }, - src/index.ts:59-63 (helper)Helper function resolveWorkspacePath used by the move_path handler. If the path starts with '/' (Unix absolute) or a drive letter (Windows absolute), it returns it as-is. Otherwise it joins the workspace_root (or cwd) with the relative path and resolves it to an absolute path.
function resolveWorkspacePath(filePath: string, workspaceRoot?: string): string { if (filePath.startsWith("/") || /^[A-Za-z]:/.test(filePath)) return filePath; const base = workspaceRoot ?? process.cwd(); return resolve(join(base, filePath)); } - src/index.ts:426-426 (registration)Registration of all tools via ListToolsRequestSchema handler. The TOOLS array (which includes 'move_path') is returned when the client requests the list of available tools.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));