Skip to main content
Glama

Filesystem MCP Server

by QuantGeekDev
CreateDirectoryTool.ts1.12 kB
import { MCPTool } from "mcp-framework"; import { z } from "zod"; import fs from "fs/promises"; interface CreateDirectoryInput { path: string; } class CreateDirectoryTool extends MCPTool<CreateDirectoryInput> { name = "create_directory"; description = "Create a new directory or ensure a directory exists. Can create multiple " + "nested directories in one operation. If the directory already exists, " + "this operation will succeed silently. Perfect for setting up directory " + "structures for projects or ensuring required paths exist. Only works within allowed directories."; schema = { path: { type: z.string(), description: "Path where to create the directory", }, }; async execute(input: CreateDirectoryInput) { try { await fs.mkdir(input.path, { recursive: true }); return `Successfully created directory ${input.path}`; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); throw new Error(`Failed to create directory: ${errorMessage}`); } } } export default CreateDirectoryTool;

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