Chrome Dependency and Auto-Installation for MCP PDF Generation

Desktop Commander MCP eliminates manual Chrome setup by automatically downloading, caching, and launching headless Chromium binaries when generating PDFs from HTML content.

Desktop Commander MCP handles Chrome dependency and auto-installation for MCP PDF generation through an intelligent caching system that manages Chromium binaries across platforms. The implementation ensures users never need to manually install Chrome or configure browser paths, instead relying on automated detection and download logic built into the PDF tooling pipeline. This approach guarantees reproducible PDF rendering across Windows, macOS, and Linux environments.

How the Chrome Auto-Installation Pipeline Works

The PDF generation system in wonderwhy-er/DesktopCommanderMCP follows a deterministic five-step process to ensure Chromium availability before rendering documents.

Locating Cached Chromium Builds

When the PDF generation tool is invoked, MCP first constructs the cache path using <cache-dir>/chrome as the root directory. It inspects sub-folders for known build identifiers, such as mac_arm-149.0.7827.54, to determine if a suitable binary already exists. This cache lookup logic is demonstrated in test/test-pdf-chrome-cache.js at lines 59-63.

Resolving Platform-Specific Executable Paths

Once a build directory is identified, the helper function executablePathForBuild(chromeDir, buildDirName) composes the correct executable location for the current operating system. The function automatically handles platform-specific naming conventions, returning chrome.exe for Windows, chrome for Linux, and the appropriate macOS bundle structure. This resolution logic appears in test/test-pdf-chrome-cache.js at lines 18-25.

Automatic Download of Missing Binaries

If the expected binary is not found in the cache, the createChromeBuild(chromeDir, buildDirName) function initiates an automatic download. This utility fetches the appropriate Chromium tarball or zip archive from the official Google storage CDN, extracts the contents, and stores the binary under the cache directory for future reuse. The implementation details are visible in test/test-pdf-chrome-cache.js at lines 38-55.

Launching Headless Chrome for Rendering

With the executable ready, MCP spawns a headless Chrome process using Puppeteer-style flags including --headless, --disable-gpu, and --no-sandbox. The browser instance receives the HTML content and renders it to PDF format. This execution phase is implicitly handled in the PDF generation flow, with output creation shown in test/test-pdf-creation.js at lines 17-22.

Cross-Platform Build Management

The Chrome dependency and auto-installation system determines the correct binary for Windows, macOS (Intel/ARM), and Linux architectures automatically. By pinning to specific Chromium versions—such as 149.0.7827.54—the system ensures deterministic PDF rendering regardless of the host environment. Subsequent PDF generation calls reuse the cached binary, eliminating redundant downloads and improving performance.

Usage Example

The generatePdfFromHtml function abstracts all Chrome management complexity, allowing developers to generate PDFs without handling binary paths or installation steps.

import { generatePdfFromHtml } from './dist/tools/pdf/markdown.js';

// HTML source you want to print
const html = `<html><body><h1>Hello, MCP!</h1></body></html>`;

// The function internally ensures Chrome is available (auto-install if needed)
generatePdfFromHtml(html, {
  outputPath: '/tmp/hello.pdf',
  // optional: custom Chrome build identifier
  chromeBuild: 'mac_arm-149.0.7827.54',
})
  .then(() => console.log('PDF created!'))
  .catch(err => console.error('PDF generation failed:', err));

This wrapper function calls the cache-lookup logic described above, ensuring you never manually interact with Chrome binaries.

Summary

  • Desktop Commander MCP automatically manages Chromium binaries for PDF generation, eliminating manual installation requirements.
  • The system checks <cache-dir>/chrome for cached builds using identifiers like mac_arm-149.0.7827.54 before initiating downloads.
  • Platform-specific executables are resolved via executablePathForBuild(), handling Windows, macOS, and Linux naming conventions.
  • Missing binaries are automatically downloaded via createChromeBuild() from Google's official storage CDN and cached for reuse.
  • The PDF generation workflow uses headless Chrome with flags --headless, --disable-gpu, and --no-sandbox to render HTML to PDF.

Frequently Asked Questions

Does Desktop Commander MCP require a pre-installed Chrome browser?

No. Desktop Commander MCP implements zero-setup Chrome dependency management by automatically downloading and caching Chromium binaries when the PDF generation tool is first invoked. Users do not need to install Chrome or configure system PATH variables.

Where does MCP store the downloaded Chromium binaries?

MCP stores binaries in a local cache directory under <cache-dir>/chrome, with sub-folders organized by build identifiers (e.g., mac_arm-149.0.7827.54). The executablePathForBuild() function in test/test-pdf-chrome-cache.js constructs the exact path based on the current operating system.

How does the auto-installation handle different operating systems?

The createChromeBuild() function automatically detects the current platform and downloads the appropriate Chromium archive (zip for Windows/macOS, tarball for Linux). The executablePathForBuild() helper then resolves the correct executable name—whether chrome.exe, chrome, or macOS bundle binaries—ensuring cross-platform compatibility.

Can I specify a specific Chrome version for PDF generation?

Yes. You can pass a specific chromeBuild identifier (such as mac_arm-149.0.7827.54) to the generatePdfFromHtml() function options. This pins the PDF rendering to a deterministic Chromium version, ensuring consistent output across different environments and deployment scenarios.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →