Skip to main content
Glama
dazeb

Markdown Downloader

download_markdown

Convert webpages to markdown files by providing a URL, with options to save in a specified subdirectory and generate date-stamped filenames automatically.

Instructions

Download a webpage as markdown using r.jina.ai

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subdirectoryNoOptional subdirectory to save the file in
urlYesURL of the webpage to download

Implementation Reference

  • The execution handler for the 'download_markdown' tool. Validates URL input, prepends r.jina.ai, downloads markdown with axios, generates a sanitized filename with date, saves to configurable directory (optionally subdirectory), and returns success/error message.
    if (request.params.name === 'download_markdown') {
      const url = request.params.arguments?.url;
      const subdirectory = request.params.arguments?.subdirectory;
    
      if (!url || typeof url !== 'string') {
        throw new McpError(
          ErrorCode.InvalidParams,
          'A valid URL must be provided'
        );
      }
    
      try {
        // Get current download directory
        const config = getConfig();
    
        // Prepend r.jina.ai to the URL
        const jinaUrl = `https://r.jina.ai/${url}`;
    
        // Download markdown
        const response = await axios.get(jinaUrl, {
          headers: {
            'Accept': 'text/markdown'
          }
        });
    
        // Generate filename
        const filename = generateFilename(url);
        let filepath = path.join(config.downloadDirectory, filename);
    
        // If subdirectory is specified, use it
        if (subdirectory && typeof subdirectory === 'string') {
          filepath = path.join(config.downloadDirectory, subdirectory, filename);
          fs.ensureDirSync(path.dirname(filepath));
        }
    
        // Save markdown file
        await fs.writeFile(filepath, response.data);
    
        return {
          content: [
            {
              type: 'text',
              text: `Markdown downloaded and saved as ${filename} in ${path.dirname(filepath)}`
            }
          ]
        };
      } catch (downloadError) {
        console.error('Download error:', downloadError);
        return {
          content: [
            {
              type: 'text',
              text: `Failed to download markdown: ${downloadError instanceof Error ? downloadError.message : 'Unknown error'}`
            }
          ],
          isError: true
        };
      }
    }
  • src/index.ts:115-131 (registration)
    Registration of the 'download_markdown' tool in the ListTools response, including its description and input schema definition.
      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']
      }
    },
  • Input schema definition for the 'download_markdown' tool, specifying required 'url' and optional 'subdirectory'.
    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']
    }
  • Helper function to generate a sanitized filename from the URL with a datestamp suffix for the markdown file.
    function generateFilename(url: string): string {
      const sanitizedUrl = sanitizeFilename(url);
      const datestamp = new Date().toISOString().split('T')[0].replace(/-/g, '');
      return `${sanitizedUrl}-${datestamp}.md`;
    }
  • Helper function to sanitize URL into a valid filename by removing protocol and replacing special chars.
    function sanitizeFilename(url: string): string {
      // Remove protocol, replace non-alphanumeric chars with dash
      return url
        .replace(/^https?:\/\//, '')
        .replace(/[^a-z0-9]/gi, '-')
        .toLowerCase();
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool downloads a webpage as markdown, implying a read operation that fetches and converts content, but lacks details on permissions, rate limits, error handling, or what happens after download (e.g., where files are saved). This is a significant gap for a tool with potential network and file system interactions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It front-loads the core purpose ('download a webpage as markdown') and includes only essential technical detail ('using r.jina.ai'). Every word earns its place, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (involving web scraping and file output), lack of annotations, and no output schema, the description is incomplete. It doesn't explain the download process (e.g., success/failure states, file naming conventions, or markdown conversion quality), leaving the agent with insufficient context for reliable use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear descriptions for both parameters: 'url' as the webpage URL and 'subdirectory' as an optional save location. The description doesn't add any meaning beyond this, such as URL format requirements or subdirectory path examples. Given the high schema coverage, a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('download a webpage as markdown') and the resource ('webpage'), using the specific verb 'download' and specifying the output format 'markdown'. It also mentions the service used ('r.jina.ai'), which adds technical context. However, it doesn't explicitly distinguish this tool from its siblings (e.g., list_downloaded_files), which would require a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a valid URL), exclusions (e.g., unsupported webpage types), or comparisons to sibling tools like create_subdirectory or get_download_directory. This leaves the agent without context for tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dazeb/markdown-downloader'

If you have feedback or need assistance with the MCP directory API, please join our Discord server