Skip to main content
Glama

fetchDocuments

Retrieve documents from a specified namespace using filter criteria, pagination, and customizable property inclusion. Simplifies document access and organization within knowledge bases.

Instructions

Fetches documents from the namespace based on filter criteria. Supports pagination and including specific document properties.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
documentIdsNo
filterConfigYes
includeConfigNo
namespaceIdNo
paginationNo
tenantIdNo

Implementation Reference

  • Handler function that processes input parameters, converts enum strings to enums, creates SourceSync client, and invokes client.getDocuments() within safeApiCall.
    async (params) => { return safeApiCall(async () => { const { namespaceId, tenantId, documentIds, pagination, filterConfig, includeConfig, } = params // Create a client with the provided parameters const client = createClient({ namespaceId, tenantId }) // Add documentIds to filterConfig if provided if (documentIds && documentIds.length > 0 && !filterConfig.documentIds) { filterConfig.documentIds = documentIds } // Call the getDocuments method with properly structured parameters return await client.getDocuments({ filterConfig: { ...filterConfig, // Convert string enum values to their SourceSync enum equivalents documentTypes: filterConfig.documentTypes?.map( (type: string) => SourceSyncDocumentType[ type as keyof typeof SourceSyncDocumentType ], ), documentIngestionSources: filterConfig.documentIngestionSources?.map( (source: string) => SourceSyncIngestionSource[ source as keyof typeof SourceSyncIngestionSource ], ), documentIngestionStatuses: filterConfig.documentIngestionStatuses?.map( (status: string) => SourceSyncIngestionStatus[ status as keyof typeof SourceSyncIngestionStatus ], ), }, pagination, includeConfig: includeConfig || { documents: true }, }) }) },
  • Zod schema defining the input parameters for the fetchDocuments tool, including namespace, filters, pagination, and include options.
    export const FetchDocumentsSchema = z.object({ namespaceId: namespaceIdSchema.optional(), documentIds: z.array(z.string()).optional(), pagination: PaginationSchema.optional(), tenantId: tenantIdSchema, filterConfig: FilterConfigSchema, includeConfig: z .object({ documents: z.boolean().optional(), stats: z.boolean().optional(), statsBySource: z.boolean().optional(), statsByStatus: z.boolean().optional(), rawFileUrl: z.boolean().optional(), parsedTextFileUrl: z.boolean().optional(), }) .optional(), })
  • src/index.ts:352-405 (registration)
    MCP server.tool registration for the fetchDocuments tool, providing name, description, schema, and handler function.
    server.tool( 'fetchDocuments', 'Fetches documents from the namespace based on filter criteria. Supports pagination and including specific document properties.', FetchDocumentsSchema.shape, async (params) => { return safeApiCall(async () => { const { namespaceId, tenantId, documentIds, pagination, filterConfig, includeConfig, } = params // Create a client with the provided parameters const client = createClient({ namespaceId, tenantId }) // Add documentIds to filterConfig if provided if (documentIds && documentIds.length > 0 && !filterConfig.documentIds) { filterConfig.documentIds = documentIds } // Call the getDocuments method with properly structured parameters return await client.getDocuments({ filterConfig: { ...filterConfig, // Convert string enum values to their SourceSync enum equivalents documentTypes: filterConfig.documentTypes?.map( (type: string) => SourceSyncDocumentType[ type as keyof typeof SourceSyncDocumentType ], ), documentIngestionSources: filterConfig.documentIngestionSources?.map( (source: string) => SourceSyncIngestionSource[ source as keyof typeof SourceSyncIngestionSource ], ), documentIngestionStatuses: filterConfig.documentIngestionStatuses?.map( (status: string) => SourceSyncIngestionStatus[ status as keyof typeof SourceSyncIngestionStatus ], ), }, pagination, includeConfig: includeConfig || { documents: true }, }) }) }, )

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/pbteja1998/sourcesyncai-mcp'

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