Skip to main content
Glama
cups-sane-mcp

cups-sane-mcp

by ispb88

cups-sane-mcp

An MCP server that lets an AI assistant (any MCP client) use a printer and a scanner on your network: print text and files, scan pages and look at them.

  • Printing through CUPS: files are handed to CUPS unchanged (PDF, PostScript, PNG, JPEG, TIFF, plain text), with CUPS options passed through (scaling, resolution, tray, pages per sheet, ...). No conversion happens here: for formatted documents the client makes a PDF and uploads it. Optionally prints files from a download link (print_url, off by default).

  • Scanning through SANE: feeder or flatbed, colour/grey/black-and-white, PDF or images. The client gets small watermarked previews; the full-quality file stays on the machine (or is shared via a short-lived link).

  • Uploads through any S3-compatible bucket: rather than passing files through the conversation, get_upload_link gives the client a presigned upload URL (used from a code sandbox or any HTTP client), and print_file(id) prints it.

Tools

Tool

What it does

list_printers, print_queue, cancel_job

Printer status and jobs

printer_options

The printer's own options and the standard CUPS job options, with allowed values

print_text

Print plain text (CUPS lays it out)

print_file_data

Print a small base64 file (tiny files only)

get_upload_link, list_uploads, print_file

Upload a file to the bucket, then print it by id

scan, list_scan_sources

Scan; show the scanner's sources and modes

list_scans, get_scan, print_scan

Saved scans: list, preview / download link, reprint

print_url

Download a file from a link (e.g. cloud storage) and print it; only when MCP_PRINT_URL=1

Every print tool takes the same options: copies, duplex, page_ranges, paper, quality, scaling (auto, fit, fill, none), ppi, and options for anything else CUPS or the printer accepts (validated against printer_options).

Related MCP server: printagent

Requirements

Linux with CUPS and cups-filters (lp, lpstat, lpoptions, cancel), SANE (scanimage), ImageMagick 7 (magick, for scans), Poppler (pdftoppm, pdfinfo) and the Liberation fonts (scan preview watermark). Python 3.11+.

Install

python -m venv venv && venv/bin/pip install .
venv/bin/cups-sane-mcp               # stdio, for local clients
venv/bin/cups-sane-mcp --http        # streamable HTTP on 127.0.0.1:8710/mcp

For a local client that starts servers itself, the usual configuration looks like:

{
  "mcpServers": {
    "printer": {
      "command": "/path/to/venv/bin/cups-sane-mcp",
      "env": { "MCP_PRINTER": "Office_Printer" }
    }
  }
}

To run it permanently over HTTP, see examples/cups-sane-mcp.service (systemd, sandboxed) and "Connecting remote clients" below.

Settings (environment variables)

Variable

Default

MCP_PORT, MCP_PATH

8710, /mcp

HTTP listener (always 127.0.0.1)

MCP_PUBLIC_HOST

–

Public hostname(s) in front of it, comma-separated (Host/Origin checks)

MCP_ALLOWED_ORIGINS

–

Extra browser origins allowed to call it, comma-separated, e.g. https://app.example.com

MCP_PRINTER

CUPS default, else first printer

MCP_SCANNER

first device scanimage finds

SANE device name, e.g. escl:https://192.0.2.10:443

MCP_SCAN_SOURCES, MCP_SCAN_MODES

matched by name

JSON maps from tool names to the device's values, e.g. {"adf": "ADF Front", "flatbed": "Flatbed"}. The keys become the tool's choices

MCP_SCAN_NOTES

–

Extra guidance for the client about your scanner's quirks

MCP_SCAN_DIR

~/Documents/Scans

Where scans are saved

MCP_MAX_MB

32

Largest file accepted for printing, in MiB (uploads, links, base64)

S3_ENDPOINT_URL, S3_REGION, S3_BUCKET, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_ADDRESSING_STYLE

– , us-east-1, …, auto

Upload storage; see examples/s3.env.example

MCP_PRINT_URL

off

