Skip to main content
Glama

sane-mcp

An MCP server that lets an AI assistant (any MCP client) use a scanner on your network through SANE.

Why this one?

It works for assistants that run elsewhere, such as web or mobile clients, as well as local ones:

  • Results the AI can see. Feeder or flatbed, multi-page PDFs or images. The client gets small watermarked previews to read and check.

  • No lost pages. If nobody says where the pages are, it reads every page in the feeder, or scans the glass when the feeder is empty.

  • Full-quality files without exposing your disk. Scans stay on your machine. When you want the actual file, that one file goes to your private S3-compatible bucket with a short-lived download link.

  • Works with quirky scanners. The scanner, its sources and its modes are detected automatically, with overrides for devices that name them oddly.

Related MCP server: scan-mcp

Tools

Tool

What it does

scan

Scan from the feeder or the glass; returns the file name and previews

list_scans, get_scan

Saved scans: list, previews, download link

list_scan_sources

The scanner's sources and modes, and how the tool's names map to them

Install

Needs Linux with SANE and a supported scanner, Python 3.11+, and the libsane development headers (or your distro's python-sane package).

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

For a local client that starts servers itself:

{
  "mcpServers": {
    "scanner": {
      "command": "/path/to/venv/bin/sane-mcp",
      "env": { "MCP_SCAN_DIR": "/home/me/Scans" }
    }
  }
}

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

Settings (environment variables)

Variable

Default

MCP_PORT, MCP_PATH

8711, /mcp

HTTP listener (always 127.0.0.1)

MCP_PUBLIC_HOST

–

Public hostname(s) in front of it, comma-separated

MCP_ALLOWED_ORIGINS

–

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

MCP_SCANNER

first scanner found

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

MCP_SCAN_SOURCES, MCP_SCAN_MODES

matched by name

JSON maps from the tool's names to the scanner's own, e.g. {"adf": "ADF Front", "flatbed": "Flatbed"}

MCP_SCAN_NOTES

–

Extra guidance for the client about your scanner's quirks

MCP_SCAN_DIR

~/Documents/Scans

Where scans are saved

MCP_SCAN_LINK_MINUTES

5

How long download links work, in minutes (up to 10080, 7 days)

S3_ENDPOINT_URL, S3_REGION, S3_BUCKET, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_ADDRESSING_STYLE

– , us-east-1, …, auto

Storage for download links; see examples/s3.env.example. Scanning works without it

If the automatic matching picks the wrong source or mode, list_scan_sources shows the scanner's own names; scan accepts those too, or set MCP_SCAN_SOURCES / MCP_SCAN_MODES.

Connecting remote clients

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. To use download links, the client must be able to reach your bucket's endpoint.

Security

  • Run it as a dedicated user; examples/sane-mcp.service shows a sandboxed systemd unit.

  • Use a storage key limited to the one bucket, and a lifecycle rule that deletes old objects.

  • Download links are only made for a scan the client asks for, and the server never downloads from URLs it's given.

Known issues

  • Linux only.

Licence

MIT, see LICENSE.

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers