npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

book-downloader-mcp

v3.0.3

Published

Programmatic LibGen+ search and downloader with an MCP server for LLM tool-calls.

Readme

LibGen Downloader + MCP Server

A powerful Node.js/TypeScript tool for searching and downloading ebooks from LibGen mirrors, featuring a Model Context Protocol (MCP) server for seamless LLM integration.

🚀 Features

  • MCP Server Integration: Enable LLMs (like Claude) to search and download books via tool calls
  • Programmatic API: Full Node.js API for automated workflows
  • Bulk Downloads: Download multiple books simultaneously by MD5
  • Smart Mirror Discovery: Automatic detection and failover for LibGen+ mirrors
  • Resilient Operations: Built-in retries and error handling for network requests
  • TypeScript Support: Full type definitions included

📦 Installation

For MCP Server (LLM Integration)

npm install -g book-downloader-mcp

For Programmatic Use

npm install book-downloader-mcp

Requirements: Node.js 16+ recommended

🤖 MCP Server Setup

Claude Desktop Integration

  1. Install globally:
npm install -g book-downloader-mcp
  1. Add to your claude_desktop_config.json:
{
  "mcpServers": {
    "libgen": {
      "command": "libgen-mcp"
    }
  }
}
  1. Restart Claude Desktop

The assistant will now have access to LibGen search and download capabilities!

Other MCP Clients

Run the MCP server directly:

libgen-mcp

Or from source:

npm run start:mcp

💻 Programmatic Usage

Basic Example

const libgen = require('@rovodev/libgen-mcp-server');

async function searchAndDownload() {
  // Initialize mirror connection
  await libgen.ensureMirrorReady();
  
  // Search for books
  const results = await libgen.searchBooks('The Art of War');
  console.log(`Found ${results.length} results`);
  
  if (results.length > 0) {
    const book = results[0];
    console.log(`Downloading: ${book.title} by ${book.authors}`);
    
    // Get direct download URL
    const url = await libgen.getDirectDownloadUrlByMd5(book.md5);
    console.log(`Download URL: ${url}`);
    
    // Download the file
    const outcome = await libgen.downloadByMd5(book.md5);
    if (outcome.status === 'ok') {
      console.log(`Downloaded to: ${outcome.path}`);
    }
  }
}

searchAndDownload();

TypeScript Example

import * as libgen from '@rovodev/libgen-mcp-server';

async function bulkDownload(searchQuery: string) {
  await libgen.ensureMirrorReady();
  
  const results = await libgen.searchBooks(searchQuery, 1, 10);
  const md5List = results
    .filter(book => book.md5)
    .map(book => book.md5!)
    .slice(0, 3); // Download first 3 books
  
  const outcomes = await libgen.downloadByMd5List(md5List);
  outcomes.forEach(outcome => {
    if (outcome.status === 'ok') {
      console.log(`✓ Downloaded: ${outcome.filename}`);
    } else {
      console.log(`✗ Failed: ${outcome.error}`);
    }
  });
}

API Reference

  • ensureMirrorReady(): Initialize mirror configuration
  • searchBooks(query, page?, pageSize?): Search for books
  • getDirectDownloadUrlByMd5(md5): Get download URL for a book
  • downloadByMd5(md5): Download a single book
  • downloadByMd5List(md5Array): Bulk download multiple books

🛠 MCP Tools Reference

When connected via MCP, the following tools are available to LLMs:

Core Operations

| Tool | Description | Input | Output | |------|-------------|-------|--------| | libgen.ensureMirror | Initialize and select working mirror | {} | { mirror, config } | | libgen.getActiveMirror | Get currently selected mirror | {} | { mirror } | | libgen.setActiveMirror | Manually set active mirror | { mirrorSrc: string } | { mirror } |

Search & Discovery

| Tool | Description | Input | Output | |------|-------------|-------|--------| | libgen.search | Search books on LibGen+ | { query: string, page?: number, pageSize?: number } | Array of book entries with metadata |

Search Result Fields: id, authors, title, publisher, year, pages, language, size, extension, mirror, md5, resolvedMirrorUrl

Download Operations

| Tool | Description | Input | Output | |------|-------------|-------|--------| | libgen.getDownloadUrl | Get direct download URL | { md5: string } | { md5, url } | | libgen.download | Download single file | { md5: string } | { md5, status, path?, filename?, total?, error? } | | libgen.bulkDownload | Download multiple files | { md5List: string[] } | Array of download outcomes |

Example MCP Workflow

// 1. Initialize
await mcp.call("libgen.ensureMirror", {});

// 2. Search
const results = await mcp.call("libgen.search", { 
  query: "machine learning", 
  page: 1 
});

// 3. Download first result
if (results.length > 0) {
  const outcome = await mcp.call("libgen.download", { 
    md5: results[0].md5 
  });
}

⚠️ Important Notes

  • Mirror Status: LibGen mirrors can be unstable. The tool automatically discovers working mirrors from the configuration
  • File Locations: Downloads are saved to the current working directory with original filenames
  • Network Resilience: Built-in retries handle temporary network issues
  • LibGen+ Compatibility: Optimized for LibGen+ mirror structure and parsing

🔧 Development

Building the Project

npm run build          # Compile TypeScript
npm run build:mcp      # Build and run MCP server
npm run watch          # Watch mode for development

Running Locally

npm run start:mcp      # Start MCP server in development
npm run lint           # Run ESLint
npm run format         # Format code with Prettier

Testing

npm test               # Run all tests
npm run test:ci        # Run tests in CI mode

Optional Integration Tests: Set environment variables for Groq API testing:

  • GROQ_API_KEY: Your Groq API key
  • RUN_GROQ_TESTS=1: Enable integration tests

Create a .env file (gitignored) or use .env.test for testing. See .env.example for reference.

🏗 Architecture

  • Core Layer: HTML parsing (jsdom), HTTP requests, mirror discovery, retry logic
  • MCP Server: Stdio-based server exposing LibGen operations as MCP tools
  • Programmatic API: Direct function exports for Node.js integration
  • Mirror Management: Dynamic configuration fetching and automatic failover

📋 Changelog

v3.0.2 (Current)

  • ✅ Full test coverage with proper mocking
  • ✅ Updated MCP SDK compatibility
  • ✅ Enhanced error handling and retries
  • ✅ Improved documentation and examples

v3.0.0

  • 🔄 LibGen+ mirrors as primary source
  • ➖ Removed search filtering for LibGen+ compatibility
  • ➖ Temporarily removed alternative downloads

v2.x

  • ➕ Alternative downloads, progress indicators
  • ➕ CLI search capabilities and shortcuts
  • ➕ Caching system

v1.x

  • 🔄 Complete UI rewrite with React/Ink/Zustand
  • ➕ Bulk download functionality
  • ✅ Enhanced error handling and retry logic

📄 License

WTFPL - Do What The F*ck You Want To Public License

⚖️ Legal Disclaimer

This tool accesses third-party LibGen mirrors which may be:

  • Blocked or unstable in certain regions
  • Subject to local laws and regulations

Use responsibly and ensure compliance with applicable laws in your jurisdiction.


🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass: npm test
  5. Submit a pull request

Repository: https://github.com/obsfx/libgen-downloader