get_indexed_keys_number
Retrieve the count of indexed keys for a specific index in Redis. Input the index name to get the number of keys indexed, simplifying data management and search operations.
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 decorated with @mcp.tool() that implements the get_indexed_keys_number tool. It connects to Redis, performs a search query on the specified index to get the total number of documents, and returns it as a string or an error message.@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)}"