stats
Retrieve statistics for all indexes or a specific index to monitor performance and track data metrics in Meilisearch.
Instructions
Get statistics about all indexes or a specific index
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| indexUid | No | Unique identifier of the index (optional, if not provided stats for all indexes will be returned) |
Implementation Reference
- src/tools/system-tools.ts:77-87 (handler)The handler function for the 'stats' tool. It constructs the appropriate Meilisearch API endpoint (/stats or /indexes/{indexUid}/stats), fetches the data using apiClient, and returns the JSON-formatted response as text content. Errors are handled via createErrorResponse.async ({ indexUid }) => { try { const endpoint = indexUid ? `/indexes/${indexUid}/stats` : '/stats'; const response = await apiClient.get(endpoint); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } }
- src/tools/system-tools.ts:75-75 (schema)Zod input schema defining the optional 'indexUid' parameter for specifying a particular index.indexUid: z.string().optional().describe('Unique identifier of the index (optional, if not provided stats for all indexes will be returned)'),
- src/tools/system-tools.ts:71-88 (registration)Direct registration of the 'stats' tool on the MCP server using server.tool(). Includes name, description, input schema, and handler function.server.tool( 'stats', 'Get statistics about all indexes or a specific index', { indexUid: z.string().optional().describe('Unique identifier of the index (optional, if not provided stats for all indexes will be returned)'), }, async ({ indexUid }) => { try { const endpoint = indexUid ? `/indexes/${indexUid}/stats` : '/stats'; const response = await apiClient.get(endpoint); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } } );
- src/index.ts:69-69 (registration)Top-level registration call for the system tools module (which includes the 'stats' tool) on the main MCP server instance.registerSystemTools(server);