stats
Retrieve statistics about all indexes or a specific index in Meilisearch to monitor performance and track data metrics.
Instructions
Get statistics about all indexes or a specific index
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| indexUid | No | Unique identifier of the index (optional, if not provided stats for all indexes will be returned) |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"indexUid": {
"description": "Unique identifier of the index (optional, if not provided stats for all indexes will be returned)",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/tools/system-tools.ts:77-87 (handler)The handler function for the 'stats' tool. It determines the appropriate Meilisearch API endpoint (/stats or /indexes/{indexUid}/stats) based on the optional indexUid parameter, fetches the stats data using apiClient, and returns it as formatted JSON text content.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:74-76 (schema)The Zod input schema for the 'stats' tool, defining an optional indexUid parameter.{ 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)The MCP server.tool call that registers the 'stats' tool, specifying its 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)High-level registration call in the main server initialization that invokes registerSystemTools to add the 'stats' tool (among others) to the MCP server.registerSystemTools(server);