Skip to main content

A MCP server for Paperless-ngx

Project description

mcp-paperless-ngx MCP Server

A MCP server that connects to Paperless-ngx DMS (Document Management System) and exposes its documents as resources. This server allows you to:

  • View and access all your Paperless-ngx documents as resources
  • Read document details including metadata
  • Search documents using the Whoosh query language (Paperless-ngx's powerful search syntax)
  • Generate summaries of your documents filtered by search criteria

Components

Resources

The server exposes Paperless-ngx documents as resources:

  • Custom paperless:// URI scheme for accessing individual documents
  • Each document resource has a name, description, and appropriate MIME type
  • Document metadata like creation date, tags, and correspondents is included

Prompts

The server provides one prompt:

  • summarize-documents: Creates summaries of Paperless-ngx documents
    • Optional "query" argument to filter which documents to summarize
    • Optional "style" argument to control detail level (brief/detailed)
    • Generates a prompt combining document metadata and content snippets

Tools

The server implements one tool:

  • search-documents: Searches for documents in Paperless-ngx using Whoosh query language
    • Takes "query" as required string argument using Whoosh query syntax
    • Returns a list of matching documents with metadata
    • Supports advanced search features including:
      • Field-specific searches (type:invoice, correspondent:university)
      • Date-based queries (created:[2020 to 2023], added:yesterday)
      • Logical operators (AND, OR, NOT)
      • Wildcards for inexact matching (electr*)

Configuration

Environment Variables

The server requires the following environment variables to be set:

  • PAPERLESS_NGX_URI: The base URL of your Paperless-ngx instance (e.g., https://paperless.example.com)
  • PAPERLESS_NGX_TOKEN: An API token for authenticating with Paperless-ngx

You can create a .env file in the project root with these variables:

PAPERLESS_NGX_URI=https://your-paperless-instance.com
PAPERLESS_NGX_TOKEN=your-api-token

Creating an API Token

To create an API token for Paperless-ngx:

  1. Log in to your Paperless-ngx instance
  2. Go to Settings → Administration
  3. Click on "API Tokens"
  4. Create a new token with appropriate permissions
  5. Copy the token value for the PAPERLESS_NGX_TOKEN environment variable

Quickstart

Install

Claude Desktop

On MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json On Windows: %APPDATA%/Claude/claude_desktop_config.json

Development/Unpublished Servers Configuration
"mcpServers": {
  "mcp-paperless-ngx": {
    "command": "uvx",
    "args": [
      "mcp-paperless-ngx"
    ],
    "env": {
      "PAPERLESS_NGX_URI": "https://your-paperless-instance.com",
      "PAPERLESS_NGX_TOKEN": "your-api-token"
    }
  }
}
Published Servers Configuration
"mcpServers": {
  "mcp-paperless-ngx": {
    "command": "uvx",
    "args": [
      "mcp-paperless-ngx"
    ],
    "env": {
      "PAPERLESS_NGX_URI": "https://your-paperless-instance.com",
      "PAPERLESS_NGX_TOKEN": "your-api-token"
    }
  }
}

Example Usage

Once the MCP server is properly configured, you can:

  1. Access documents by asking Claude to list available documents
  2. Search for specific documents using natural language or specific queries
  3. Get detailed information about specific documents
  4. Ask Claude to summarize documents matching certain criteria

Example prompts:

  • "Show me a list of my Paperless-ngx documents"
  • "Search for my documents using the query: type:invoice AND (created:[2023-01-01 to 2023-12-31])"
  • "Find documents with Whoosh query: correspondent:university AND tag:important"
  • "Search for documents with the query: insurance contract* AND NOT expired"
  • "Summarize the content of my tax documents from 2023 using query: tag:tax created:[2023-01-01 to 2023-12-31]"

Development

Building and Publishing

To prepare the package for distribution:

  1. Sync dependencies and update lockfile:
uv sync
  1. Build package distributions:
uv build

This will create source and wheel distributions in the dist/ directory.

  1. Publish to PyPI:
uv publish

Note: You'll need to set PyPI credentials via environment variables or command flags:

  • Token: --token or UV_PUBLISH_TOKEN
  • Or username/password: --username/UV_PUBLISH_USERNAME and --password/UV_PUBLISH_PASSWORD

Search Syntax Reference

Paperless-ngx uses the Whoosh query language for its search functionality. This section provides a quick reference for the most common search patterns.

Basic Search

By default, Paperless returns documents that contain all words in your query:

invoice receipt

This matches documents containing both "invoice" AND "receipt".

Field-Specific Searches

You can search within specific document fields:

type:invoice                 # Documents of type "invoice"
correspondent:university     # Documents from "university" correspondent
tag:important                # Documents with "important" tag

Date-Based Searches

Search by document dates using various formats:

created:[2020 to 2023]       # Date range (created between 2020-2023)
added:yesterday              # Relative date (added yesterday)
modified:today               # Relative date (modified today)

Logical Operators

Combine terms with logical operators:

invoice AND receipt          # Documents with both terms
invoice OR receipt           # Documents with either term
invoice AND NOT paid         # Documents with "invoice" but not "paid"
invoice AND (paid OR unpaid) # More complex expressions

Inexact Matching

Search for variations of terms:

electr*                      # Wildcard search (matches "electric", "electronics", etc.)

For more details on Whoosh query syntax, see the official documentation.

Debugging

Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the MCP Inspector.

You can launch the MCP Inspector via npm with this command:

npx @modelcontextprotocol/inspector uv run mcp-paperless-ngx

Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_paperless_ngx-0.1.2.tar.gz (34.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_paperless_ngx-0.1.2-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file mcp_paperless_ngx-0.1.2.tar.gz.

File metadata

  • Download URL: mcp_paperless_ngx-0.1.2.tar.gz
  • Upload date:
  • Size: 34.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for mcp_paperless_ngx-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0dbdfce07d4466570e017c81e8eb13505d2f4e9bdfde2a5d80acf31c8dabceff
MD5 cfe6e8b693b3e447994c56e4652709b3
BLAKE2b-256 d2c5b480c15f12346a803da8717310507dc0c5e901f939a210f65ca91054e70c

See more details on using hashes here.

File details

Details for the file mcp_paperless_ngx-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_paperless_ngx-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e276e132d88a0b6ba038903bf6ccbf7c8c57300fb0853c5b9b509bf0d2be91fc
MD5 e17cfc52d68f0bb6853dced44705d2cc
BLAKE2b-256 9a236de0a8c311484154c521c3b49ab7f6ed19fb33b964a6a13237fa737f4ff9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page