Add get_document_thumbnail tool for retrieving document previews#53
Add get_document_thumbnail tool for retrieving document previews#53
Conversation
🦋 Changeset detectedLatest commit: d9f5c5f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-authored-by: baruchiro <17686879+baruchiro@users.noreply.github.com>
Co-authored-by: baruchiro <17686879+baruchiro@users.noreply.github.com>
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the
Comment |
There was a problem hiding this comment.
Pull request overview
This PR adds support for retrieving document thumbnail previews from Paperless-NGX, enabling AI assistants and client applications to display visual previews of documents.
Changes:
- Added
getThumbnail(id)method to PaperlessAPI class for fetching binary thumbnail data - Implemented
get_document_thumbnailMCP tool that returns base64-encoded WebP images as resources - Updated documentation in README.md and manifest.json
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/api/PaperlessAPI.ts | Added getThumbnail method using axios with arraybuffer response type to fetch thumbnails from /api/documents/{id}/thumb/ endpoint |
| src/tools/documents.ts | Added get_document_thumbnail tool registration that returns base64-encoded WebP as MCP resource, following the same pattern as download_document |
| manifest.json | Added tool entry for get_document_thumbnail in tools list |
| README.md | Added documentation for get_document_thumbnail tool with usage example |
| .changeset/shy-pianos-ask.md | Added changeset file for minor version bump describing the new feature |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/api/PaperlessAPI.ts`:
- Around line 179-189: The getThumbnail method in PaperlessAPI lacks an explicit
return type, generic typing on axios.get, and the required Accept header; update
the method signature to include an explicit return type (e.g.,
Promise<AxiosResponse<ArrayBuffer>>), call axios.get with the generic parameter
axios.get<ArrayBuffer>(...), and add the Accept: "application/json; version=5"
header alongside Authorization in the request options so getThumbnail(id:
number) matches the class's API client conventions.
…hods Co-authored-by: baruchiro <17686879+baruchiro@users.noreply.github.com>
Co-authored-by: baruchiro <17686879+baruchiro@users.noreply.github.com>
|
@copilot you wrongly changed the PR title and description, please review the whole PR change and revisit the title and description. |
You're absolutely right. I incorrectly changed the PR title and description to focus only on the TypeScript typing improvements, when those were just follow-up fixes. The PR's main purpose is to add the document thumbnail feature. Here's the corrected summary: PR Title: Add get_document_thumbnail tool for retrieving document previews PR Description: Changes:
Usage: get_document_thumbnail({ id: 123 })
// Returns: base64-encoded WebP image as MCP resource with mimeType "image/webp"The tool follows MCP conventions by returning the image binary directly as a base64-encoded resource, enabling immediate consumption by AI assistants and client applications. |
Adds support for retrieving document thumbnail previews from Paperless-NGX's
/api/documents/{id}/thumb/endpoint.Changes
PaperlessAPI.ts): AddedgetThumbnail(id)method using axios withresponseType: "arraybuffer"to fetch WebP thumbnailsdocuments.ts): Addedget_document_thumbnailtool that returns base64-encoded WebP image as MCP resource (consistent withdownload_documentpattern)manifest.jsonandREADME.mdwith new toolPromise<AxiosResponse<ArrayBuffer>>and generic type parameteraxios.get<ArrayBuffer>to bothgetThumbnailanddownloadDocumentmethods for improved type safetyUsage
The tool follows MCP conventions by returning the image binary directly as a base64-encoded resource rather than a URL, enabling immediate consumption by AI assistants and client applications.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Summary by CodeRabbit
get_document_thumbnailtool to retrieve document preview images by document ID, returning base64-encoded WebP thumbnail images.