list_document_types
Retrieve and cache all document types to efficiently handle user queries and reduce redundant API calls. Simplifies matching by name or slug for better performance.
Instructions
List all document types. IMPORTANT: When a user query may refer to a document type or tag, you should fetch all document types and all tags up front (with a large enough page_size), cache them for the session, and search locally for matches by name or slug before making further API calls. This reduces redundant requests and handles ambiguity between tags and document types efficiently.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name__icontains | No | ||
| name__iendswith | No | ||
| name__iexact | No | ||
| name__istartswith | No | ||
| ordering | No | ||
| page | No | ||
| page_size | No |
Implementation Reference
- src/tools/documentTypes.ts:28-48 (handler)Executes the tool logic: builds query string from args, fetches document types from API, enhances results with matching algorithms, returns JSON response.withErrorHandling(async (args = {}, extra) => { if (!api) throw new Error("Please configure API connection first"); const queryString = buildQueryString(args); const response = await api.request( `/document_types/${queryString ? `?${queryString}` : ""}` ); const enhancedResults = enhanceMatchingAlgorithmArray( response.results || [] ); return { content: [ { type: "text", text: JSON.stringify({ ...response, results: enhancedResults, }), }, ], }; })
- src/tools/documentTypes.ts:19-27 (schema)Input schema (Zod) for pagination and filtering parameters.{ page: z.number().optional(), page_size: z.number().optional(), name__icontains: z.string().optional(), name__iendswith: z.string().optional(), name__iexact: z.string().optional(), name__istartswith: z.string().optional(), ordering: z.string().optional(), },
- src/tools/documentTypes.ts:16-49 (registration)Registers the list_document_types tool on the MCP server, including name, long description, input schema, and handler wrapped with error handling.server.tool( "list_document_types", "List all document types. IMPORTANT: When a user query may refer to a document type or tag, you should fetch all document types and all tags up front (with a large enough page_size), cache them for the session, and search locally for matches by name or slug before making further API calls. This reduces redundant requests and handles ambiguity between tags and document types efficiently.", { page: z.number().optional(), page_size: z.number().optional(), name__icontains: z.string().optional(), name__iendswith: z.string().optional(), name__iexact: z.string().optional(), name__istartswith: z.string().optional(), ordering: z.string().optional(), }, withErrorHandling(async (args = {}, extra) => { if (!api) throw new Error("Please configure API connection first"); const queryString = buildQueryString(args); const response = await api.request( `/document_types/${queryString ? `?${queryString}` : ""}` ); const enhancedResults = enhanceMatchingAlgorithmArray( response.results || [] ); return { content: [ { type: "text", text: JSON.stringify({ ...response, results: enhancedResults, }), }, ], }; }) );
- src/index.ts:72-72 (registration)Top-level call to register all document type tools (including list_document_types) on the main MCP server instance.registerDocumentTypeTools(server, api);