@baruchiro/paperless-mcp
Version:
Model Context Protocol (MCP) server for interacting with Paperless-NGX document management system. Enables AI assistants to manage documents, tags, correspondents, and document types through the Paperless-NGX API.
38 lines (37 loc) • 1.41 kB
JavaScript
;
/**
* Resource URI builders for document/thumbnail downloads.
*
* URIs mirror document resources under a custom `paperless://` scheme, so the
* same identifiers can back MCP resources (`resources/list` / `resources/read`)
* without a second naming scheme.
*
* The scheme also keeps the URI well-formed regardless of filename
* content, which Python MCP clients (pydantic-validated) require.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildDocumentResourceUri = buildDocumentResourceUri;
exports.buildThumbnailResourceUri = buildThumbnailResourceUri;
/**
* Builds a resource URI for a downloaded document.
*
* The MCP resource URI is intentionally canonical and filename-free; filenames
* belong in resource metadata, while the URI identifies the fetchable content.
*/
function buildDocumentResourceUri(id, optionsOrFilename) {
const options = typeof optionsOrFilename === "string" ? {} : optionsOrFilename || {};
const params = new URLSearchParams();
if (options.original) {
params.set("original", "true");
}
const query = params.toString();
return `paperless://documents/${id}/download${query ? `?${query}` : ""}`;
}
/**
* Builds a resource URI for a document thumbnail.
*
* Mirrors `GET /api/documents/{id}/thumb/`.
*/
function buildThumbnailResourceUri(id) {
return `paperless://documents/${id}/thumb`;
}