get-documents
Retrieve documents from a Meilisearch index by specifying filters, fields, and pagination parameters to access stored data.
Instructions
Get documents from a Meilisearch index
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| indexUid | Yes | Unique identifier of the index | |
| limit | No | Maximum number of documents to return (default: 20) | |
| offset | No | Number of documents to skip (default: 0) | |
| fields | No | Fields to return in the documents | |
| filter | No | Filter query to apply |
Implementation Reference
- src/tools/document-tools.ts:71-87 (handler)Handler function that implements the core logic of the 'get-documents' tool by querying the Meilisearch API for documents in the specified index with optional pagination, field selection, and filtering.async ({ indexUid, limit, offset, fields, filter }: GetDocumentsParams) => { try { const response = await apiClient.get(`/indexes/${indexUid}/documents`, { params: { limit, offset, fields: fields?.join(','), filter, }, }); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } }
- src/tools/document-tools.ts:64-70 (schema)Zod schema defining the input parameters for the 'get-documents' tool: indexUid (required), limit, offset, fields, filter (optional).{ indexUid: z.string().describe('Unique identifier of the index'), limit: z.number().min(1).max(1000).optional().describe('Maximum number of documents to return (default: 20)'), offset: z.number().min(0).optional().describe('Number of documents to skip (default: 0)'), fields: z.array(z.string()).optional().describe('Fields to return in the documents'), filter: z.string().optional().describe('Filter query to apply'), },
- src/tools/document-tools.ts:62-88 (registration)Registration of the 'get-documents' tool using server.tool(), specifying the tool name, description, input schema, and handler function within the registerDocumentTools module.'get-documents', 'Get documents from a Meilisearch index', { indexUid: z.string().describe('Unique identifier of the index'), limit: z.number().min(1).max(1000).optional().describe('Maximum number of documents to return (default: 20)'), offset: z.number().min(0).optional().describe('Number of documents to skip (default: 0)'), fields: z.array(z.string()).optional().describe('Fields to return in the documents'), filter: z.string().optional().describe('Filter query to apply'), }, async ({ indexUid, limit, offset, fields, filter }: GetDocumentsParams) => { try { const response = await apiClient.get(`/indexes/${indexUid}/documents`, { params: { limit, offset, fields: fields?.join(','), filter, }, }); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } } );
- src/index.ts:65-65 (registration)Top-level call to registerDocumentTools(server) in the main MCP server initialization, which includes the 'get-documents' tool among others.registerDocumentTools(server);
- src/tools/document-tools.ts:14-20 (helper)TypeScript interface defining the parameters for the get-documents handler function.interface GetDocumentsParams { indexUid: string; limit?: number; offset?: number; fields?: string[]; filter?: string; }