Skip to main content
Glama
AI-IDM MCP Server

AI-IDM MCP Server

by XinwangTao

AI-IDM

CI License: MIT Python

AI-IDM is a multi-connection download engine written with the Python standard library only — no third-party dependencies. It speaks HTTP/HTTPS, HLS (m3u8, including AES-128 encrypted segments) and FTP/FTPS, resumes from where it stopped, and ships an MCP server so AI agents can drive it.

中文说明见 README.zh-CN.md。

$ ai-idm get https://example.com/big.iso -o ~/Downloads/big.iso -n 8
  big.iso  100.0%  8 workers  12.4MB/s  done in 6.3s

Features

Area

What you get

Multi-connection

Range splitting, 8 connections by default, 1 MB minimum chunk

Dynamic chunking

~4× more chunks than connections, claimed at runtime from a work queue — one slow connection cannot stall the transfer

Connection reuse

keep-alive pool: a worker fetches several chunks over the same TCP/TLS connection (no re-handshake per chunk)

Resume

progress in .idmpart.json, data in <dest>.idmpart, os.replace() on completion — never a half-written target file

Integrity

64-byte overlap between adjacent chunks compared byte-by-byte; optional sampling at the end (--verify-sample N)

Fallback

server ignores Range → single stream, automatically

Throttling

token bucket, plus time-of-day schedules that switch while downloading

Per-site limits

config set-site example.com 24, wildcards supported (*.cdn.com)

Proxies

HTTP/HTTPS proxy, SOCKS5, SOCKS5H (remote DNS), Windows system proxy

HLS

master playlist quality selection, EXT-X-MAP, pure-Python AES-128-CBC, resumable

FTP / FTPS

multi-connection via REST, AUTH TLS + PROT P

Queue

SQLite job queue, atomic claim, survives restarts, parallel workers

AI-ready

MCP stdio server with 12 tools (start_download, wait_download, queue_*, download_hls, …)

Browser takeover

ai-idm serve + a Chrome/Edge extension: a browser download is handed to this engine, falling back to the browser if anything fails

Related MCP server: chrome-downloader

Install

git clone https://github.com/XinwangTao/AI-IDM.git
cd AI-IDM
pip install -e .

# or run it without installing
python -m ai_idm get https://example.com/file.zip

Python 3.10+. No runtime dependencies.

Updates

Editable installs update in place from the repository remote (server + Edge extension):

ai-idm update            # check now, ask before installing
ai-idm update --check    # check only (exit 2 = update available)
ai-idm update --apply    # install without asking (used by the server)
ai-idm update --rollback # go back to the commit before the last update

ai-idm serve checks every 6 hours (30 min back-off on failure), exposes GET /update, and the extension popup shows an "update service" banner. Updates are refused while downloads are running; a failed rebase/install is rolled back to the previous commit. Flow diagram: docs/archify/ai_idm_auto_update_workflow.html.

Optional autostart (Windows): python scripts/install_autostart.py (--remove / --status).

Batch downloads (many small files)

# one URL per line; keeps <host>/<path> under the output dir
ai-idm batch urls.txt -o downloads/

# retry only what failed or is missing (resume reads failed.txt / existing files)
ai-idm batch downloads/failed.txt -o downloads/ --resume

# flat layout, higher concurrency, 3 files per host
ai-idm batch urls.txt -o downloads/ --flat --concurrency 24 --per-host 3

Small files use one GET per file (probe + download in a single request) and share a keep-alive connection pool across the whole batch; large files automatically fall back to segmented downloads with --file-connections (default 4). Global concurrency (default 16) and per-host socket concurrency (default 6) keep sites from being hammered. The batch writes batch.json and failed.txt into the output dir; one failing file never aborts the rest. The browser extension adds "download all links/images on this page" to the context menu, which starts one server-side batch job (POST /batch, progress via GET /batch, cancel via POST /batch/cancel).

CLI

# download with 8 connections, verify the checksum afterwards
ai-idm get https://example.com/file.zip -o file.zip -n 8 --checksum sha256

# inspect only: size / Range support / ETag / filename
ai-idm probe https://example.com/file.zip

# interrupted? run the same command again — it resumes
ai-idm get https://example.com/file.zip -o file.zip

# throttle to 2 MB/s, or go through a proxy
ai-idm get https://example.com/file.zip --limit 2M --proxy socks5h://127.0.0.1:1080

