create_subdirectory
Organize downloaded markdown files by creating a new subdirectory in the root folder. Specify the directory name to efficiently structure and manage stored webpage content.
Instructions
Create a new subdirectory in the root download folder
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the subdirectory to create |
Input Schema (JSON Schema)
{
"properties": {
"name": {
"description": "Name of the subdirectory to create",
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
}
Implementation Reference
- src/index.ts:333-371 (handler)Handler function for the 'create_subdirectory' tool. Validates the input name parameter, retrieves the download directory from config, constructs the full path, creates the subdirectory using fs.ensureDir, and returns a success message or error.// Create subdirectory if (request.params.name === 'create_subdirectory') { const subdirectoryName = request.params.arguments?.name; if (!subdirectoryName || typeof subdirectoryName !== 'string') { throw new McpError( ErrorCode.InvalidParams, 'A valid subdirectory name must be provided' ); } try { const config = getConfig(); const newSubdirectoryPath = path.join(config.downloadDirectory, subdirectoryName); // Create the subdirectory await fs.ensureDir(newSubdirectoryPath); return { content: [ { type: 'text', text: `Subdirectory created: ${newSubdirectoryPath}` } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; return { content: [ { type: 'text', text: `Failed to create subdirectory: ${errorMessage}` } ], isError: true }; } }
- src/index.ts:170-179 (schema)Input schema definition for the 'create_subdirectory' tool, specifying the required 'name' parameter as a string.inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the subdirectory to create' } }, required: ['name'] }
- src/index.ts:167-180 (registration)Registration of the 'create_subdirectory' tool in the ListTools response, including name, description, and input schema.{ name: 'create_subdirectory', description: 'Create a new subdirectory in the root download folder', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the subdirectory to create' } }, required: ['name'] } }