Skip to main content
Glama
handoing

Instagram Video Downloader MCP Server

by handoing

download

Download Instagram videos to a local path by providing the video URL and destination directory. Track progress and save content programmatically.

Instructions

Instagram downloader

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesDownload local path (e.g. /Users/project/vue, /Users/download)
urlYesInstagram website address (e.g. https://www.instagram.com/p/DHvN6-xygmQ/, https://www.instagram.com/p/DHaq23Oy1iV/)

Implementation Reference

  • index.js:41-53 (handler)
    Handler function for the 'download' tool. Fetches Instagram video data using igdl, validates video URL, downloads the video via helper function, logs progress/errors, and returns success/error message.
    execute: async ({ url, path }, { log, reportProgress }) => { try { const data = await igdl(url); if (!data || !data[0]?.url) { throw new UserError("No downloadable video found."); } await downloadVideo(data[0].url, path, log, reportProgress); return 'Instagram download success'; } catch (e) { log.error(`Instagram download error: ${e.message}`); return 'Instagram download error'; } },
  • Input schema for the 'download' tool using Zod, defining 'url' (Instagram post URL) and 'path' (local save directory).
    parameters: z.object({ url: z.string().describe("Instagram website address (e.g. https://www.instagram.com/p/DHvN6-xygmQ/, https://www.instagram.com/p/DHaq23Oy1iV/)") .url(), path: z.string().describe("Download local path (e.g. /Users/project/vue, /Users/download)"), }),
  • index.js:33-54 (registration)
    Registration of the 'download' tool on the FastMCP server, including name, description, input schema, and execute handler.
    server.addTool({ name: "download", description: "Instagram downloader", parameters: z.object({ url: z.string().describe("Instagram website address (e.g. https://www.instagram.com/p/DHvN6-xygmQ/, https://www.instagram.com/p/DHaq23Oy1iV/)") .url(), path: z.string().describe("Download local path (e.g. /Users/project/vue, /Users/download)"), }), execute: async ({ url, path }, { log, reportProgress }) => { try { const data = await igdl(url); if (!data || !data[0]?.url) { throw new UserError("No downloadable video found."); } await downloadVideo(data[0].url, path, log, reportProgress); return 'Instagram download success'; } catch (e) { log.error(`Instagram download error: ${e.message}`); return 'Instagram download error'; } }, });
  • index.js:9-29 (helper)
    Helper function to download video stream from URL to local file using axios and fs, generates hash-based filename, logs progress and errors.
    async function downloadVideo(url, saveDir, log) { try { log.info('Starting video download...', { url }); const response = await axios.get(url, { responseType: 'stream' }); const fileName = createHash('sha256').update(url).digest('hex').slice(0, 8) + '.mp4'; const savePath = path.join(saveDir, fileName); await new Promise((resolve, reject) => { const writer = fs.createWriteStream(savePath); response.data.pipe(writer); writer.on('finish', resolve); writer.on('error', reject); }); log.info(`Video download complete! File saved as: ${savePath}`); } catch (error) { log.error(`Failed to download video: ${error.message}`); } }

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/handoing/ig-download-mcp-server'

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