create_directory
Create a new directory at a specified path to organize files within the file system.
Instructions
Create a new directory
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the directory to create |
Implementation Reference
- src/index.ts:587-597 (handler)The handler case for the 'create_directory' tool. It validates the path using validatePath, calls fsPromises.mkdir with recursive:true, and returns a success response.
case "create_directory": { const validPath = await validatePath(args.path); await fsPromises.mkdir(validPath, { recursive: true }); return { toolResult: { success: true, content: [{ type: "text", text: `Directory created: ${args.path}` }], message: `Created directory: ${args.path}` } }; } - src/index.ts:346-358 (schema)The tool registration with inputSchema for 'create_directory'. Defines a single required 'path' string parameter.
{ name: "create_directory", description: "Create a new directory", inputSchema: { type: "object", properties: { path: { type: "string", description: "Path to the directory to create" } }, required: ["path"] } - src/index.ts:277-387 (registration)The ListToolsRequestSchema handler that registers all available tools including 'create_directory'.
server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ // Image generation tool { name: "generate_3d_cartoon", description: "Generates a 3D style cartoon image for kids based on the given prompt", inputSchema: { type: "object", properties: { prompt: { type: "string", description: "The prompt describing the 3D cartoon image to generate" }, fileName: { type: "string", description: "The name of the output file (without extension)" } }, required: ["prompt", "fileName"] } }, // File system tools { name: "read_file", description: "Read the contents of a file", inputSchema: { type: "object", properties: { path: { type: "string", description: "Path to the file to read" } }, required: ["path"] } }, { name: "write_file", description: "Write content to a file", inputSchema: { type: "object", properties: { path: { type: "string", description: "Path to the file to write" }, content: { type: "string", description: "Content to write to the file" } }, required: ["path", "content"] } }, { name: "list_directory", description: "List the contents of a directory", inputSchema: { type: "object", properties: { path: { type: "string", description: "Path to the directory to list" } }, required: ["path"] } }, { name: "create_directory", description: "Create a new directory", inputSchema: { type: "object", properties: { path: { type: "string", description: "Path to the directory to create" } }, required: ["path"] } }, { name: "search_files", description: "Search for files matching a pattern", inputSchema: { type: "object", properties: { path: { type: "string", description: "Base directory to search from" }, pattern: { type: "string", description: "Search pattern (glob format)" }, excludePatterns: { type: "array", items: { type: "string" }, description: "Patterns to exclude from search (glob format)" } }, required: ["path", "pattern"] } } ] }; });