# HLS: pick the best variant, download the segments, merge them
ai-idm hls https://example.com/master.m3u8 -o video.ts --quality best

# FTP / FTPS
ai-idm get ftp://user:pass@host/path/file.iso -o file.iso -n 4

# persistent queue
ai-idm queue add https://example.com/a.zip -o a.zip -n 8 --priority 5
ai-idm queue run --parallel 3
ai-idm queue list

# configuration
ai-idm config show
ai-idm config set connections=16 timeout=45
ai-idm config set-site example.com 24
ai-idm config schedule add "09:00-18:00=1M" --days mon,tue,wed,thu,fri

Every command prints a JSON result, so it composes with jq and with scripts.

MCP server (for AI agents)

ai-idm mcp speaks MCP over stdio. Register it with your client:

{
  "mcpServers": {
    "idm": {
      "command": "python",
      "args": ["-m", "ai_idm", "mcp"],
      "env": { "PYTHONPATH": "/path/to/AI-IDM" }
    }
  }
}

Tools: probe_url, start_download, download_status, wait_download, cancel_download, list_downloads, queue_add, queue_run, queue_list, queue_remove, queue_retry, download_hls.

An agent can then be told "download these three URLs into D:\dl, 4 in parallel, tell me which ones failed" and it drives the tools itself.

Browser takeover (click download, get this engine)

Same architecture as IDM: browser extension → loopback HTTP service → download engine.

ai-idm serve
#   address : http://127.0.0.1:13391
#   token   : 3Qk...  (generated on first run, stored in config.json)
#   folder  : C:\Users\you\Downloads
#   panel   : http://127.0.0.1:13391/?token=...
  1. chrome://extensions → developer mode → "Load unpacked" → pick browser-extension/

  2. The options page opens on first install: paste the token, click "Test connection"

  3. From then on, browser downloads are taken over by AI-IDM and land in ~/Downloads

An unpacked install is never auto-updated by the browser, so the extension checks the repo's latest.json itself and shows an "update available" banner in the popup (since 1.12.0). Publishing to Edge Add-ons — after which the browser updates every device — is tracked in docs/PUBLISHING.md.

Three entry points: auto (cancel the browser download and hand the URL over — restored to the browser on any failure), context menu (link / media / page) and popup (current tab plus live progress). Cookies and Referer are forwarded, so logged-in downloads work. When a download finishes, the extension pops the file manager with the file selected (since 1.9.0; at most one window per folder every 2 s, toggleable in the options page).

Any script can drive the same local API:

curl -X POST http://127.0.0.1:13391/add \
  -H "X-AI-IDM-Token: $TOKEN" -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/big.iso","connections":16}'

Endpoints, security model, limits and troubleshooting: docs/BROWSER-INTEGRATION.md.

How it works

probe   HEAD → Range: bytes=0-0        → total size, ETag, Accept-Ranges
plan    chunks ≈ connections × 4
workers pull a chunk from the queue, reuse a kept-alive connection
        Range: bytes=N-(M+63)          → +64 bytes = seam sample (not written)
  ├─ write at offset into <dest>.idmpart
  ├─ compare the seam sample with the neighbour chunk already on disk
  └─ on failure: release the chunk, back off, another worker takes it
verify  seams → optional sampling → fsync → os.replace(<dest>.idmpart, <dest>)

Module map and concurrency model: docs/ARCHITECTURE.md.

Design notes and provenance

This project began as an exercise: observe why a well-known commercial download manager behaves the way it does, then rebuild that engine from scratch in Python. Several design decisions (64-byte seams, dynamic chunking, connection reuse, chunk hand-off) come from runtime observation of that program. All code here is original, written for Python; no code was copied from any product, and no binary is redistributed. What is evidence-based versus my own engineering judgement is laid out in docs/BEHAVIOR-NOTES.md.

There is no license-check bypass, DRM circumvention or paywall logic in this project, and none will be accepted.

Tests

python tests/run_all.py           # every suite
python tests/run_all.py -k seam   # one suite

13 suites / 55 checks, fully self-contained: local HTTP servers, a hand-written SOCKS5 server, a minimal FTP server, TLS-free fixtures. CI runs them on Linux and Windows over Python 3.10 / 3.12 / 3.13.