1 enables print_url

MCP_PRINT_URL_HOSTS

any public host

Comma-separated host suffixes print_url may download from, e.g. dropboxusercontent.com,googleusercontent.com

Without a scanner mapping, the server reads the device's --source and --mode choices and matches them by name (feeder/flatbed/duplex, colour/grey/lineart). If that picks the wrong one, list_scan_sources shows the device's own names; scan accepts those too, or set MCP_SCAN_SOURCES.

Connecting remote clients

Local clients can use stdio. Remote (web) clients need a public HTTPS URL. The server has no authentication of its own: put it behind a reverse proxy or tunnel that does (for example an OAuth-capable proxy or a zero-trust tunnel), and set MCP_PUBLIC_HOST to that hostname. If the client calls it from a browser page, add that page's origin to MCP_ALLOWED_ORIGINS. For uploads, the client's sandbox must be allowed to reach your bucket's endpoint host.

Security

  • Run it as a dedicated user with no access to anything else; examples/cups-sane-mcp.service shows a systemd sandbox (no home directories, network limited to localhost and the scanner).

  • Optional egress filter: route its traffic through a proxy that only allows the S3 endpoint (examples/tinyproxy.*, with HTTPS_PROXY in the unit).

  • Uploads: use a bucket-scoped key and a short lifecycle rule. Upload links last 15 minutes, scan download links 5 minutes, and uploads are deleted after printing.

  • print_url only downloads and prints files: no HTML rendering, no scripts. Each URL and every redirect must be http(s), on MCP_PRINT_URL_HOSTS if set, and resolve only to public addresses, so links to localhost or your network are refused. Setting MCP_PRINT_URL_HOSTS to your storage providers is recommended. If you use the egress proxy, add those hosts to its filter too.

Known issues

  • Blank pages from some PDFs. libcupsfilters 2.2.x with PDFio 1.6.6 or older can't read PDF streams with chained filters (e.g. [/ASCII85Decode /FlateDecode], which ReportLab uses by default). CUPS logs cfFilterPDFToPDF: Unsupported compound stream filter and prints a blank page while reporting success. Fixed in PDFio 1.6.7 (libcupsfilters#301): update PDFio. Until then, re-save such PDFs with Flate only (e.g. qpdf --decode-level=generalized), or set rl_config.useA85 = 0 in ReportLab.

  • Linux only. It drives the CUPS and SANE command-line tools.

Licence

MIT, see LICENSE.

Available Tools

14 tools
cancel_jobB

Cancel a print job by id (e.g. "Office_Printer-42", from print_queue).

Inputs: job_id (required). Returns: result

get_scanA

Show a saved scan's pages as watermarked preview images (up to 5 per call, starting at first_page). upload=True also returns a 5-minute download link to the full-quality file.

Inputs: filename (required), upload, first_page.

list_printersA

List printers and their state.

Inputs: no named parameters. Returns: result

list_scansC

List saved scans, newest first.

Inputs: limit. Returns: result

list_scan_sourcesA

Show the scanner in use, its own source and mode names, and which of them the scan tool's names (adf, flatbed, color, gray, ...) map to. scan accepts either kind of name.

Inputs: no named parameters. Returns: result

list_uploadsA

List files that have been uploaded and not yet printed (they are deleted after a day).

Inputs: no named parameters. Returns: result

printer_optionsB

Show what a printer accepts in the print tools' options (its own options such as tray and media type, plus standard CUPS job options), with allowed values and defaults (*).

Inputs: printer. Returns: result

scanA

Scan a document. Returns the saved file name and watermarked, low-quality preview images.

source is REQUIRED; ask the user where the pages are if you don't know. Use one of these
names, or a source name exactly as list_scan_sources shows it (also for mode):
  adf        pages stacked in the document feeder: scans every page in it.
  adf_duplex feeder, both sides of each page (if the scanner supports it).
  flatbed    ONE page lying on the glass under the lid.
