get-index-metrics
Retrieve detailed metrics for a specified index in Meilisearch, providing insights into performance and usage. Simplify index analysis for better data management.
Instructions
Get detailed metrics for an index
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| indexUid | Yes |
Implementation Reference
- src/meilisearch_mcp/monitoring.py:65-78 (handler)Core implementation of get-index-metrics tool: retrieves index stats using Meilisearch client and constructs IndexMetrics objectdef get_index_metrics(self, index_uid: str) -> IndexMetrics: """Get detailed metrics for an index""" try: index = self.client.index(index_uid) stats = index.get_stats() return IndexMetrics( number_of_documents=stats["numberOfDocuments"], field_distribution=stats["fieldDistribution"], is_indexing=stats["isIndexing"], index_size=stats.get("indexSize"), ) except Exception as e: raise Exception(f"Failed to get index metrics: {str(e)}")
- src/meilisearch_mcp/server.py:685-699 (handler)MCP server handler for get-index-metrics: delegates to client.monitoring.get_index_metrics and returns formatted JSON responseelif name == "get-index-metrics": metrics = self.meili_client.monitoring.get_index_metrics( arguments["indexUid"] ) self.logger.info( "Index metrics retrieved", index=arguments["indexUid"], metrics=metrics.__dict__, ) return [ types.TextContent( type="text", text=f"Index metrics: {json.dumps(metrics.__dict__, default=json_serializer)}", ) ]
- src/meilisearch_mcp/server.py:348-357 (registration)Registration of get-index-metrics tool in MCP list_tools handler, including input schematypes.Tool( name="get-index-metrics", description="Get detailed metrics for an index", inputSchema={ "type": "object", "properties": {"indexUid": {"type": "string"}}, "required": ["indexUid"], "additionalProperties": False, }, ),
- Dataclass defining the structure of index metrics returned by the toolclass IndexMetrics: """Detailed index metrics""" number_of_documents: int field_distribution: Dict[str, int] is_indexing: bool index_size: Optional[int] = None