get_indexed_keys_number
Get the number of keys indexed by a specific index in Redis, helping you track indexing status.
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
| Name | Required | Description | Default |
|---|---|---|---|
| index_name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/tools/redis_query_engine.py:46-61 (handler)The actual handler function for the 'get_indexed_keys_number' tool. It uses the MCP @mcp.tool() decorator to register as a tool, connects to Redis, runs FT.SEARCH with Query('*') to get the total count of indexed keys, and returns it as a string.
@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)}" - src/tools/redis_query_engine.py:46-47 (registration)The tool is registered via the @mcp.tool() decorator on the get_indexed_keys_number async function.
@mcp.tool() async def get_indexed_keys_number(index_name: str) -> str: