create_directory
Create new directories efficiently with specified paths, optionally enabling recursive parent directory creation for structured file management within the Enhanced Directory Context MCP Server.
Instructions
Create a new directory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Directory path relative to working directory | |
| recursive | No | Create parent directories if needed |
Implementation Reference
- server.js:707-725 (handler)The handler function that implements the create_directory tool. It destructures path and recursive from args, resolves the full path relative to the working directory, creates the directory using fs.mkdir (supporting recursive creation of parents), and returns a success message or throws an MCP error on failure.async handleCreateDirectory(args) { const { path: dirPath, recursive = true } = args; const fullPath = path.resolve(this.workingDirectory, dirPath); try { await fs.mkdir(fullPath, { recursive }); return { content: [ { type: 'text', text: `Directory created: ${dirPath}`, }, ], }; } catch (error) { throw new McpError(ErrorCode.InternalError, `Failed to create directory: ${error.message}`); } }
- server.js:321-335 (schema)Input schema for the create_directory tool, defining 'path' as required string and 'recursive' as optional boolean (default true).inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Directory path relative to working directory', }, recursive: { type: 'boolean', description: 'Create parent directories if needed', default: true, }, }, required: ['path'], },
- server.js:319-336 (registration)Tool registration entry in the ListToolsRequestSchema handler, providing name, description, and inputSchema for create_directory.name: 'create_directory', description: 'Create a new directory', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Directory path relative to working directory', }, recursive: { type: 'boolean', description: 'Create parent directories if needed', default: true, }, }, required: ['path'], }, },
- server.js:488-489 (registration)Registration/dispatch in the CallToolRequestSchema switch statement, routing calls to 'create_directory' to the handleCreateDirectory handler.case 'create_directory': return await this.handleCreateDirectory(args);