Skip to main content
Glama

Filesystem MCP Server

by QuantGeekDev
MoveFileTool.ts1.26 kB
import { MCPTool } from "mcp-framework"; import { z } from "zod"; import fs from "fs/promises"; interface MoveFileInput { source: string; destination: string; } class MoveFileTool extends MCPTool<MoveFileInput> { name = "move_file"; description = "Move or rename files and directories. Can move files between directories " + "and rename them in a single operation. If the destination exists, the " + "operation will fail. Works across different directories and can be used " + "for simple renaming within the same directory. Both source and destination must be within allowed directories."; schema = { source: { type: z.string(), description: "Source path of the file or directory to move", }, destination: { type: z.string(), description: "Destination path where to move the file or directory", }, }; async execute(input: MoveFileInput) { try { await fs.rename(input.source, input.destination); return `Successfully moved ${input.source} to ${input.destination}`; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); throw new Error(`Failed to move file: ${errorMessage}`); } } } export default MoveFileTool;

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/QuantGeekDev/mcp-filesystem'

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