Some scanners take paper from the feeder whenever it holds any, even if flatbed is
chosen, so whenever pages are in the feeder use adf.

upload=True also uploads the full-quality file and returns a download link valid
for 5 minutes (only ask for it when the actual file is needed, e.g. to save or send it).

The saved file can be reprinted with print_scan.
name: optional file name stem, e.g. "lease-signed".
Tool names: source adf|flatbed|adf_duplex, mode color|gray|bw.

Inputs: source (required), mode, name, paper, +3 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 14 tools

    Disambiguation4/5

    The four print tools (print_text, print_file, print_file_data, print_scan) share nearly identical option blocks, but each description names a distinct input source and explicitly steers callers away from the weaker variants (e.g. 'prefer get_upload_link + print_file for files'). The only genuinely confusable pair is print_file vs print_file_data, which the descriptions mitigate but do not fully eliminate.

    Naming Consistency4/5

    Most tools follow a clear verb_noun pattern (list_printers, cancel_job, get_scan, print_text), and the scan/print families are coherently grouped. Two outliers break the pattern: 'printer_options' uses noun-first with no verb, and 'scan' is a bare verb, plus 'print_queue' is really a listing operation.

    Tool Count5/5

    14 tools sits squarely in the well-scoped range, and each one maps to a distinct step in the print/scan workflow: discovery, option lookup, submission, queue inspection, cancellation, and scan retrieval. Nothing appears redundant or padded.

    Completeness4/5

    Core lifecycle is covered: list printers, inspect capabilities, submit from four input types, view and cancel queue jobs, scan, list/retrieve scans, and manage uploads. Minor gaps remain — no hold/release or pause-printer operations, no scan deletion or cleanup, and no way to query a single job's detailed status beyond print_queue.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    • Print from Claude and ChatGPT to your own printer. Free for 5 prints a month; Plus $7.99/mo.

      https://getprintbot.com/mcp
    • Have It Printed turns a document or a letter an AI assistant just helped you write into real mail. No printer, no ink, no trip to the post office. The assistant starts a job, adds the document (a file, or text it wrote with you), picks how it is mailed and gets the exact price from Have It Printed's own page count. Then it creates a checkout link: you enter the address and pay on haveitprinted.com, so no address or card ever goes through the chat. After payment it can check the order and read the tracking number. Ways to mail: flat and tracked (the default), printed and mailed flat in a rigid mailer with a free tracking number, from $15 for up to 30 pages; a $3 letter of up to 5 pages, folded into a standard envelope and mailed USPS First-Class with no tracking; or $11 by USPS Certified Mail with a tracking number. With an API key, agents can also write letters in a handwriting-style font on designed stationery, send postcards from $2, and pay on their own with a Stripe shared payment token (the bank's checks still apply). Prices include printing and postage. Letters, Certified Mail and postcards go to US addresses; flat and tracked also ships to Canada, Mexico, the UK, Germany, Australia and Japan. Uploaded files are deleted automatically and never used to train AI. Docs: https://haveitprinted.com/developers.html

    • 3D print farm management for AI. Monitor, queue, and control prints on your SimplyPrint account.

      https://simplyprint.io/api/mcp
    • Connect your AI to your own devices, 3D printers, factory tools and a shared agent task pool.

      https://ce-net.com/mcp

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to print documents, manage print queues, and control printers on macOS/Linux systems via the CUPS printing system. Supports printing PDFs, text files, and other formats with options like duplex printing, landscape orientation, and multiple copies.
      6
      22 npm
      13
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to submit PDFs or JSON-rendered templates to local printers, check printer status, and manage print jobs through MCP tools.
      18 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI assistants to print documents directly on your own printer over a private network, without cloud services or open ports. Supports printing text, URLs, and files with per-person access keys, usage limits, and detailed job control.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants to drive cloud printers: listing available printers, sending PDFs, ZPL labels and ESC/POS receipts, tracking print jobs through to completion, and managing webhooks. It connects an MCP client to the InkRelay printing API so printing happens from natural language requests.
      MIT