search_documents
Search document content, titles, and metadata in your Paperless-NGX instance using a full-text query for precise and comprehensive results.
Instructions
Full text search for documents. This tool is for searching document content, title, and metadata using a full text query. For general document listing or filtering by fields, use 'list_documents' instead.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- src/tools/documents.ts:266-270 (handler)Handler function that executes the 'search_documents' tool logic: checks API, calls PaperlessAPI.searchDocuments with the input query, processes response with convertDocsWithNames, wrapped in error handling.withErrorHandling(async (args, extra) => { if (!api) throw new Error("Please configure API connection first"); const docsResponse = await api.searchDocuments(args.query); return convertDocsWithNames(docsResponse, api); })
- src/tools/documents.ts:263-265 (schema)Zod input schema for the tool, defining a required 'query' string parameter.{ query: z.string(), },
- src/tools/documents.ts:260-271 (registration)MCP tool registration call via server.tool(), including name, description, schema, and handler for 'search_documents'.server.tool( "search_documents", "Full text search for documents. This tool is for searching document content, title, and metadata using a full text query. For general document listing or filtering by fields, use 'list_documents' instead.", { query: z.string(), }, withErrorHandling(async (args, extra) => { if (!api) throw new Error("Please configure API connection first"); const docsResponse = await api.searchDocuments(args.query); return convertDocsWithNames(docsResponse, api); }) );
- src/api/PaperlessAPI.ts:158-163 (helper)Core helper method in PaperlessAPI class that performs the HTTP request to the Paperless-ngx API endpoint /documents/?query=... to retrieve search results.async searchDocuments(query: string): Promise<DocumentsResponse> { const response = await this.request<DocumentsResponse>( `/documents/?query=${encodeURIComponent(query)}` ); return response; }
- src/index.ts:69-69 (registration)Top-level call to register all document tools, including 'search_documents', on the MCP server instance.registerDocumentTools(server, api);