update_document_type
Modify document type settings in Paperless-NGX by updating metadata such as name and matching algorithm to improve document organization and retrieval.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| match | No | ||
| matching_algorithm | No | ||
| name | Yes |
Implementation Reference
- src/tools/documentTypes.ts:101-109 (handler)The handler function wrapped in withErrorHandling that implements the core logic of the update_document_type tool: validates API, destructures args, calls updateDocumentType API helper, enhances the response with matching algorithm info, and returns JSON as text content.withErrorHandling(async (args, extra) => { if (!api) throw new Error("Please configure API connection first"); const { id, ...payloadWithoutId } = args; const response = await api.updateDocumentType(id, payloadWithoutId); const enhancedDocumentType = enhanceMatchingAlgorithm(response); return { content: [{ type: "text", text: JSON.stringify(enhancedDocumentType) }], }; })
- src/tools/documentTypes.ts:89-100 (schema)Zod input schema defining required 'id' and 'name', optional 'match' and 'matching_algorithm' (0-6) for the tool.{ id: z.number(), name: z.string(), match: z.string().optional(), matching_algorithm: z .number() .int() .min(0) .max(6) .optional() .describe(MATCHING_ALGORITHM_DESCRIPTION), },
- src/tools/documentTypes.ts:87-110 (registration)Registration of the 'update_document_type' MCP tool using server.tool(), including schema and handler inline within registerDocumentTypeTools function.server.tool( "update_document_type", { id: z.number(), name: z.string(), match: z.string().optional(), matching_algorithm: z .number() .int() .min(0) .max(6) .optional() .describe(MATCHING_ALGORITHM_DESCRIPTION), }, withErrorHandling(async (args, extra) => { if (!api) throw new Error("Please configure API connection first"); const { id, ...payloadWithoutId } = args; const response = await api.updateDocumentType(id, payloadWithoutId); const enhancedDocumentType = enhanceMatchingAlgorithm(response); return { content: [{ type: "text", text: JSON.stringify(enhancedDocumentType) }], }; }) );
- src/api/PaperlessAPI.ts:255-263 (helper)API wrapper helper method that sends PUT request to /document_types/{id}/ with the update data.async updateDocumentType( id: number, data: Partial<DocumentType> ): Promise<DocumentType> { return this.request<DocumentType>(`/document_types/${id}/`, { method: "PUT", body: JSON.stringify(data), }); }