Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

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

Implementation Reference

  • 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)}"

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

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