What the suites actually assert is worth knowing — e.g. connection reuse is verified by counting TCP connections on the server side, not by "the download succeeded". See the comments at the top of each file under tests/.

Known limits

Not implemented

Notes

GUI

CLI + MCP + a web panel (ai-idm serve ships one)

blob: / data: / POST-form downloads

The browser exposes no replayable URL; the extension hands these back

DASH (.mpd)

HLS only

DRM (Widevine, …)

Out of scope by design

PAC scripts

Needs a JS engine; use an explicit proxy or auto

HTTP/2, BitTorrent, Metalink

Out of scope for now

License

MIT — see LICENSE.

Available Tools

12 tools
cancel_downloadA

取消一个下载任务(保留断点状态,可再次续传)。

Inputs: id (required).

download_hlsB

下载 HLS(m3u8) 并合并为单文件。支持 master 选码率、AES-128 加密分片、断点续传。

Inputs: url (required), proxy, output, headers, +5 more.

download_statusA

查询下载进度。给定 id 查单个,不给则返回全部任务。

Inputs: id.

list_downloadsA

列出当前会话内的所有下载任务及其状态。

Inputs: no named parameters.

probe_urlA

探测 URL:返回文件大小、是否支持 Range(分片)、ETag、文件名、Content-Type。不下载。

Inputs: url (required), proxy, headers, insecure.

queue_addC

把下载加入持久化队列(SQLite),进程退出后仍保留,可断点续传。

Inputs: url (required), proxy, output, headers, +3 more.

queue_listC

查看队列:按状态统计 + 任务明细。

Inputs: status.

queue_removeC

从队列删除一个任务。

Inputs: id (required).

queue_retryC

把失败任务重新置为 pending。

Inputs: id (required).

queue_runA

消费队列直到清空(并行下载),返回各任务最终状态。

Inputs: parallel.

start_downloadB

启动一个分片多连接下载任务(异步)。返回任务 id,用 download_status 查看进度。支持断点续传。

Inputs: url (required), proxy, output, resume, +10 more.

wait_downloadB

阻塞等待任务结束(或超时),返回最终状态。

Inputs: id (required), timeout_sec.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

    TDQS

    B3.4/5.0

    Scored across 12 tools

    Disambiguation4/5

    The set cleanly separates session download management (start/status/wait/cancel/list) from persistent queue management (queue_*), and download_hls is distinct. However, download_status called without an id overlaps heavily with list_downloads, and start_download vs queue_add require reading descriptions to distinguish immediate vs deferred execution.

    Naming Consistency4/5

    All names are snake_case and the queue_* group is perfectly consistent (queue_add/run/list/remove/retry). The download group mixes noun-first (download_status, download_hls) with verb-first (start_download, cancel_download, wait_download, list_downloads), a minor but noticeable deviation.

    Tool Count5/5

    12 tools is well within the ideal 3-15 range and each tool earns its place across probe, session tasks, persistent queue, and HLS handling. No tool appears redundant enough to prune beyond the noted status/list overlap.

    Completeness5/5

    The download lifecycle is fully covered: probe before download, start/status/wait/cancel, list, persistent queue with add/run/list/remove/retry, and HLS with bitrate/decryption/resume support. No obvious dead ends for a download manager domain.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      A download manager for humans and AI with a native MCP server: add_task, list_tasks, wait_for_task with progress notifications from any MCP host. Multi-threaded multi-mirror HTTP, BT/magnet, 1000+ video sites (yt-dlp), RSS, token-secured remote Web UI. ~8MB, open source.
      12,206,305 npm
      1
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents and CLI tools to dispatch downloads through Chrome's native download engine over the MCP protocol, automatically inheriting browser cookies, login sessions, and proxy settings. Supports submitting, monitoring, pausing, resuming, and cancelling download tasks locally without manual server setup.
      8
      MIT
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to search, browse rankings, view album details and comments, manage favorites, and download manga albums or individual chapters asynchronously with progress tracking, cancellation, and retry. Also supports post-processing downloads into ZIP/PDF/long images, dynamic configuration updates, account login with cookie persistence, and access to schema/reference knowledge resources over stdio, SSE, and HTTP transports.
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables LLM agents to drive full web crawling and scraping through conversation by exposing tools for fetching, extracting, crawling, and screenshotting over stdio or SSE.
      -