Skip to main content
Glama

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
NameRequiredDescriptionDefault
name__icontainsNo
name__iendswithNo
name__iexactNo
name__istartswithNo
orderingNo
pageNo
page_sizeNo

Implementation Reference

  • 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, }), }, ], }; })
  • 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(), },
  • 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);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/baruchiro/paperless-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server