set_download_directory
Define the primary local directory where markdown files are saved when downloading webpages via the Markdown Downloader MCP server.
Instructions
Set the main local download folder for markdown files
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| directory | Yes | Full path to the download directory |
Input Schema (JSON Schema)
{
"properties": {
"directory": {
"description": "Full path to the download directory",
"type": "string"
}
},
"required": [
"directory"
],
"type": "object"
}
Implementation Reference
- src/index.ts:279-317 (handler)Handler for the 'set_download_directory' tool. Validates the directory path, ensures it is writable, updates the configuration with the new download directory, saves the config, and returns a success or error message.if (request.params.name === 'set_download_directory') { const directory = request.params.arguments?.directory; if (!directory || typeof directory !== 'string') { throw new McpError( ErrorCode.InvalidParams, 'A valid directory path must be provided' ); } try { // Validate directory exists and is writable await fs.access(directory, fs.constants.W_OK); // Update and save config const config = getConfig(); config.downloadDirectory = directory; saveConfig(config); return { content: [ { type: 'text', text: `Download directory set to: ${directory}` } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; return { content: [ { type: 'text', text: `Failed to set download directory: ${errorMessage}` } ], isError: true }; }
- src/index.ts:146-158 (schema)Schema definition for the 'set_download_directory' tool, including input schema requiring a 'directory' string parameter.name: 'set_download_directory', description: 'Set the main local download folder for markdown files', inputSchema: { type: 'object', properties: { directory: { type: 'string', description: 'Full path to the download directory' } }, required: ['directory'] } },
- src/index.ts:112-182 (registration)Registration of all tools including 'set_download_directory' in the ListToolsRequestSchema handler.this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { name: 'download_markdown', description: 'Download a webpage as markdown using r.jina.ai', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL of the webpage to download' }, subdirectory: { type: 'string', description: 'Optional subdirectory to save the file in' } }, required: ['url'] } }, { name: 'list_downloaded_files', description: 'List all downloaded markdown files', inputSchema: { type: 'object', properties: { subdirectory: { type: 'string', description: 'Optional subdirectory to list files from' } } } }, { name: 'set_download_directory', description: 'Set the main local download folder for markdown files', inputSchema: { type: 'object', properties: { directory: { type: 'string', description: 'Full path to the download directory' } }, required: ['directory'] } }, { name: 'get_download_directory', description: 'Get the current download directory', inputSchema: { type: 'object', properties: {} } }, { 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'] } } ] }));