Skip to main content
Glama

curl_download

Download files from URLs using curl with options to specify output filenames, resume partial downloads, follow redirects, and set request timeouts.

Instructions

Download a file using curl

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
follow_redirectsNoWhether to follow redirects
output_filenameNoOutput filename (if not provided, will use remote filename)
resumeNoResume partial download if file exists
timeoutNoRequest timeout in seconds
urlYesThe URL of the file to download

Implementation Reference

  • The handler function that executes the curl download logic by building safe curl arguments and invoking the shared executeCurl helper.
    async ({ url, output_filename, resume, follow_redirects, timeout }) => { const args = ['curl']; // Add the URL args.push(url); // Add output option if (output_filename) { args.push('-o', output_filename); } else { args.push('-O'); // Use remote filename } // Add resume option if (resume) { args.push('-C', '-'); } // Add follow redirects option if (follow_redirects) { args.push('-L'); } // Add timeout if provided if (timeout) { args.push('--max-time', timeout.toString()); } // Show progress args.push('--progress-bar'); try { const result = await executeCurl(args); return { content: [ { type: "text", text: `Exit Code: ${result.exitCode}\n\nDownload ${result.exitCode === 0 ? 'completed successfully' : 'failed'}:\n${result.stdout}${result.stderr ? `\n\nOutput:\n${result.stderr}` : ''}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error executing curl: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
  • Zod input schema defining the parameters for the curl_download tool.
    { url: z.string().describe("The URL of the file to download"), output_filename: z.string().optional().describe("Output filename (if not provided, will use remote filename)"), resume: z.boolean().optional().default(false).describe("Resume partial download if file exists"), follow_redirects: z.boolean().optional().default(true).describe("Whether to follow redirects"), timeout: z.number().optional().describe("Request timeout in seconds"), },
  • src/index.ts:356-419 (registration)
    The server.tool registration for the curl_download tool, including description, schema, and handler reference."},{
    server.tool( "curl_download", "Download a file using curl", { url: z.string().describe("The URL of the file to download"), output_filename: z.string().optional().describe("Output filename (if not provided, will use remote filename)"), resume: z.boolean().optional().default(false).describe("Resume partial download if file exists"), follow_redirects: z.boolean().optional().default(true).describe("Whether to follow redirects"), timeout: z.number().optional().describe("Request timeout in seconds"), }, async ({ url, output_filename, resume, follow_redirects, timeout }) => { const args = ['curl']; // Add the URL args.push(url); // Add output option if (output_filename) { args.push('-o', output_filename); } else { args.push('-O'); // Use remote filename } // Add resume option if (resume) { args.push('-C', '-'); } // Add follow redirects option if (follow_redirects) { args.push('-L'); } // Add timeout if provided if (timeout) { args.push('--max-time', timeout.toString()); } // Show progress args.push('--progress-bar'); try { const result = await executeCurl(args); return { content: [ { type: "text", text: `Exit Code: ${result.exitCode}\n\nDownload ${result.exitCode === 0 ? 'completed successfully' : 'failed'}:\n${result.stdout}${result.stderr ? `\n\nOutput:\n${result.stderr}` : ''}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error executing curl: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } );

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/247arjun/mcp-curl'

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