Skip to main content
Glama
meilisearch

Meilisearch MCP Server

Official
by meilisearch

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
NameRequiredDescriptionDefault
indexUidYes

Implementation Reference

  • Core implementation of get-index-metrics tool: retrieves index stats using Meilisearch client and constructs IndexMetrics object
    def 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)}")
  • MCP server handler for get-index-metrics: delegates to client.monitoring.get_index_metrics and returns formatted JSON response
    elif 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)}", ) ]
  • Registration of get-index-metrics tool in MCP list_tools handler, including input schema
    types.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 tool
    class IndexMetrics: """Detailed index metrics""" number_of_documents: int field_distribution: Dict[str, int] is_indexing: bool index_size: Optional[int] = None

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/meilisearch/meilisearch-mcp'

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