get_indexed_keys_number
Retrieve the count of indexed keys for a specific Redis index to monitor indexing status and data volume.
Instructions
Retrieve the number of indexed keys by the index
Args: index_name (str): The name of the index to retrieve information about.
Returns: str: Number of indexed keys as a string
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index_name | Yes |
Implementation Reference
- src/tools/redis_query_engine.py:46-62 (handler)The handler function for the 'get_indexed_keys_number' MCP tool. Decorated with @mcp.tool() for automatic registration. Connects to Redis, performs a full search query on the index to retrieve the total number of documents, and returns it as a string or an error message if the operation fails.@mcp.tool() async def get_indexed_keys_number(index_name: str) -> str: """Retrieve the number of indexed keys by the index Args: index_name (str): The name of the index to retrieve information about. Returns: str: Number of indexed keys as a string """ try: r = RedisConnectionManager.get_connection() total = r.ft(index_name).search(Query("*")).total return str(total) except RedisError as e: return f"Error retrieving number of keys: {str(e)}"