create_directory
Create new directories in your file system, including parent directories when needed, to organize project files and structure.
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 main handler function that implements the create_directory tool. It resolves the directory path relative to the working directory, creates the directory using fs.mkdir (with optional recursive creation), and returns a success message or throws an error.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-334 (schema)Input schema definition for the create_directory tool, specifying the path parameter (required) and optional recursive flag.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:318-336 (registration)Tool registration in the ListToolsRequestSchema response, defining name, description, and input schema.{ 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)Switch case in CallToolRequestSchema handler that routes create_directory calls to the handler method.case 'create_directory': return await this.handleCreateDirectory(args);